Commit 2227293f authored by Aurel's avatar Aurel

remove all isinstance by test of isListeningConnection


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@401 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e2b1da10
...@@ -37,7 +37,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -37,7 +37,7 @@ class VerificationEventHandler(StorageEventHandler):
StorageEventHandler.connectionAccepted(self, conn, s, addr) StorageEventHandler.connectionAccepted(self, conn, s, addr)
def timeoutExpired(self, conn): def timeoutExpired(self, conn):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
# 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')
raise PrimaryFailure('the primary master node times out') raise PrimaryFailure('the primary master node times out')
...@@ -45,7 +45,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -45,7 +45,7 @@ class VerificationEventHandler(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 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')
raise PrimaryFailure('the primary master node is dead') raise PrimaryFailure('the primary master node is dead')
...@@ -53,7 +53,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -53,7 +53,7 @@ class VerificationEventHandler(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 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')
raise PrimaryFailure('the primary master node is broken') raise PrimaryFailure('the primary master node is broken')
...@@ -62,7 +62,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -62,7 +62,7 @@ class VerificationEventHandler(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
...@@ -112,7 +112,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -112,7 +112,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list): known_master_list):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
if app.primary_master_node.getUUID() != primary_uuid: if app.primary_master_node.getUUID() != primary_uuid:
raise PrimaryFailure('the primary master node seems to have changed') raise PrimaryFailure('the primary master node seems to have changed')
...@@ -123,7 +123,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -123,7 +123,7 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAskLastIDs(self, conn, packet): def handleAskLastIDs(self, conn, packet):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
p = Packet() p = Packet()
oid = app.dm.getLastOID() or INVALID_OID oid = app.dm.getLastOID() or INVALID_OID
...@@ -134,7 +134,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -134,7 +134,7 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAskPartitionTable(self, conn, packet, offset_list): def handleAskPartitionTable(self, conn, packet, offset_list):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
row_list = [] row_list = []
try: try:
...@@ -162,7 +162,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -162,7 +162,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleSendPartitionTable(self, conn, packet, ptid, row_list): def handleSendPartitionTable(self, conn, packet, ptid, row_list):
"""A primary master node sends this packet to synchronize a partition """A primary master node sends this packet to synchronize a partition
table. Note that the message can be split into multiple packets.""" table. Note that the message can be split into multiple packets."""
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
...@@ -196,7 +196,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -196,7 +196,7 @@ class VerificationEventHandler(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
...@@ -223,19 +223,19 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -223,19 +223,19 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleStartOperation(self, conn, packet): def handleStartOperation(self, conn, packet):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
self.app.operational = True self.app.operational = True
else: else:
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)
def handleAskUnfinishedTransactions(self, conn, packet): def handleAskUnfinishedTransactions(self, conn, packet):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
tid_list = app.dm.getUnfinishedTIDList() tid_list = app.dm.getUnfinishedTIDList()
p = Packet() p = Packet()
...@@ -246,7 +246,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -246,7 +246,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleAskTransactionInformation(self, conn, packet, tid): def handleAskTransactionInformation(self, conn, packet, tid):
app = self.app app = self.app
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
# If this is from a primary master node, assume that it wants # If this is from a primary master node, assume that it wants
# to obtain information about the transaction, even if it has # to obtain information about the transaction, even if it has
# not been finished. # not been finished.
...@@ -263,7 +263,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -263,7 +263,7 @@ class VerificationEventHandler(StorageEventHandler):
conn.addPacket(p) conn.addPacket(p)
def handleAskObjectPresent(self, conn, packet, oid, tid): def handleAskObjectPresent(self, conn, packet, oid, tid):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
p = Packet() p = Packet()
if app.dm.objectPresent(oid, tid): if app.dm.objectPresent(oid, tid):
...@@ -276,14 +276,14 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -276,14 +276,14 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleDeleteTransaction(self, conn, packet, tid): def handleDeleteTransaction(self, conn, packet, tid):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
app.dm.deleteTransaction(tid, all = True) app.dm.deleteTransaction(tid, all = True)
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleCommitTransaction(self, conn, packet, tid): def handleCommitTransaction(self, conn, packet, tid):
if isinstance(conn, ClientConnection): if not conn.isListeningConnection():
app = self.app app = self.app
app.dm.finishTransaction(tid) app.dm.finishTransaction(tid)
else: else:
......
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