Commit 858cbdc6 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rename isListeningConnection to isServerConnection.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@426 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 8197473f
...@@ -315,7 +315,7 @@ class Connection(BaseConnection): ...@@ -315,7 +315,7 @@ class Connection(BaseConnection):
self.event_dict[msg_id] = event self.event_dict[msg_id] = event
self.em.addIdleEvent(event) self.em.addIdleEvent(event)
def isListeningConnection(self): def isServerConnection(self):
raise NotImplementedError raise NotImplementedError
class ClientConnection(Connection): class ClientConnection(Connection):
...@@ -358,12 +358,12 @@ class ClientConnection(Connection): ...@@ -358,12 +358,12 @@ class ClientConnection(Connection):
else: else:
Connection.writable(self) Connection.writable(self)
def isListeningConnection(self): def isServerConnection(self):
return False return False
class ServerConnection(Connection): class ServerConnection(Connection):
"""A connection from a remote node to this node.""" """A connection from a remote node to this node."""
def isListeningConnection(self): def isServerConnection(self):
return True return True
class MTClientConnection(ClientConnection): class MTClientConnection(ClientConnection):
......
...@@ -59,12 +59,12 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -59,12 +59,12 @@ class ElectionEventHandler(MasterEventHandler):
MasterEventHandler.connectionFailed(self, conn) MasterEventHandler.connectionFailed(self, conn)
def connectionClosed(self, conn): def connectionClosed(self, conn):
if not conn.isListeningConnection(): if not conn.isServerConnection():
self.connectionFailed(conn) self.connectionFailed(conn)
MasterEventHandler.connectionClosed(self, conn) MasterEventHandler.connectionClosed(self, conn)
def timeoutExpired(self, conn): def timeoutExpired(self, conn):
if not conn.isListeningConnection(): if not conn.isServerConnection():
self.connectionFailed(conn) self.connectionFailed(conn)
MasterEventHandler.timeoutExpired(self, conn) MasterEventHandler.timeoutExpired(self, conn)
...@@ -72,7 +72,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -72,7 +72,7 @@ class ElectionEventHandler(MasterEventHandler):
app = self.app app = self.app
addr = conn.getAddress() addr = conn.getAddress()
node = app.nm.getNodeByServer(addr) node = app.nm.getNodeByServer(addr)
if not conn.isListeningConnection(): if not conn.isServerConnection():
if node is not None: if node is not None:
node.setState(DOWN_STATE) node.setState(DOWN_STATE)
app.negotiating_master_node_set.discard(addr) app.negotiating_master_node_set.discard(addr)
...@@ -82,7 +82,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -82,7 +82,7 @@ class ElectionEventHandler(MasterEventHandler):
MasterEventHandler.peerBroken(self, conn) MasterEventHandler.peerBroken(self, conn)
def packetReceived(self, conn, packet): def packetReceived(self, conn, packet):
if not conn.isListeningConnection(): if not conn.isServerConnection():
node = self.app.nm.getNodeByServer(conn.getAddress()) node = self.app.nm.getNodeByServer(conn.getAddress())
if node.getState() != BROKEN_STATE: if node.getState() != BROKEN_STATE:
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
...@@ -91,7 +91,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -91,7 +91,7 @@ class ElectionEventHandler(MasterEventHandler):
def handleAcceptNodeIdentification(self, conn, packet, node_type, def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, num_partitions, uuid, ip_address, port, num_partitions,
num_replicas, your_uuid): num_replicas, your_uuid):
if not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
node = app.nm.getNodeByServer(conn.getAddress()) node = app.nm.getNodeByServer(conn.getAddress())
if node_type != MASTER_NODE_TYPE: if node_type != MASTER_NODE_TYPE:
...@@ -127,7 +127,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -127,7 +127,7 @@ class ElectionEventHandler(MasterEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list): def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list):
if not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
# Register new master nodes. # Register new master nodes.
for ip_address, port, uuid in known_master_list: for ip_address, port, uuid in known_master_list:
...@@ -176,7 +176,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -176,7 +176,7 @@ class ElectionEventHandler(MasterEventHandler):
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 not conn.isListeningConnection(): if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app app = self.app
...@@ -225,7 +225,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -225,7 +225,7 @@ class ElectionEventHandler(MasterEventHandler):
conn.expectMessage() conn.expectMessage()
def handleAskPrimaryMaster(self, conn, packet): def handleAskPrimaryMaster(self, conn, packet):
if not conn.isListeningConnection(): if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
uuid = conn.getUUID() uuid = conn.getUUID()
...@@ -252,7 +252,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -252,7 +252,7 @@ class ElectionEventHandler(MasterEventHandler):
conn.addPacket(p) conn.addPacket(p)
def handleAnnouncePrimaryMaster(self, conn, packet): def handleAnnouncePrimaryMaster(self, conn, packet):
if not conn.isListeningConnection(): if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
uuid = conn.getUUID() uuid = conn.getUUID()
......
...@@ -162,7 +162,7 @@ server: 127.0.0.1:10023 ...@@ -162,7 +162,7 @@ server: 127.0.0.1:10023
uuid = self.getNewUUID() uuid = self.getNewUUID()
# test alien cluster # test alien cluster
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None, conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True}) "isServerConnection" : True})
self.election.handleRequestNodeIdentification(conn, self.election.handleRequestNodeIdentification(conn,
packet=packet, packet=packet,
node_type=node_type, node_type=node_type,
...@@ -284,7 +284,7 @@ server: 127.0.0.1:10023 ...@@ -284,7 +284,7 @@ server: 127.0.0.1:10023
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port) uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
# Without a client connection # Without a client connection
conn = Mock({"getUUID" : uuid, conn = Mock({"getUUID" : uuid,
"isListeningConnection" : True, "isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port),}) "getAddress" : ("127.0.0.1", self.master_port),})
self.assertEqual(len(self.app.unconnected_master_node_set), 1) self.assertEqual(len(self.app.unconnected_master_node_set), 1)
self.assertEqual(len(self.app.negotiating_master_node_set), 0) self.assertEqual(len(self.app.negotiating_master_node_set), 0)
...@@ -499,7 +499,7 @@ server: 127.0.0.1:10023 ...@@ -499,7 +499,7 @@ server: 127.0.0.1:10023
uuid = self.getNewUUID() uuid = self.getNewUUID()
# test alien cluster # test alien cluster
conn = Mock({"addPacket" : None, "abort" : None, conn = Mock({"addPacket" : None, "abort" : None,
"isListeningConnection" : True}) "isServerConnection" : True})
election.handleRequestNodeIdentification(conn, election.handleRequestNodeIdentification(conn,
packet=packet, packet=packet,
node_type=MASTER_NODE_TYPE, node_type=MASTER_NODE_TYPE,
...@@ -510,7 +510,7 @@ server: 127.0.0.1:10023 ...@@ -510,7 +510,7 @@ server: 127.0.0.1:10023
self.checkCalledAbort(conn) self.checkCalledAbort(conn)
# test connection of a storage node # test connection of a storage node
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None, conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True}) "isServerConnection" : True})
election.handleRequestNodeIdentification(conn, election.handleRequestNodeIdentification(conn,
packet=packet, packet=packet,
node_type=STORAGE_NODE_TYPE, node_type=STORAGE_NODE_TYPE,
...@@ -522,7 +522,7 @@ server: 127.0.0.1:10023 ...@@ -522,7 +522,7 @@ server: 127.0.0.1:10023
# known node # known node
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None, conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True}) "isServerConnection" : True})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1) self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
node = self.app.nm.getMasterNodeList()[0] node = self.app.nm.getMasterNodeList()[0]
self.assertEqual(node.getUUID(), None) self.assertEqual(node.getUUID(), None)
...@@ -540,7 +540,7 @@ server: 127.0.0.1:10023 ...@@ -540,7 +540,7 @@ server: 127.0.0.1:10023
self.checkCalledAcceptNodeIdentification(conn) self.checkCalledAcceptNodeIdentification(conn)
# unknown node # unknown node
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None, conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True}) "isServerConnection" : True})
new_uuid = self.getNewUUID() new_uuid = self.getNewUUID()
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1) self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
self.assertEqual(len(self.app.unconnected_master_node_set), 1) self.assertEqual(len(self.app.unconnected_master_node_set), 1)
...@@ -558,7 +558,7 @@ server: 127.0.0.1:10023 ...@@ -558,7 +558,7 @@ server: 127.0.0.1:10023
self.assertEqual(len(self.app.negotiating_master_node_set), 0) self.assertEqual(len(self.app.negotiating_master_node_set), 0)
# broken node # broken node
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None, conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True}) "isServerConnection" : True})
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port+1)) node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port+1))
self.assertEqual(node.getUUID(), new_uuid) self.assertEqual(node.getUUID(), new_uuid)
self.assertEqual(node.getState(), RUNNING_STATE) self.assertEqual(node.getState(), RUNNING_STATE)
...@@ -580,7 +580,7 @@ server: 127.0.0.1:10023 ...@@ -580,7 +580,7 @@ server: 127.0.0.1:10023
packet = Packet(msg_id=2) packet = Packet(msg_id=2)
conn = Mock({"addPacket" : None, conn = Mock({"addPacket" : None,
"getUUID" : uuid, "getUUID" : uuid,
"isListeningConnection" : True, "isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)}) "getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1) self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
election.handleAskPrimaryMaster(conn, packet) election.handleAskPrimaryMaster(conn, packet)
...@@ -595,7 +595,7 @@ server: 127.0.0.1:10023 ...@@ -595,7 +595,7 @@ server: 127.0.0.1:10023
# No uuid # No uuid
conn = Mock({"addPacket" : None, conn = Mock({"addPacket" : None,
"getUUID" : None, "getUUID" : None,
"isListeningConnection" : True, "isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)}) "getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1) self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
election.handleAnnouncePrimaryMaster(conn, packet) election.handleAnnouncePrimaryMaster(conn, packet)
...@@ -603,7 +603,7 @@ server: 127.0.0.1:10023 ...@@ -603,7 +603,7 @@ server: 127.0.0.1:10023
# announce # announce
conn = Mock({"addPacket" : None, conn = Mock({"addPacket" : None,
"getUUID" : uuid, "getUUID" : uuid,
"isListeningConnection" : True, "isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)}) "getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(self.app.primary, None) self.assertEqual(self.app.primary, None)
self.assertEqual(self.app.primary_master_node, None) self.assertEqual(self.app.primary_master_node, None)
...@@ -613,7 +613,7 @@ server: 127.0.0.1:10023 ...@@ -613,7 +613,7 @@ server: 127.0.0.1:10023
# set current as primary, and announce another, must raise # set current as primary, and announce another, must raise
conn = Mock({"addPacket" : None, conn = Mock({"addPacket" : None,
"getUUID" : uuid, "getUUID" : uuid,
"isListeningConnection" : True, "isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)}) "getAddress" : ("127.0.0.1", self.master_port)})
self.app.primary = True self.app.primary = True
self.assertEqual(self.app.primary, True) self.assertEqual(self.app.primary, True)
...@@ -627,7 +627,7 @@ server: 127.0.0.1:10023 ...@@ -627,7 +627,7 @@ server: 127.0.0.1:10023
# No uuid # No uuid
conn = Mock({"addPacket" : None, conn = Mock({"addPacket" : None,
"getUUID" : None, "getUUID" : None,
"isListeningConnection" : True, "isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)}) "getAddress" : ("127.0.0.1", self.master_port)})
self.assertRaises(ElectionFailure, election.handleReelectPrimaryMaster, conn, packet) self.assertRaises(ElectionFailure, election.handleReelectPrimaryMaster, conn, packet)
......
...@@ -65,7 +65,7 @@ class BootstrapEventHandler(StorageEventHandler): ...@@ -65,7 +65,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.connectionAccepted(self, conn, s, addr) StorageEventHandler.connectionAccepted(self, conn, s, addr)
def timeoutExpired(self, conn): def timeoutExpired(self, conn):
if not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
if app.trying_master_node is app.primary_master_node: if app.trying_master_node is app.primary_master_node:
# If a primary master node timeouts, I should not rely on it. # If a primary master node timeouts, I should not rely on it.
...@@ -76,7 +76,7 @@ class BootstrapEventHandler(StorageEventHandler): ...@@ -76,7 +76,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.timeoutExpired(self, conn) StorageEventHandler.timeoutExpired(self, conn)
def connectionClosed(self, conn): def connectionClosed(self, conn):
if not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
if app.trying_master_node is app.primary_master_node: if app.trying_master_node is app.primary_master_node:
# If a primary master node closes, I should not rely on it. # If a primary master node closes, I should not rely on it.
...@@ -87,7 +87,7 @@ class BootstrapEventHandler(StorageEventHandler): ...@@ -87,7 +87,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.connectionClosed(self, conn) StorageEventHandler.connectionClosed(self, conn)
def peerBroken(self, conn): def peerBroken(self, conn):
if not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
if app.trying_master_node is app.primary_master_node: if app.trying_master_node is app.primary_master_node:
# If a primary master node gets broken, I should not rely # If a primary master node gets broken, I should not rely
...@@ -99,7 +99,7 @@ class BootstrapEventHandler(StorageEventHandler): ...@@ -99,7 +99,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.peerBroken(self, conn) StorageEventHandler.peerBroken(self, conn)
def handleNotReady(self, conn, packet, message): def handleNotReady(self, conn, packet, message):
if not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
if app.trying_master_node is not None: if app.trying_master_node is not None:
app.trying_master_node = None app.trying_master_node = None
...@@ -108,7 +108,7 @@ class BootstrapEventHandler(StorageEventHandler): ...@@ -108,7 +108,7 @@ class BootstrapEventHandler(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 not conn.isListeningConnection(): if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app app = self.app
...@@ -155,7 +155,7 @@ class BootstrapEventHandler(StorageEventHandler): ...@@ -155,7 +155,7 @@ class BootstrapEventHandler(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, your_uuid): num_partitions, num_replicas, your_uuid):
if conn.isListeningConnection(): if conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app app = self.app
...@@ -201,7 +201,7 @@ class BootstrapEventHandler(StorageEventHandler): ...@@ -201,7 +201,7 @@ class BootstrapEventHandler(StorageEventHandler):
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list): known_master_list):
if conn.isListeningConnection(): if conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app app = self.app
......
...@@ -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 not conn.isListeningConnection(): if not conn.isServerConnection():
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 not conn.isListeningConnection(): if not conn.isServerConnection():
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 not conn.isListeningConnection(): if not conn.isServerConnection():
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 not conn.isListeningConnection(): if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app app = self.app
...@@ -186,7 +186,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -186,7 +186,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, your_uuid): num_partitions, num_replicas, your_uuid):
if not conn.isListeningConnection(): if not conn.isServerConnection():
raise NotImplementedError raise NotImplementedError
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
...@@ -207,7 +207,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -207,7 +207,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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
nm = app.nm nm = app.nm
pt = app.pt pt = app.pt
...@@ -244,7 +244,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -244,7 +244,7 @@ class OperationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleStopOperation(self, conn, packet): def handleStopOperation(self, conn, packet):
if not conn.isListeningConnection(): if not conn.isServerConnection():
raise OperationFailure('operation stopped') raise OperationFailure('operation stopped')
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
...@@ -274,7 +274,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -274,7 +274,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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
...@@ -291,7 +291,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -291,7 +291,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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
...@@ -455,13 +455,13 @@ class OperationEventHandler(StorageEventHandler): ...@@ -455,13 +455,13 @@ class OperationEventHandler(StorageEventHandler):
pass pass
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
if not conn.isListeningConnection(): if not conn.isServerConnection():
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 not conn.isListeningConnection(): if not conn.isServerConnection():
self.app.replicator.setUnfinishedTIDList(tid_list) self.app.replicator.setUnfinishedTIDList(tid_list)
else: else:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
......
...@@ -185,7 +185,7 @@ server: 127.0.0.1:10020 ...@@ -185,7 +185,7 @@ server: 127.0.0.1:10020
def test_04_timeoutExpired(self): def test_04_timeoutExpired(self):
conn = Mock({ conn = Mock({
"isListeningConnection": False, "isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), "getAddress" : ("127.0.0.1", self.master_port),
}) })
# pmn connection has expired # pmn connection has expired
...@@ -205,7 +205,7 @@ server: 127.0.0.1:10020 ...@@ -205,7 +205,7 @@ server: 127.0.0.1:10020
def test_05_connectionClosed(self): def test_05_connectionClosed(self):
conn = Mock({ conn = Mock({
"isListeningConnection": False, "isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), "getAddress" : ("127.0.0.1", self.master_port),
}) })
# pmn connection is closed # pmn connection is closed
...@@ -225,7 +225,7 @@ server: 127.0.0.1:10020 ...@@ -225,7 +225,7 @@ server: 127.0.0.1:10020
def test_06_peerBroken(self): def test_06_peerBroken(self):
conn = Mock({ conn = Mock({
"isListeningConnection": False, "isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), "getAddress" : ("127.0.0.1", self.master_port),
}) })
# the primary is broken # the primary is broken
...@@ -245,7 +245,7 @@ server: 127.0.0.1:10020 ...@@ -245,7 +245,7 @@ server: 127.0.0.1:10020
def test_07_handleNotReady(self): def test_07_handleNotReady(self):
conn = Mock({ conn = Mock({
"isListeningConnection": False, "isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), "getAddress" : ("127.0.0.1", self.master_port),
}) })
# the primary is not ready # the primary is not ready
...@@ -268,7 +268,7 @@ server: 127.0.0.1:10020 ...@@ -268,7 +268,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification1(self): def test_08_handleRequestNodeIdentification1(self):
# client socket connection -> rejected # client socket connection -> rejected
packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION)
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
self.bootstrap.handleRequestNodeIdentification( self.bootstrap.handleRequestNodeIdentification(
...@@ -285,7 +285,7 @@ server: 127.0.0.1:10020 ...@@ -285,7 +285,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification2(self): def test_08_handleRequestNodeIdentification2(self):
# not a master node -> rejected # not a master node -> rejected
packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION)
conn = Mock({"isListeningConnection": True, conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
self.bootstrap.handleRequestNodeIdentification( self.bootstrap.handleRequestNodeIdentification(
conn=conn, conn=conn,
...@@ -301,7 +301,7 @@ server: 127.0.0.1:10020 ...@@ -301,7 +301,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification3(self): def test_08_handleRequestNodeIdentification3(self):
# bad app name -> rejected # bad app name -> rejected
packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION)
conn = Mock({"isListeningConnection": True, conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
self.bootstrap.handleRequestNodeIdentification( self.bootstrap.handleRequestNodeIdentification(
conn=conn, conn=conn,
...@@ -317,7 +317,7 @@ server: 127.0.0.1:10020 ...@@ -317,7 +317,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification4(self): def test_08_handleRequestNodeIdentification4(self):
# new master # new master
packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION)
conn = Mock({"isListeningConnection": True, conn = Mock({"isServerConnection": True,
"getAddress" : ("192.168.1.1", self.master_port), }) "getAddress" : ("192.168.1.1", self.master_port), })
# master not known # master not known
mn = self.app.nm.getNodeByServer(('192.168.1.1', self.master_port)) mn = self.app.nm.getNodeByServer(('192.168.1.1', self.master_port))
...@@ -347,7 +347,7 @@ server: 127.0.0.1:10020 ...@@ -347,7 +347,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification5(self): def test_08_handleRequestNodeIdentification5(self):
# broken node -> rejected # broken node -> rejected
packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION)
conn = Mock({"isListeningConnection": True, conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
master = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port)) master = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
uuid=self.getNewUUID() uuid=self.getNewUUID()
...@@ -367,7 +367,7 @@ server: 127.0.0.1:10020 ...@@ -367,7 +367,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification6(self): def test_08_handleRequestNodeIdentification6(self):
# master node is already known # master node is already known
packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=REQUEST_NODE_IDENTIFICATION)
conn = Mock({"isListeningConnection": True, conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
# master known # master known
mn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port)) mn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
...@@ -398,7 +398,7 @@ server: 127.0.0.1:10020 ...@@ -398,7 +398,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification1(self): def test_09_handleAcceptNodeIdentification1(self):
# server socket connection -> rejected # server socket connection -> rejected
conn = Mock({"isListeningConnection": True, conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
...@@ -416,7 +416,7 @@ server: 127.0.0.1:10020 ...@@ -416,7 +416,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification2(self): def test_09_handleAcceptNodeIdentification2(self):
# not a master node -> rejected # not a master node -> rejected
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.storage_port), }) "getAddress" : ("127.0.0.1", self.storage_port), })
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
...@@ -439,7 +439,7 @@ server: 127.0.0.1:10020 ...@@ -439,7 +439,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification3(self): def test_09_handleAcceptNodeIdentification3(self):
# bad address -> rejected # bad address -> rejected
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
...@@ -459,7 +459,7 @@ server: 127.0.0.1:10020 ...@@ -459,7 +459,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification4(self): def test_09_handleAcceptNodeIdentification4(self):
# bad number of replicas/partitions # bad number of replicas/partitions
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
...@@ -495,7 +495,7 @@ server: 127.0.0.1:10020 ...@@ -495,7 +495,7 @@ server: 127.0.0.1:10020
uuid, your_uuid = self.getNewUUID(), self.getNewUUID() uuid, your_uuid = self.getNewUUID(), self.getNewUUID()
self.app.num_partitions = None self.app.num_partitions = None
self.app.num_replicas = None self.app.num_replicas = None
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
self.assertNotEquals(self.app.trying_master_node.getUUID(), uuid) self.assertNotEquals(self.app.trying_master_node.getUUID(), uuid)
...@@ -530,7 +530,7 @@ server: 127.0.0.1:10020 ...@@ -530,7 +530,7 @@ server: 127.0.0.1:10020
self.assertEquals(len(conn.mockGetNamedCalls("expectMessage")), 1) self.assertEquals(len(conn.mockGetNamedCalls("expectMessage")), 1)
def test_09_handleAcceptNodeIdentification6(self): def test_09_handleAcceptNodeIdentification6(self):
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION) packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
...@@ -561,7 +561,7 @@ server: 127.0.0.1:10020 ...@@ -561,7 +561,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster01(self): def test_10_handleAnswerPrimaryMaster01(self):
# server connection rejected # server connection rejected
conn = Mock({"isListeningConnection": True, conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER) packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
self.app.trying_master_node = self.trying_master_node self.app.trying_master_node = self.trying_master_node
...@@ -581,7 +581,7 @@ server: 127.0.0.1:10020 ...@@ -581,7 +581,7 @@ server: 127.0.0.1:10020
existing_master = ('127.0.0.1', self.master_port, self.getNewUUID(), ) existing_master = ('127.0.0.1', self.master_port, self.getNewUUID(), )
new_master = ('192.168.0.1', 10001, self.getNewUUID(), ) new_master = ('192.168.0.1', 10001, self.getNewUUID(), )
known_masters = (existing_master, new_master, ) known_masters = (existing_master, new_master, )
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER) packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
self.assertTrue(existing_master[:2] in self.app.nm.server_dict) self.assertTrue(existing_master[:2] in self.app.nm.server_dict)
...@@ -605,7 +605,7 @@ server: 127.0.0.1:10020 ...@@ -605,7 +605,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster03(self): def test_10_handleAnswerPrimaryMaster03(self):
# invalid primary master uuid -> close connection # invalid primary master uuid -> close connection
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER) packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port)) pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
...@@ -625,7 +625,7 @@ server: 127.0.0.1:10020 ...@@ -625,7 +625,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster04(self): def test_10_handleAnswerPrimaryMaster04(self):
# trying_master_node is not pmn -> close connection # trying_master_node is not pmn -> close connection
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER) packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port)) pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
...@@ -647,7 +647,7 @@ server: 127.0.0.1:10020 ...@@ -647,7 +647,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster05(self): def test_10_handleAnswerPrimaryMaster05(self):
# trying_master_node is pmn -> set verification handler # trying_master_node is pmn -> set verification handler
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER) packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port)) pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
...@@ -671,7 +671,7 @@ server: 127.0.0.1:10020 ...@@ -671,7 +671,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster06(self): def test_10_handleAnswerPrimaryMaster06(self):
# primary_uuid not known -> nothing happen # primary_uuid not known -> nothing happen
conn = Mock({"isListeningConnection": False, conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), }) "getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER) packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
self.app.primary_master_node = None self.app.primary_master_node = None
......
This diff is collapsed.
...@@ -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 not conn.isListeningConnection(): if not conn.isServerConnection():
# 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 not conn.isListeningConnection(): if not conn.isServerConnection():
# 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 not conn.isListeningConnection(): if not conn.isServerConnection():
# 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 not conn.isListeningConnection(): if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app app = self.app
...@@ -114,7 +114,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -114,7 +114,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 not conn.isListeningConnection(): if not conn.isServerConnection():
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')
...@@ -125,7 +125,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -125,7 +125,7 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAskLastIDs(self, conn, packet): def handleAskLastIDs(self, conn, packet):
if not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
p = Packet() p = Packet()
oid = app.dm.getLastOID() or INVALID_OID oid = app.dm.getLastOID() or INVALID_OID
...@@ -136,7 +136,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -136,7 +136,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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
row_list = [] row_list = []
try: try:
...@@ -164,7 +164,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -164,7 +164,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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
nm = app.nm nm = app.nm
pt = app.pt pt = app.pt
...@@ -198,7 +198,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -198,7 +198,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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
nm = app.nm nm = app.nm
pt = app.pt pt = app.pt
...@@ -225,19 +225,19 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -225,19 +225,19 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleStartOperation(self, conn, packet): def handleStartOperation(self, conn, packet):
if not conn.isListeningConnection(): if not conn.isServerConnection():
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 not conn.isListeningConnection(): if not conn.isServerConnection():
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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
tid_list = app.dm.getUnfinishedTIDList() tid_list = app.dm.getUnfinishedTIDList()
p = Packet() p = Packet()
...@@ -248,7 +248,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -248,7 +248,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleAskTransactionInformation(self, conn, packet, tid): def handleAskTransactionInformation(self, conn, packet, tid):
app = self.app app = self.app
if not conn.isListeningConnection(): if not conn.isServerConnection():
# 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.
...@@ -265,7 +265,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -265,7 +265,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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
p = Packet() p = Packet()
if app.dm.objectPresent(oid, tid): if app.dm.objectPresent(oid, tid):
...@@ -278,14 +278,14 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -278,14 +278,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 not conn.isListeningConnection(): if not conn.isServerConnection():
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 not conn.isListeningConnection(): if not conn.isServerConnection():
app = self.app app = self.app
app.dm.finishTransaction(tid) app.dm.finishTransaction(tid)
else: else:
......
...@@ -182,7 +182,7 @@ class testConnection(unittest.TestCase): ...@@ -182,7 +182,7 @@ class testConnection(unittest.TestCase):
# test abort # test abort
bc.abort() bc.abort()
self.assertEqual(bc.aborted, True) self.assertEqual(bc.aborted, True)
self.assertRaises(NotImplementedError, bc.isListeningConnection) self.assertRaises(NotImplementedError, bc.isServerConnection)
def test_04_Connection_pending(self): def test_04_Connection_pending(self):
em = Mock() em = Mock()
...@@ -732,7 +732,7 @@ class testConnection(unittest.TestCase): ...@@ -732,7 +732,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413)) addr=("127.0.0.7", 93413))
# check connector created and connection initialize # check connector created and connection initialize
self.assertFalse(bc.connecting) self.assertFalse(bc.connecting)
self.assertFalse(bc.isListeningConnection()) self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None) self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector() conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1) self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
...@@ -760,7 +760,7 @@ class testConnection(unittest.TestCase): ...@@ -760,7 +760,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413)) addr=("127.0.0.7", 93413))
# check connector created and connection initialize # check connector created and connection initialize
self.assertTrue(bc.connecting) self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection()) self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None) self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector() conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1) self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
...@@ -788,7 +788,7 @@ class testConnection(unittest.TestCase): ...@@ -788,7 +788,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413)) addr=("127.0.0.7", 93413))
# check connector created and connection initialize # check connector created and connection initialize
self.assertTrue(bc.connecting) self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection()) self.assertFalse(bc.isServerConnection())
self.assertEqual(bc.getConnector(), None) self.assertEqual(bc.getConnector(), None)
call = conn.mockGetNamedCalls("makeClientConnection")[0] call = conn.mockGetNamedCalls("makeClientConnection")[0]
data = call.getParam(0) data = call.getParam(0)
...@@ -955,7 +955,7 @@ class testConnection(unittest.TestCase): ...@@ -955,7 +955,7 @@ class testConnection(unittest.TestCase):
# test abort # test abort
bc.abort() bc.abort()
self.assertEqual(bc.aborted, True) self.assertEqual(bc.aborted, True)
self.assertTrue(bc.isListeningConnection()) self.assertTrue(bc.isServerConnection())
def test_15_MTClientConnection(self): def test_15_MTClientConnection(self):
...@@ -968,7 +968,7 @@ class testConnection(unittest.TestCase): ...@@ -968,7 +968,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413)) addr=("127.0.0.7", 93413))
# check connector created and connection initialize # check connector created and connection initialize
self.assertFalse(bc.connecting) self.assertFalse(bc.connecting)
self.assertFalse(bc.isListeningConnection()) self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None) self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector() conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1) self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
...@@ -995,7 +995,7 @@ class testConnection(unittest.TestCase): ...@@ -995,7 +995,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413)) addr=("127.0.0.7", 93413))
# check connector created and connection initialize # check connector created and connection initialize
self.assertTrue(bc.connecting) self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection()) self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None) self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector() conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1) self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
...@@ -1023,7 +1023,7 @@ class testConnection(unittest.TestCase): ...@@ -1023,7 +1023,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413)) addr=("127.0.0.7", 93413))
# check connector created and connection initialize # check connector created and connection initialize
self.assertTrue(bc.connecting) self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection()) self.assertFalse(bc.isServerConnection())
self.assertEqual(bc.getConnector(), None) self.assertEqual(bc.getConnector(), None)
call = conn.mockGetNamedCalls("makeClientConnection")[0] call = conn.mockGetNamedCalls("makeClientConnection")[0]
data = call.getParam(0) data = call.getParam(0)
...@@ -1075,7 +1075,7 @@ class testConnection(unittest.TestCase): ...@@ -1075,7 +1075,7 @@ class testConnection(unittest.TestCase):
# test abort # test abort
bc.abort() bc.abort()
self.assertEqual(bc.aborted, True) self.assertEqual(bc.aborted, True)
self.assertTrue(bc.isListeningConnection()) self.assertTrue(bc.isServerConnection())
# XXX check locking ??? # XXX check locking ???
......
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