[Neo-report] r2636 vincent - in /trunk/neo: client/ client/handlers/ lib/ tests/client/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Jan 24 15:17:41 CET 2011
Author: vincent
Date: Mon Jan 24 15:17:41 2011
New Revision: 2636
Log:
Use exception to notify non-ready nodes.
Modified:
trunk/neo/client/app.py
trunk/neo/client/handlers/master.py
trunk/neo/client/handlers/storage.py
trunk/neo/client/pool.py
trunk/neo/lib/exception.py
trunk/neo/tests/client/testClientApp.py
trunk/neo/tests/client/testMasterHandler.py
trunk/neo/tests/client/testStorageHandler.py
Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -113,7 +113,6 @@ class ThreadContext(object):
'txn_info': 0,
'history': None,
'node_tids': {},
- 'node_ready': False,
'asked_object': 0,
'undo_object_tid_dict': {},
'involved_nodes': set(),
@@ -1160,15 +1159,6 @@ class Application(object):
def invalidationBarrier(self):
self._askPrimary(Packets.AskBarrier())
- def setNodeReady(self):
- self.local_var.node_ready = True
-
- def setNodeNotReady(self):
- self.local_var.node_ready = False
-
- def isNodeReady(self):
- return self.local_var.node_ready
-
def setTID(self, value):
self.local_var.tid = value
Modified: trunk/neo/client/handlers/master.py
==============================================================================
--- trunk/neo/client/handlers/master.py [iso-8859-1] (original)
+++ trunk/neo/client/handlers/master.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -29,7 +29,6 @@ class PrimaryBootstrapHandler(AnswerBase
def notReady(self, conn, message):
app = self.app
app.trying_master_node = None
- app.setNodeNotReady()
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
Modified: trunk/neo/client/handlers/storage.py
==============================================================================
--- trunk/neo/client/handlers/storage.py [iso-8859-1] (original)
+++ trunk/neo/client/handlers/storage.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -24,6 +24,7 @@ from neo.lib.protocol import NodeTypes,
from neo.lib.util import dump
from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
+from neo.lib.exception import NodeNotReady
class StorageEventHandler(BaseHandler):
@@ -45,7 +46,7 @@ class StorageBootstrapHandler(AnswerBase
""" Handler used when connecting to a storage node """
def notReady(self, conn, message):
- self.app.setNodeNotReady()
+ raise NodeNotReady(message)
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
Modified: trunk/neo/client/pool.py
==============================================================================
--- trunk/neo/client/pool.py [iso-8859-1] (original)
+++ trunk/neo/client/pool.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -24,6 +24,7 @@ from neo.lib.protocol import NodeTypes,
from neo.lib.connection import MTClientConnection, ConnectionClosed
from neo.client.exception import NEOStorageError
from neo.lib.profiling import profiler_decorator
+from neo.lib.exception import NodeNotReady
# How long before we might retry a connection to a node to which connection
# failed in the past.
@@ -60,7 +61,6 @@ class ConnectionPool(object):
addr = node.getAddress()
assert addr is not None
app = self.app
- app.setNodeReady()
neo.lib.logging.debug('trying to connect to %s - %s', node,
node.getState())
conn = MTClientConnection(app.em, app.storage_event_handler, addr,
@@ -74,15 +74,14 @@ class ConnectionPool(object):
except ConnectionClosed:
neo.lib.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
- return None
-
- if app.isNodeReady():
- neo.lib.logging.info('Connected %r', node)
- return conn
- else:
+ conn = None
+ except NodeNotReady:
neo.lib.logging.info('%r not ready', node)
self.notifyFailure(node)
- return NOT_READY
+ conn = NOT_READY
+ else:
+ neo.lib.logging.info('Connected %r', node)
+ return conn
@profiler_decorator
def _dropConnections(self):
Modified: trunk/neo/lib/exception.py
==============================================================================
--- trunk/neo/lib/exception.py [iso-8859-1] (original)
+++ trunk/neo/lib/exception.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -29,3 +29,7 @@ class OperationFailure(NeoException):
class DatabaseFailure(NeoException):
pass
+
+class NodeNotReady(NeoException):
+ pass
+
Modified: trunk/neo/tests/client/testClientApp.py
==============================================================================
--- trunk/neo/tests/client/testClientApp.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testClientApp.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -1027,7 +1027,6 @@ class ClientApplicationTests(NeoUnitTest
app._waitMessage = _waitMessage6
# third iteration : node not ready
def _waitMessage4(conn, msg_id, handler=None):
- app.setNodeNotReady()
app.trying_master_node = None
app._waitMessage = _waitMessage5
# second iteration : master node changed
Modified: trunk/neo/tests/client/testMasterHandler.py
==============================================================================
--- trunk/neo/tests/client/testMasterHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testMasterHandler.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -50,7 +50,6 @@ class MasterBootstrapHandlerTests(Master
conn = self.getConnection()
self.handler.notReady(conn, 'message')
self.assertEqual(self.app.trying_master_node, None)
- self.checkCalledOnApp('setNodeNotReady')
def test_acceptIdentification1(self):
""" Non-master node """
Modified: trunk/neo/tests/client/testStorageHandler.py
==============================================================================
--- trunk/neo/tests/client/testStorageHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testStorageHandler.py [iso-8859-1] Mon Jan 24 15:17:41 2011
@@ -24,6 +24,7 @@ from neo.client.handlers.storage import
from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
from ZODB.POSException import ConflictError
+from neo.lib.exception import NodeNotReady
MARKER = []
@@ -39,9 +40,7 @@ class StorageBootstrapHandlerTests(NeoUn
def test_notReady(self):
conn = self.getConnection()
- self.handler.notReady(conn, 'message')
- calls = self.app.mockGetNamedCalls('setNodeNotReady')
- self.assertEqual(len(calls), 1)
+ self.assertRaises(NodeNotReady, self.handler.notReady, conn, 'message')
def test_acceptIdentification1(self):
""" Not a storage node """
More information about the Neo-report
mailing list