Commit 0dc4a63e authored by Grégory Wisniewski's avatar Grégory Wisniewski

Use isListeningConnection() instead of isinstance in storage/operation.py.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@354 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 85b013cb
...@@ -89,7 +89,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -89,7 +89,7 @@ class OperationEventHandler(StorageEventHandler):
app.executeQueuedEvents() app.executeQueuedEvents()
def timeoutExpired(self, conn): def timeoutExpired(self, conn):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
if conn.getUUID() == self.app.primary_master_node.getUUID(): if conn.getUUID() == self.app.primary_master_node.getUUID():
# If a primary master node timeouts, I cannot continue. # If a primary master node timeouts, I cannot continue.
logging.critical('the primary master node times out') logging.critical('the primary master node times out')
...@@ -103,7 +103,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -103,7 +103,7 @@ class OperationEventHandler(StorageEventHandler):
StorageEventHandler.timeoutExpired(self, conn) StorageEventHandler.timeoutExpired(self, conn)
def connectionClosed(self, conn): def connectionClosed(self, conn):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
if conn.getUUID() == self.app.primary_master_node.getUUID(): if conn.getUUID() == self.app.primary_master_node.getUUID():
# If a primary master node closes, I cannot continue. # If a primary master node closes, I cannot continue.
logging.critical('the primary master node is dead') logging.critical('the primary master node is dead')
...@@ -117,7 +117,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -117,7 +117,7 @@ class OperationEventHandler(StorageEventHandler):
StorageEventHandler.connectionClosed(self, conn) StorageEventHandler.connectionClosed(self, conn)
def peerBroken(self, conn): def peerBroken(self, conn):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
if conn.getUUID() == self.app.primary_master_node.getUUID(): if conn.getUUID() == self.app.primary_master_node.getUUID():
# If a primary master node gets broken, I cannot continue. # If a primary master node gets broken, I cannot continue.
logging.critical('the primary master node is broken') logging.critical('the primary master node is broken')
...@@ -132,7 +132,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -132,7 +132,7 @@ class OperationEventHandler(StorageEventHandler):
def handleRequestNodeIdentification(self, conn, packet, node_type, def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, name): uuid, ip_address, port, name):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app app = self.app
...@@ -185,7 +185,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -185,7 +185,7 @@ class OperationEventHandler(StorageEventHandler):
def handleAcceptNodeIdentification(self, conn, packet, node_type, def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, uuid, ip_address, port,
num_partitions, num_replicas): num_partitions, num_replicas):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
raise NotImplementedError raise NotImplementedError
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
...@@ -206,7 +206,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -206,7 +206,7 @@ class OperationEventHandler(StorageEventHandler):
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that """This is very similar to Send Partition Table, except that
the information is only about changes from the previous.""" the information is only about changes from the previous."""
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
nm = app.nm nm = app.nm
pt = app.pt pt = app.pt
...@@ -243,7 +243,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -243,7 +243,7 @@ class OperationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleStopOperation(self, conn, packet): def handleStopOperation(self, conn, packet):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
raise OperationFailure('operation stopped') raise OperationFailure('operation stopped')
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
...@@ -273,7 +273,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -273,7 +273,7 @@ class OperationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleLockInformation(self, conn, packet, tid): def handleLockInformation(self, conn, packet, tid):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
...@@ -290,7 +290,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -290,7 +290,7 @@ class OperationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleUnlockInformation(self, conn, packet, tid): def handleUnlockInformation(self, conn, packet, tid):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
...@@ -454,13 +454,13 @@ class OperationEventHandler(StorageEventHandler): ...@@ -454,13 +454,13 @@ class OperationEventHandler(StorageEventHandler):
pass pass
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
self.app.replicator.setCriticalTID(packet, ltid) self.app.replicator.setCriticalTID(packet, ltid)
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list): def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
self.app.replicator.setUnfinishedTIDList(tid_list) self.app.replicator.setUnfinishedTIDList(tid_list)
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment