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):
self.event_dict[msg_id] = event
self.em.addIdleEvent(event)
def isListeningConnection(self):
def isServerConnection(self):
raise NotImplementedError
class ClientConnection(Connection):
......@@ -358,12 +358,12 @@ class ClientConnection(Connection):
else:
Connection.writable(self)
def isListeningConnection(self):
def isServerConnection(self):
return False
class ServerConnection(Connection):
"""A connection from a remote node to this node."""
def isListeningConnection(self):
def isServerConnection(self):
return True
class MTClientConnection(ClientConnection):
......
......@@ -59,12 +59,12 @@ class ElectionEventHandler(MasterEventHandler):
MasterEventHandler.connectionFailed(self, conn)
def connectionClosed(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.connectionFailed(conn)
MasterEventHandler.connectionClosed(self, conn)
def timeoutExpired(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.connectionFailed(conn)
MasterEventHandler.timeoutExpired(self, conn)
......@@ -72,7 +72,7 @@ class ElectionEventHandler(MasterEventHandler):
app = self.app
addr = conn.getAddress()
node = app.nm.getNodeByServer(addr)
if not conn.isListeningConnection():
if not conn.isServerConnection():
if node is not None:
node.setState(DOWN_STATE)
app.negotiating_master_node_set.discard(addr)
......@@ -82,7 +82,7 @@ class ElectionEventHandler(MasterEventHandler):
MasterEventHandler.peerBroken(self, conn)
def packetReceived(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
node = self.app.nm.getNodeByServer(conn.getAddress())
if node.getState() != BROKEN_STATE:
node.setState(RUNNING_STATE)
......@@ -91,7 +91,7 @@ class ElectionEventHandler(MasterEventHandler):
def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, num_partitions,
num_replicas, your_uuid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
node = app.nm.getNodeByServer(conn.getAddress())
if node_type != MASTER_NODE_TYPE:
......@@ -127,7 +127,7 @@ class ElectionEventHandler(MasterEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
# Register new master nodes.
for ip_address, port, uuid in known_master_list:
......@@ -176,7 +176,7 @@ class ElectionEventHandler(MasterEventHandler):
def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, name):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
app = self.app
......@@ -225,7 +225,7 @@ class ElectionEventHandler(MasterEventHandler):
conn.expectMessage()
def handleAskPrimaryMaster(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
uuid = conn.getUUID()
......@@ -252,7 +252,7 @@ class ElectionEventHandler(MasterEventHandler):
conn.addPacket(p)
def handleAnnouncePrimaryMaster(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
uuid = conn.getUUID()
......
......@@ -162,7 +162,7 @@ server: 127.0.0.1:10023
uuid = self.getNewUUID()
# test alien cluster
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True})
"isServerConnection" : True})
self.election.handleRequestNodeIdentification(conn,
packet=packet,
node_type=node_type,
......@@ -284,7 +284,7 @@ server: 127.0.0.1:10023
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
# Without a client connection
conn = Mock({"getUUID" : uuid,
"isListeningConnection" : True,
"isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port),})
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
......@@ -499,7 +499,7 @@ server: 127.0.0.1:10023
uuid = self.getNewUUID()
# test alien cluster
conn = Mock({"addPacket" : None, "abort" : None,
"isListeningConnection" : True})
"isServerConnection" : True})
election.handleRequestNodeIdentification(conn,
packet=packet,
node_type=MASTER_NODE_TYPE,
......@@ -510,7 +510,7 @@ server: 127.0.0.1:10023
self.checkCalledAbort(conn)
# test connection of a storage node
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True})
"isServerConnection" : True})
election.handleRequestNodeIdentification(conn,
packet=packet,
node_type=STORAGE_NODE_TYPE,
......@@ -522,7 +522,7 @@ server: 127.0.0.1:10023
# known node
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True})
"isServerConnection" : True})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
node = self.app.nm.getMasterNodeList()[0]
self.assertEqual(node.getUUID(), None)
......@@ -540,7 +540,7 @@ server: 127.0.0.1:10023
self.checkCalledAcceptNodeIdentification(conn)
# unknown node
conn = Mock({"addPacket" : None, "abort" : None, "expectMessage" : None,
"isListeningConnection" : True})
"isServerConnection" : True})
new_uuid = self.getNewUUID()
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
......@@ -558,7 +558,7 @@ server: 127.0.0.1:10023
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
# broken node
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))
self.assertEqual(node.getUUID(), new_uuid)
self.assertEqual(node.getState(), RUNNING_STATE)
......@@ -580,7 +580,7 @@ server: 127.0.0.1:10023
packet = Packet(msg_id=2)
conn = Mock({"addPacket" : None,
"getUUID" : uuid,
"isListeningConnection" : True,
"isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
election.handleAskPrimaryMaster(conn, packet)
......@@ -595,7 +595,7 @@ server: 127.0.0.1:10023
# No uuid
conn = Mock({"addPacket" : None,
"getUUID" : None,
"isListeningConnection" : True,
"isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
election.handleAnnouncePrimaryMaster(conn, packet)
......@@ -603,7 +603,7 @@ server: 127.0.0.1:10023
# announce
conn = Mock({"addPacket" : None,
"getUUID" : uuid,
"isListeningConnection" : True,
"isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(self.app.primary, None)
self.assertEqual(self.app.primary_master_node, None)
......@@ -613,7 +613,7 @@ server: 127.0.0.1:10023
# set current as primary, and announce another, must raise
conn = Mock({"addPacket" : None,
"getUUID" : uuid,
"isListeningConnection" : True,
"isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.app.primary = True
self.assertEqual(self.app.primary, True)
......@@ -627,7 +627,7 @@ server: 127.0.0.1:10023
# No uuid
conn = Mock({"addPacket" : None,
"getUUID" : None,
"isListeningConnection" : True,
"isServerConnection" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertRaises(ElectionFailure, election.handleReelectPrimaryMaster, conn, packet)
......
......@@ -65,7 +65,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.connectionAccepted(self, conn, s, addr)
def timeoutExpired(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
if app.trying_master_node is app.primary_master_node:
# If a primary master node timeouts, I should not rely on it.
......@@ -76,7 +76,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.timeoutExpired(self, conn)
def connectionClosed(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
if app.trying_master_node is app.primary_master_node:
# If a primary master node closes, I should not rely on it.
......@@ -87,7 +87,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.connectionClosed(self, conn)
def peerBroken(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
if app.trying_master_node is app.primary_master_node:
# If a primary master node gets broken, I should not rely
......@@ -99,7 +99,7 @@ class BootstrapEventHandler(StorageEventHandler):
StorageEventHandler.peerBroken(self, conn)
def handleNotReady(self, conn, packet, message):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
if app.trying_master_node is not None:
app.trying_master_node = None
......@@ -108,7 +108,7 @@ class BootstrapEventHandler(StorageEventHandler):
def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, name):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
app = self.app
......@@ -155,7 +155,7 @@ class BootstrapEventHandler(StorageEventHandler):
def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port,
num_partitions, num_replicas, your_uuid):
if conn.isListeningConnection():
if conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
app = self.app
......@@ -201,7 +201,7 @@ class BootstrapEventHandler(StorageEventHandler):
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list):
if conn.isListeningConnection():
if conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
app = self.app
......
......@@ -89,7 +89,7 @@ class OperationEventHandler(StorageEventHandler):
app.executeQueuedEvents()
def timeoutExpired(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
if conn.getUUID() == self.app.primary_master_node.getUUID():
# If a primary master node timeouts, I cannot continue.
logging.critical('the primary master node times out')
......@@ -103,7 +103,7 @@ class OperationEventHandler(StorageEventHandler):
StorageEventHandler.timeoutExpired(self, conn)
def connectionClosed(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
if conn.getUUID() == self.app.primary_master_node.getUUID():
# If a primary master node closes, I cannot continue.
logging.critical('the primary master node is dead')
......@@ -117,7 +117,7 @@ class OperationEventHandler(StorageEventHandler):
StorageEventHandler.connectionClosed(self, conn)
def peerBroken(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
if conn.getUUID() == self.app.primary_master_node.getUUID():
# If a primary master node gets broken, I cannot continue.
logging.critical('the primary master node is broken')
......@@ -132,7 +132,7 @@ class OperationEventHandler(StorageEventHandler):
def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, name):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
app = self.app
......@@ -186,7 +186,7 @@ class OperationEventHandler(StorageEventHandler):
def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port,
num_partitions, num_replicas, your_uuid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
raise NotImplementedError
else:
self.handleUnexpectedPacket(conn, packet)
......@@ -207,7 +207,7 @@ class OperationEventHandler(StorageEventHandler):
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that
the information is only about changes from the previous."""
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
nm = app.nm
pt = app.pt
......@@ -244,7 +244,7 @@ class OperationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleStopOperation(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
raise OperationFailure('operation stopped')
else:
self.handleUnexpectedPacket(conn, packet)
......@@ -274,7 +274,7 @@ class OperationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleLockInformation(self, conn, packet, tid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
try:
t = app.transaction_dict[tid]
......@@ -291,7 +291,7 @@ class OperationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleUnlockInformation(self, conn, packet, tid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
try:
t = app.transaction_dict[tid]
......@@ -455,13 +455,13 @@ class OperationEventHandler(StorageEventHandler):
pass
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.app.replicator.setCriticalTID(packet, ltid)
else:
self.handleUnexpectedPacket(conn, packet)
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.app.replicator.setUnfinishedTIDList(tid_list)
else:
self.handleUnexpectedPacket(conn, packet)
......
......@@ -185,7 +185,7 @@ server: 127.0.0.1:10020
def test_04_timeoutExpired(self):
conn = Mock({
"isListeningConnection": False,
"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
# pmn connection has expired
......@@ -205,7 +205,7 @@ server: 127.0.0.1:10020
def test_05_connectionClosed(self):
conn = Mock({
"isListeningConnection": False,
"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
# pmn connection is closed
......@@ -225,7 +225,7 @@ server: 127.0.0.1:10020
def test_06_peerBroken(self):
conn = Mock({
"isListeningConnection": False,
"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
# the primary is broken
......@@ -245,7 +245,7 @@ server: 127.0.0.1:10020
def test_07_handleNotReady(self):
conn = Mock({
"isListeningConnection": False,
"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
# the primary is not ready
......@@ -268,7 +268,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification1(self):
# client socket connection -> rejected
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), })
self.app.trying_master_node = self.trying_master_node
self.bootstrap.handleRequestNodeIdentification(
......@@ -285,7 +285,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification2(self):
# not a master node -> rejected
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), })
self.bootstrap.handleRequestNodeIdentification(
conn=conn,
......@@ -301,7 +301,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification3(self):
# bad app name -> rejected
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), })
self.bootstrap.handleRequestNodeIdentification(
conn=conn,
......@@ -317,7 +317,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification4(self):
# new master
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), })
# master not known
mn = self.app.nm.getNodeByServer(('192.168.1.1', self.master_port))
......@@ -347,7 +347,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification5(self):
# broken node -> rejected
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), })
master = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
uuid=self.getNewUUID()
......@@ -367,7 +367,7 @@ server: 127.0.0.1:10020
def test_08_handleRequestNodeIdentification6(self):
# master node is already known
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), })
# master known
mn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
......@@ -398,7 +398,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification1(self):
# server socket connection -> rejected
conn = Mock({"isListeningConnection": True,
conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
self.app.trying_master_node = self.trying_master_node
......@@ -416,7 +416,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification2(self):
# not a master node -> rejected
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.storage_port), })
self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
......@@ -439,7 +439,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification3(self):
# bad address -> rejected
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
......@@ -459,7 +459,7 @@ server: 127.0.0.1:10020
def test_09_handleAcceptNodeIdentification4(self):
# bad number of replicas/partitions
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
......@@ -495,7 +495,7 @@ server: 127.0.0.1:10020
uuid, your_uuid = self.getNewUUID(), self.getNewUUID()
self.app.num_partitions = None
self.app.num_replicas = None
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node
self.assertNotEquals(self.app.trying_master_node.getUUID(), uuid)
......@@ -530,7 +530,7 @@ server: 127.0.0.1:10020
self.assertEquals(len(conn.mockGetNamedCalls("expectMessage")), 1)
def test_09_handleAcceptNodeIdentification6(self):
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_id=1, msg_type=ACCEPT_NODE_IDENTIFICATION)
......@@ -561,7 +561,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster01(self):
# server connection rejected
conn = Mock({"isListeningConnection": True,
conn = Mock({"isServerConnection": True,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
self.app.trying_master_node = self.trying_master_node
......@@ -581,7 +581,7 @@ server: 127.0.0.1:10020
existing_master = ('127.0.0.1', self.master_port, self.getNewUUID(), )
new_master = ('192.168.0.1', 10001, self.getNewUUID(), )
known_masters = (existing_master, new_master, )
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
self.assertTrue(existing_master[:2] in self.app.nm.server_dict)
......@@ -605,7 +605,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster03(self):
# invalid primary master uuid -> close connection
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
......@@ -625,7 +625,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster04(self):
# trying_master_node is not pmn -> close connection
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
......@@ -647,7 +647,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster05(self):
# trying_master_node is pmn -> set verification handler
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
......@@ -671,7 +671,7 @@ server: 127.0.0.1:10020
def test_10_handleAnswerPrimaryMaster06(self):
# primary_uuid not known -> nothing happen
conn = Mock({"isListeningConnection": False,
conn = Mock({"isServerConnection": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_id=1, msg_type=ANSWER_PRIMARY_MASTER)
self.app.primary_master_node = None
......
This diff is collapsed.
......@@ -37,7 +37,7 @@ class VerificationEventHandler(StorageEventHandler):
StorageEventHandler.connectionAccepted(self, conn, s, addr)
def timeoutExpired(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
# If a primary master node timeouts, I cannot continue.
logging.critical('the primary master node times out')
raise PrimaryFailure('the primary master node times out')
......@@ -45,7 +45,7 @@ class VerificationEventHandler(StorageEventHandler):
StorageEventHandler.timeoutExpired(self, conn)
def connectionClosed(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
# If a primary master node closes, I cannot continue.
logging.critical('the primary master node is dead')
raise PrimaryFailure('the primary master node is dead')
......@@ -53,7 +53,7 @@ class VerificationEventHandler(StorageEventHandler):
StorageEventHandler.connectionClosed(self, conn)
def peerBroken(self, conn):
if not conn.isListeningConnection():
if not conn.isServerConnection():
# If a primary master node gets broken, I cannot continue.
logging.critical('the primary master node is broken')
raise PrimaryFailure('the primary master node is broken')
......@@ -62,7 +62,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, name):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.handleUnexpectedPacket(conn, packet)
else:
app = self.app
......@@ -114,7 +114,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
if app.primary_master_node.getUUID() != primary_uuid:
raise PrimaryFailure('the primary master node seems to have changed')
......@@ -125,7 +125,7 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleAskLastIDs(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
p = Packet()
oid = app.dm.getLastOID() or INVALID_OID
......@@ -136,7 +136,7 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleAskPartitionTable(self, conn, packet, offset_list):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
row_list = []
try:
......@@ -164,7 +164,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleSendPartitionTable(self, conn, packet, ptid, row_list):
"""A primary master node sends this packet to synchronize a partition
table. Note that the message can be split into multiple packets."""
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
nm = app.nm
pt = app.pt
......@@ -198,7 +198,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that
the information is only about changes from the previous."""
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
nm = app.nm
pt = app.pt
......@@ -225,19 +225,19 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleStartOperation(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
self.app.operational = True
else:
self.handleUnexpectedPacket(conn, packet)
def handleStopOperation(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
raise OperationFailure('operation stopped')
else:
self.handleUnexpectedPacket(conn, packet)
def handleAskUnfinishedTransactions(self, conn, packet):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
tid_list = app.dm.getUnfinishedTIDList()
p = Packet()
......@@ -248,7 +248,7 @@ class VerificationEventHandler(StorageEventHandler):
def handleAskTransactionInformation(self, conn, packet, tid):
app = self.app
if not conn.isListeningConnection():
if not conn.isServerConnection():
# If this is from a primary master node, assume that it wants
# to obtain information about the transaction, even if it has
# not been finished.
......@@ -265,7 +265,7 @@ class VerificationEventHandler(StorageEventHandler):
conn.addPacket(p)
def handleAskObjectPresent(self, conn, packet, oid, tid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
p = Packet()
if app.dm.objectPresent(oid, tid):
......@@ -278,14 +278,14 @@ class VerificationEventHandler(StorageEventHandler):
self.handleUnexpectedPacket(conn, packet)
def handleDeleteTransaction(self, conn, packet, tid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
app.dm.deleteTransaction(tid, all = True)
else:
self.handleUnexpectedPacket(conn, packet)
def handleCommitTransaction(self, conn, packet, tid):
if not conn.isListeningConnection():
if not conn.isServerConnection():
app = self.app
app.dm.finishTransaction(tid)
else:
......
......@@ -182,7 +182,7 @@ class testConnection(unittest.TestCase):
# test abort
bc.abort()
self.assertEqual(bc.aborted, True)
self.assertRaises(NotImplementedError, bc.isListeningConnection)
self.assertRaises(NotImplementedError, bc.isServerConnection)
def test_04_Connection_pending(self):
em = Mock()
......@@ -732,7 +732,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413))
# check connector created and connection initialize
self.assertFalse(bc.connecting)
self.assertFalse(bc.isListeningConnection())
self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -760,7 +760,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413))
# check connector created and connection initialize
self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection())
self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -788,7 +788,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413))
# check connector created and connection initialize
self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection())
self.assertFalse(bc.isServerConnection())
self.assertEqual(bc.getConnector(), None)
call = conn.mockGetNamedCalls("makeClientConnection")[0]
data = call.getParam(0)
......@@ -955,7 +955,7 @@ class testConnection(unittest.TestCase):
# test abort
bc.abort()
self.assertEqual(bc.aborted, True)
self.assertTrue(bc.isListeningConnection())
self.assertTrue(bc.isServerConnection())
def test_15_MTClientConnection(self):
......@@ -968,7 +968,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413))
# check connector created and connection initialize
self.assertFalse(bc.connecting)
self.assertFalse(bc.isListeningConnection())
self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -995,7 +995,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413))
# check connector created and connection initialize
self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection())
self.assertFalse(bc.isServerConnection())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -1023,7 +1023,7 @@ class testConnection(unittest.TestCase):
addr=("127.0.0.7", 93413))
# check connector created and connection initialize
self.assertTrue(bc.connecting)
self.assertFalse(bc.isListeningConnection())
self.assertFalse(bc.isServerConnection())
self.assertEqual(bc.getConnector(), None)
call = conn.mockGetNamedCalls("makeClientConnection")[0]
data = call.getParam(0)
......@@ -1075,7 +1075,7 @@ class testConnection(unittest.TestCase):
# test abort
bc.abort()
self.assertEqual(bc.aborted, True)
self.assertTrue(bc.isListeningConnection())
self.assertTrue(bc.isServerConnection())
# 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