Commit 57e5e7f8 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Replace calls of 'getNodeByXXX' with 'getByXXX' because 'Node' is implied by the

node manager.


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1318 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 86819c9c
......@@ -61,7 +61,7 @@ class AdminEventHandler(EventHandler):
def handleSetNodeState(self, conn, packet, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s" %(dump(uuid), state))
node = self.app.nm.getNodeByUUID(uuid)
node = self.app.nm.getByUUID(uuid)
if node is None:
raise protocol.ProtocolError('invalid uuid')
if node.getState() == state and modify_partition_table is False:
......@@ -165,13 +165,13 @@ class MasterEventHandler(EventHandler):
app = self.app
nm = app.nm
pt = app.pt
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
if app.ptid != ptid:
app.ptid = ptid
pt.clear()
for offset, row in row_list:
for uuid, state in row:
node = nm.getNodeByUUID(uuid)
node = nm.getByUUID(uuid)
if node is None:
nm.createStorage(
uuid=uuid,
......
......@@ -62,12 +62,12 @@ class BootstrapManager(EventHandler):
# Register new master nodes.
for address, uuid in known_master_list:
node = nm.getNodeByServer(address)
node = nm.getByAddress(address)
if node is None:
nm.createMaster(server=address)
node.setUUID(uuid)
self.primary = nm.getNodeByUUID(primary_uuid)
self.primary = nm.getByUUID(primary_uuid)
if self.primary is None or self.current is not self.primary:
# three cases here:
# - something goes wrong (unknown UUID)
......@@ -116,7 +116,7 @@ class BootstrapManager(EventHandler):
conn = ClientConnection(em, self, addr, connector_handler)
# still processing
em.poll(1)
node = nm.getNodeByUUID(conn.getUUID())
node = nm.getByUUID(conn.getUUID())
return (node, conn, self.uuid, self.num_partitions, self.num_replicas)
......
......@@ -315,7 +315,7 @@ class Application(object):
# Guess the handler to use based on the type of node on the
# connection
if handler is None:
node = self.nm.getNodeByServer(conn.getAddress())
node = self.nm.getByAddress(conn.getAddress())
if node is None:
raise ValueError, 'Expecting an answer from a node ' \
'which type is not known... Is this right ?'
......
......@@ -33,7 +33,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid):
app = self.app
node = app.nm.getNodeByServer(conn.getAddress())
node = app.nm.getByAddress(conn.getAddress())
# this must be a master node
if node_type != protocol.MASTER_NODE_TYPE:
conn.close()
......@@ -62,9 +62,9 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
app = self.app
# Register new master nodes.
for address, uuid in known_master_list:
n = app.nm.getNodeByServer(address)
n = app.nm.getByAddress(address)
if n is None:
app.nm.createMaster(server=address)
app.nm.createMaster(address)
if uuid is not None:
# If I don't know the UUID yet, believe what the peer
# told me at the moment.
......@@ -72,7 +72,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
n.setUUID(uuid)
if primary_uuid is not None:
primary_node = app.nm.getNodeByUUID(primary_uuid)
primary_node = app.nm.getByUUID(primary_uuid)
if primary_node is None:
# I don't know such a node. Probably this information
# is old. So ignore it.
......
......@@ -25,7 +25,7 @@ class StorageEventHandler(BaseHandler):
def _dealWithStorageFailure(self, conn):
app = self.app
node = app.nm.getNodeByServer(conn.getAddress())
node = app.nm.getByAddress(conn.getAddress())
assert node is not None
# Remove from pool connection
app.cp.removeConnection(node)
......@@ -55,7 +55,7 @@ class StorageBootstrapHandler(AnswerBaseHandler):
def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid):
app = self.app
node = app.nm.getNodeByServer(conn.getAddress())
node = app.nm.getByAddress(conn.getAddress())
# It can be eiter a master node or a storage node
if node_type != protocol.STORAGE_NODE_TYPE:
conn.close()
......
......@@ -297,7 +297,7 @@ class Application(object):
# Only to master nodes and storage nodes.
for c in self.em.getConnectionList():
if c.getUUID() is not None:
n = self.nm.getNodeByUUID(c.getUUID())
n = self.nm.getByUUID(c.getUUID())
if n.isMaster() or n.isStorage() or n.isAdmin():
node_list = [(node_type, address, uuid, state)]
c.notify(protocol.notifyNodeInformation(node_list))
......@@ -315,7 +315,7 @@ class Application(object):
logging.debug('broadcastPartitionChanges')
self.pt.log()
for c in self.em.getConnectionList():
n = self.nm.getNodeByUUID(c.getUUID())
n = self.nm.getByUUID(c.getUUID())
if n is None:
continue
if n.isClient() or n.isStorage() or n.isAdmin():
......@@ -369,7 +369,7 @@ class Application(object):
logging.debug('Broadcast last OID to storages : %s' % dump(oid))
packet = protocol.notifyLastOID(oid)
for conn in self.em.getConnectionList():
node = self.nm.getNodeByUUID(conn.getUUID())
node = self.nm.getByUUID(conn.getUUID())
if node is not None and node.isStorage():
conn.notify(packet)
......@@ -525,7 +525,7 @@ class Application(object):
for conn in em.getConnectionList():
uuid = conn.getUUID()
if uuid is not None:
node = nm.getNodeByUUID(uuid)
node = nm.getByUUID(uuid)
if node.isStorage():
self.asking_uuid_dict[uuid] = False
conn.ask(protocol.askUnfinishedTransactions())
......@@ -547,7 +547,7 @@ class Application(object):
for conn in em.getConnectionList():
uuid = conn.getUUID()
if uuid is not None:
node = nm.getNodeByUUID(uuid)
node = nm.getByUUID(uuid)
if node.isStorage():
conn.notify(protocol.deleteTransaction(tid))
else:
......@@ -592,7 +592,7 @@ class Application(object):
# and client nodes. Abort connections to client nodes.
logging.critical('No longer operational, so stopping the service')
for conn in em.getConnectionList():
node = nm.getNodeByUUID(conn.getUUID())
node = nm.getByUUID(conn.getUUID())
if node is not None and (node.isStorage() or node.isClient()):
conn.notify(protocol.stopOperation())
if node.isClient():
......@@ -616,7 +616,7 @@ class Application(object):
for conn in em.getConnectionList():
conn_uuid = conn.getUUID()
if conn_uuid is not None:
node = nm.getNodeByUUID(conn_uuid)
node = nm.getByUUID(conn_uuid)
assert node is not None
assert node.isMaster()
conn.setHandler(handler)
......@@ -683,7 +683,7 @@ class Application(object):
# change handlers
notification_packet = protocol.notifyClusterInformation(state)
for conn in em.getConnectionList():
node = nm.getNodeByUUID(conn.getUUID())
node = nm.getByUUID(conn.getUUID())
if conn.isListening() or node is None:
# not identified or listening, keep the identification handler
continue
......@@ -723,7 +723,7 @@ class Application(object):
return prefix + uuid
def isValidUUID(self, uuid, addr):
node = self.nm.getNodeByUUID(uuid)
node = self.nm.getByUUID(uuid)
if node is not None and node.getServer() is not None and node.getServer() != addr:
return False
return uuid != self.uuid and uuid is not None
......@@ -748,7 +748,7 @@ class Application(object):
# no more transaction, ask clients to shutdown
logging.info("asking all clients to shutdown")
for c in self.em.getConnectionList():
node = self.nm.getNodeByUUID(c.getUUID())
node = self.nm.getByUUID(c.getUUID())
if node.isClient():
node_list = [(node.getType(), node.getServer(),
node.getUUID(), DOWN_STATE)]
......@@ -756,7 +756,7 @@ class Application(object):
# then ask storages and master nodes to shutdown
logging.info("asking all remaining nodes to shutdown")
for c in self.em.getConnectionList():
node = self.nm.getNodeByUUID(c.getUUID())
node = self.nm.getByUUID(c.getUUID())
if node.isStorage() or node.isMaster():
node_list = [(node.getType(), node.getServer(),
node.getUUID(), DOWN_STATE)]
......
......@@ -81,7 +81,7 @@ class BaseServiceHandler(MasterHandler):
pass
def connectionLost(self, conn, new_state):
node = self.app.nm.getNodeByUUID(conn.getUUID())
node = self.app.nm.getByUUID(conn.getUUID())
assert node is not None
if new_state != protocol.BROKEN_STATE:
new_state = DISCONNECTED_STATE_DICT.get(node.getType(), protocol.DOWN_STATE)
......
......@@ -27,7 +27,7 @@ class AdministrationHandler(MasterHandler):
"""This class deals with messages from the admin node only"""
def connectionLost(self, conn, new_state):
node = self.app.nm.getNodeByUUID(conn.getUUID())
node = self.app.nm.getByUUID(conn.getUUID())
self.app.nm.remove(node)
def handleAskPrimaryMaster(self, conn, packet):
......@@ -46,7 +46,7 @@ class AdministrationHandler(MasterHandler):
def handleSetNodeState(self, conn, packet, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s : %s" % (dump(uuid), state, modify_partition_table))
app = self.app
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
if node is None:
raise protocol.ProtocolError('unknown node')
......@@ -116,7 +116,7 @@ class AdministrationHandler(MasterHandler):
logging.info('Adding nodes %s' % uuids)
# switch nodes to running state
for uuid in uuid_set:
node = nm.getNodeByUUID(uuid)
node = nm.getByUUID(uuid)
new_cells = pt.addNode(node)
cell_list.extend(new_cells)
node.setState(RUNNING_STATE)
......
......@@ -42,7 +42,7 @@ class ElectionHandler(MasterHandler):
# This is self.
continue
else:
node = app.nm.getNodeByServer(addr)
node = app.nm.getByAddress(addr)
# The master must be known
assert node is not None
......@@ -67,7 +67,7 @@ class ElectionHandler(MasterHandler):
class ClientElectionHandler(ElectionHandler):
def packetReceived(self, conn, packet):
node = self.app.nm.getNodeByServer(conn.getAddress())
node = self.app.nm.getByAddress(conn.getAddress())
if node.getState() != BROKEN_STATE:
node.setState(RUNNING_STATE)
MasterHandler.packetReceived(self, conn, packet)
......@@ -95,7 +95,7 @@ class ClientElectionHandler(ElectionHandler):
app = self.app
addr = conn.getAddress()
app.negotiating_master_node_set.discard(addr)
node = app.nm.getNodeByServer(addr)
node = app.nm.getByAddress(addr)
if node.getState() == RUNNING_STATE:
app.unconnected_master_node_set.add(addr)
node.setState(TEMPORARILY_DOWN_STATE)
......@@ -106,7 +106,7 @@ class ClientElectionHandler(ElectionHandler):
def peerBroken(self, conn):
app = self.app
addr = conn.getAddress()
node = app.nm.getNodeByServer(addr)
node = app.nm.getByAddress(addr)
if node is not None:
node.setState(DOWN_STATE)
app.negotiating_master_node_set.discard(addr)
......@@ -116,7 +116,7 @@ class ClientElectionHandler(ElectionHandler):
uuid, address, num_partitions,
num_replicas, your_uuid):
app = self.app
node = app.nm.getNodeByServer(conn.getAddress())
node = app.nm.getByAddress(conn.getAddress())
if node_type != MASTER_NODE_TYPE:
# The peer is not a master node!
logging.error('%s:%d is not a master node', *address)
......@@ -164,7 +164,7 @@ class ClientElectionHandler(ElectionHandler):
# This is self.
continue
else:
n = app.nm.getNodeByServer(address)
n = app.nm.getByAddress(address)
# master node must be known
assert n is not None
......@@ -181,7 +181,7 @@ class ClientElectionHandler(ElectionHandler):
# There are multiple primary master nodes. This is
# dangerous.
raise ElectionFailure, 'multiple primary master nodes'
primary_node = app.nm.getNodeByUUID(primary_uuid)
primary_node = app.nm.getByUUID(primary_uuid)
if primary_node is None:
# I don't know such a node. Probably this information
# is old. So ignore it.
......@@ -212,7 +212,7 @@ class ServerElectionHandler(ElectionHandler):
def peerBroken(self, conn):
app = self.app
addr = conn.getAddress()
node = app.nm.getNodeByServer(addr)
node = app.nm.getByAddress(addr)
if node is not None and node.getUUID() is not None:
node.setState(BROKEN_STATE)
MasterHandler.peerBroken(self, conn)
......@@ -232,7 +232,7 @@ class ServerElectionHandler(ElectionHandler):
if node_type != MASTER_NODE_TYPE:
logging.info('reject a connection from a non-master')
raise protocol.NotReadyError
node = app.nm.getNodeByServer(address)
node = app.nm.getByAddress(address)
if node is None:
logging.error('unknown master node: %s' % (address, ))
raise protocol.ProtocolError('unknown master node')
......@@ -260,7 +260,7 @@ class ServerElectionHandler(ElectionHandler):
if app.primary:
# I am also the primary... So restart the election.
raise ElectionFailure, 'another primary arises'
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
app.primary = False
app.primary_master_node = node
logging.info('%s is the primary', node)
......
......@@ -31,8 +31,8 @@ class IdentificationHandler(MasterHandler):
self.checkClusterName(name)
app, nm = self.app, self.app.nm
node_by_uuid = nm.getNodeByUUID(uuid)
node_by_addr = nm.getNodeByServer(address)
node_by_uuid = nm.getByUUID(uuid)
node_by_addr = nm.getByAddress(address)
# handle conflicts and broken nodes
node = node_by_uuid or node_by_addr
......
......@@ -53,7 +53,7 @@ class RecoveryHandler(MasterHandler):
# load unknown storage nodes
for offset, row in row_list:
for uuid, state in row:
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
if node is None:
app.nm.createStorage(
uuid=uuid,
......
......@@ -27,7 +27,7 @@ class SecondaryMasterHandler(MasterHandler):
""" Handler used by primary to handle secondary masters"""
def connectionLost(self, conn, new_state):
node = self.app.nm.getNodeByUUID(conn.getUUID())
node = self.app.nm.getByUUID(conn.getUUID())
assert node is not None
node.setState(DOWN_STATE)
self.app.broadcastNodeInformation(node)
......@@ -50,7 +50,7 @@ class PrimaryMasterHandler(MasterHandler):
def packetReceived(self, conn, packet):
if not conn.isServer():
node = self.app.nm.getNodeByServer(conn.getAddress())
node = self.app.nm.getByAddress(conn.getAddress())
if node.getState() != BROKEN_STATE:
node.setState(RUNNING_STATE)
MasterHandler.packetReceived(self, conn, packet)
......@@ -77,7 +77,7 @@ class PrimaryMasterHandler(MasterHandler):
# This is self.
continue
else:
n = app.nm.getNodeByServer(addr)
n = app.nm.getByAddress(addr)
# master node must be known
assert n is not None
......@@ -91,7 +91,7 @@ class PrimaryMasterHandler(MasterHandler):
uuid, address, num_partitions,
num_replicas, your_uuid):
app = self.app
node = app.nm.getNodeByServer(conn.getAddress())
node = app.nm.getByAddress(conn.getAddress())
assert node_type == MASTER_NODE_TYPE
assert conn.getAddress() == address
......
......@@ -30,7 +30,7 @@ class StorageServiceHandler(BaseServiceHandler):
""" Handler dedicated to storages during service state """
def connectionCompleted(self, conn):
node = self.app.nm.getNodeByUUID(conn.getUUID())
node = self.app.nm.getByUUID(conn.getUUID())
if node.getState() == protocol.RUNNING_STATE:
conn.notify(protocol.notifyLastOID(self.app.loid))
conn.notify(protocol.startOperation())
......@@ -46,7 +46,7 @@ class StorageServiceHandler(BaseServiceHandler):
def handleNotifyInformationLocked(self, conn, packet, tid):
uuid = conn.getUUID()
app = self.app
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
# If the given transaction ID is later than the last TID, the peer
# is crazy.
......@@ -64,7 +64,7 @@ class StorageServiceHandler(BaseServiceHandler):
for c in app.em.getConnectionList():
uuid = c.getUUID()
if uuid is not None:
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
if node.isClient():
if c is t.getConnection():
p = protocol.notifyTransactionFinished(tid)
......@@ -86,7 +86,7 @@ class StorageServiceHandler(BaseServiceHandler):
# a replication has finished.
uuid = conn.getUUID()
app = self.app
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
new_cell_list = []
for cell in cell_list:
......
......@@ -331,6 +331,3 @@ class NodeManager(object):
getStorageNodeList = getStorageList
getClientNodeList = getClientList
getAdminNodeList = getAdminList
getNodeByUUID = getByUUID
def getNodeByServer(self, server):
return self.getByAddress(address=server)
......@@ -173,7 +173,7 @@ class PartitionTable(object):
for offset, row in row_list:
assert offset < self.getPartitions() and not self.hasOffset(offset)
for uuid, state in row:
node = nm.getNodeByUUID(uuid)
node = nm.getByUUID(uuid)
# XXX: the node should be known before we receive the partition
# table, so remove this assert when this is checked.
assert node is not None
......@@ -190,7 +190,7 @@ class PartitionTable(object):
return
self.id = ptid
for offset, uuid, state in cell_list:
node = nm.getNodeByUUID(uuid)
node = nm.getByUUID(uuid)
assert node is not None
self.setCell(offset, node, state)
logging.debug('partition table updated')
......
......@@ -135,7 +135,7 @@ class Application(object):
# convert from int to Enum
state = protocol.cell_states[state]
# register unknown nodes
if self.nm.getNodeByUUID(uuid) is None:
if self.nm.getByUUID(uuid) is None:
self.nm.createStorage(
uuid=uuid,
state=protocol.TEMPORARILY_DOWN_STATE,
......@@ -169,7 +169,7 @@ class Application(object):
while 1:
try:
# check my state
node = self.nm.getNodeByUUID(self.uuid)
node = self.nm.getByUUID(self.uuid)
if node is not None and node.getState() == HIDDEN_STATE:
self.wait()
self.verifyData()
......@@ -295,7 +295,7 @@ class Application(object):
for conn in self.em.getConnectionList():
conn.setHandler(handler)
node = self.nm.getNodeByUUID(self.uuid)
node = self.nm.getByUUID(self.uuid)
while 1:
self.em.poll(1)
if node.getState() != HIDDEN_STATE:
......
......@@ -34,7 +34,7 @@ class IdentificationHandler(BaseStorageHandler):
if not self.app.ready:
raise protocol.NotReadyError
app = self.app
node = app.nm.getNodeByUUID(uuid)
node = app.nm.getByUUID(uuid)
# choose the handler according to the node type
if node_type == protocol.CLIENT_NODE_TYPE:
from neo.storage.handlers.client import ClientOperationHandler
......
......@@ -99,7 +99,7 @@ class ClientHandlerTests(NeoTestBase):
master_node_next_packet_id = 1
class App:
primary_master_node = Mock({'getUUID': self.getNewUUID()})
nm = Mock({'getNodeByServer': fake_storage_node})
nm = Mock({'getByAddress': fake_storage_node})
cp = Mock({'removeConnection': None})
master_conn = Mock({
'_addPacket': None,
......@@ -211,7 +211,7 @@ class ClientHandlerTests(NeoTestBase):
def test_clientAcceptNodeIdentification(self):
class App:
nm = Mock({'getNodeByServer': None})
nm = Mock({'getByAddress': None})
storage_node = None
pt = None
app = App()
......@@ -233,7 +233,7 @@ class ClientHandlerTests(NeoTestBase):
from Queue import Queue
queue = Queue()
class App:
nm = Mock({'getNodeByServer': node})
nm = Mock({'getByAddress': node})
storage_node = None
pt = None
local_var = FakeLocal()
......@@ -255,7 +255,7 @@ class ClientHandlerTests(NeoTestBase):
def test_storageAcceptNodeIdentification(self):
node = Mock({'setUUID': None})
class App:
nm = Mock({'getNodeByServer': node})
nm = Mock({'getByAddress': node})
storage_node = None
pt = None
app = App()
......@@ -279,20 +279,20 @@ class ClientHandlerTests(NeoTestBase):
for node_type in (CLIENT_NODE_TYPE, STORAGE_NODE_TYPE):
node = Mock({'getType': node_type})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': None, 'add': None})
nm = Mock({'getByUUID': node, 'getByAddress': None, 'add': None})
trying_master_node = None
app = App()
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection()
client_handler.handleAnswerPrimaryMaster(conn, None, 0, [])
# Check that nothing happened
self.assertEqual(len(app.nm.mockGetNamedCalls('getNodeByServer')), 0)
self.assertEqual(len(app.nm.mockGetNamedCalls('getByAddress')), 0)
self.assertEqual(len(app.nm.mockGetNamedCalls('add')), 0)
def test_unknownNodeAnswerPrimaryMaster(self):
node = Mock({'getType': MASTER_NODE_TYPE})
class App:
nm = Mock({'getNodeByServer': None, 'add': None})
nm = Mock({'getByAddress': None, 'add': None})
primary_master_node = None
app = App()
client_handler = PrimaryBootstrapHandler(app)
......@@ -300,14 +300,14 @@ class ClientHandlerTests(NeoTestBase):
test_master_list = [(('127.0.0.1', 10010), self.getNewUUID())]
client_handler.handleAnswerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
# Check that yet-unknown master node got added
getNodeByServer_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
add_call_list = app.nm.mockGetNamedCalls('add')
self.assertEqual(len(getNodeByServer_call_list), 1)
self.assertEqual(len(getByAddress_call_list), 1)
self.assertEqual(len(add_call_list), 1)
(address, port), test_uuid = test_master_list[0]
getNodeByServer_call = getNodeByServer_call_list[0]
getByAddress_call = getNodeByServer_call_list[0]
add_call = add_call_list[0]
self.assertEquals((address, port), getNodeByServer_call.getParam(0))
self.assertEquals((address, port), getByAddress_call.getParam(0))
node_instance = add_call.getParam(0)
self.assertEquals(test_uuid, node_instance.getUUID())
# Check that primary master was not updated (it is not known yet,
......@@ -317,7 +317,7 @@ class ClientHandlerTests(NeoTestBase):
def test_knownNodeUnknownUUIDNodeAnswerPrimaryMaster(self):
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': None, 'setUUID': None})
class App:
nm = Mock({'getNodeByServer': node, 'add': None})
nm = Mock({'getByAddress': node, 'add': None})
primary_master_node = None
app = App()
client_handler = PrimaryBootstrapHandler(app)
......@@ -326,13 +326,13 @@ class ClientHandlerTests(NeoTestBase):
test_master_list = [(('127.0.0.1', 10010), test_node_uuid)]
client_handler.handleAnswerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
# Test sanity checks
getNodeByServer_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getNodeByServer_call_list), 1)
self.assertEqual(getNodeByServer_call_list[0].getParam(0), test_master_list[0][0])
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getByAddress_call_list), 1)
self.assertEqual(getByAddress_call_list[0].getParam(0), test_master_list[0][0])
# Check that known master node did not get added
getNodeByServer_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
add_call_list = app.nm.mockGetNamedCalls('add')
self.assertEqual(len(getNodeByServer_call_list), 1)
self.assertEqual(len(getByAddress_call_list), 1)
self.assertEqual(len(add_call_list), 0)
# Check that node UUID got updated
self.checkUUIDSet(node, test_node_uuid)
......@@ -344,7 +344,7 @@ class ClientHandlerTests(NeoTestBase):
test_node_uuid = self.getNewUUID()
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByServer': node, 'add': None})
nm = Mock({'getByAddress': node, 'add': None})
primary_master_node = None
app = App()
client_handler = PrimaryBootstrapHandler(app)
......@@ -352,9 +352,9 @@ class ClientHandlerTests(NeoTestBase):
test_master_list = [(('127.0.0.1', 10010), test_node_uuid)]
client_handler.handleAnswerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
# Test sanity checks
getNodeByServer_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getNodeByServer_call_list), 1)
self.assertEqual(getNodeByServer_call_list[0].getParam(0), test_master_list[0][0])
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getByAddress_call_list), 1)
self.assertEqual(getByAddress_call_list[0].getParam(0), test_master_list[0][0])
# Check that known master node did not get added
add_call_list = app.nm.mockGetNamedCalls('add')
self.assertEqual(len(add_call_list), 0)
......@@ -378,7 +378,7 @@ class ClientHandlerTests(NeoTestBase):
test_primary_master_node = Mock({'getUUID': test_primary_node_uuid})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': node, 'add': None})
nm = Mock({'getByUUID': node, 'getByAddress': node, 'add': None})
primary_master_node = test_primary_master_node
trying_master_node = None
app = App()
......@@ -391,17 +391,17 @@ class ClientHandlerTests(NeoTestBase):
# Check that the primary master changed
self.assertTrue(app.primary_master_node is node)
# Test sanity checks
getNodeByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getNodeByUUID_call_list), 1)
self.assertEqual(getNodeByUUID_call_list[0].getParam(0), test_node_uuid)
getNodeByServer_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getNodeByServer_call_list), 0)
getByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getByUUID_call_list), 1)
self.assertEqual(getByUUID_call_list[0].getParam(0), test_node_uuid)
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getByAddress_call_list), 0)
def test_alreadySamePrimaryAnswerPrimaryMaster(self):
test_node_uuid = self.getNewUUID()
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': node, 'add': None})
nm = Mock({'getByUUID': node, 'getByAddress': node, 'add': None})
primary_master_node = node
trying_master_node = node
app = App()
......@@ -418,7 +418,7 @@ class ClientHandlerTests(NeoTestBase):
test_primary_node_uuid = self.getNewUUID()
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': None, 'getNodeByServer': node, 'add': None})
nm = Mock({'getByUUID': None, 'getByAddress': node, 'add': None})
primary_master_node = None
trying_master_node = None
app = App()
......@@ -426,9 +426,9 @@ class ClientHandlerTests(NeoTestBase):
conn = self.getConnection()
client_handler.handleAnswerPrimaryMaster(conn, None, test_primary_node_uuid, [])
# Test sanity checks
getNodeByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getNodeByUUID_call_list), 1)
self.assertEqual(getNodeByUUID_call_list[0].getParam(0), test_primary_node_uuid)
getByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getByUUID_call_list), 1)
self.assertEqual(getByUUID_call_list[0].getParam(0), test_primary_node_uuid)
# Check that primary node was not updated.
self.assertTrue(app.primary_master_node is None)
......@@ -436,7 +436,7 @@ class ClientHandlerTests(NeoTestBase):
test_node_uuid = self.getNewUUID()
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': node, 'add': None})
nm = Mock({'getByUUID': node, 'getByAddress': node, 'add': None})
primary_master_node = None
trying_master_node = None
app = App()
......@@ -445,12 +445,12 @@ class ClientHandlerTests(NeoTestBase):
test_master_list = [(('127.0.0.1', 10010), test_node_uuid)]
client_handler.handleAnswerPrimaryMaster(conn, None, test_node_uuid, test_master_list)
# Test sanity checks
getNodeByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getNodeByUUID_call_list), 1)
self.assertEqual(getNodeByUUID_call_list[0].getParam(0), test_node_uuid)
getNodeByServer_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getNodeByServer_call_list), 1)
self.assertEqual(getNodeByServer_call_list[0].getParam(0), test_master_list[0][0])
getByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getByUUID_call_list), 1)
self.assertEqual(getByUUID_call_list[0].getParam(0), test_node_uuid)
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getByAddress_call_list), 1)
self.assertEqual(getByAddress_call_list[0].getParam(0), test_master_list[0][0])
# Check that primary master was updated to known node
self.assertTrue(app.primary_master_node is node)
......@@ -458,7 +458,7 @@ class ClientHandlerTests(NeoTestBase):
node = Mock({'getType': MASTER_NODE_TYPE})
test_ptid = 0
class App:
nm = Mock({'getNodeByUUID': node})
nm = Mock({'getByUUID': node})
pt = PartitionTable(1, 1)
app = App()
client_handler = PrimaryNotificationsHandler(app, Mock())
......@@ -471,7 +471,7 @@ class ClientHandlerTests(NeoTestBase):
test_node = Mock({'getType': MASTER_NODE_TYPE})
test_ptid = 0
class App:
nm = Mock({'getNodeByUUID': ReturnValues(test_node, None), 'add': None})
nm = Mock({'getByUUID': ReturnValues(test_node, None), 'add': None})
pt = Mock({'setCell': None})
ptid = test_ptid
test_storage_uuid = self.getNewUUID()
......@@ -496,7 +496,7 @@ class ClientHandlerTests(NeoTestBase):
test_node = Mock({'getType': MASTER_NODE_TYPE})
test_ptid = 0
class App:
nm = Mock({'getNodeByUUID': test_node, 'add': None})
nm = Mock({'getByUUID': test_node, 'add': None})
pt = Mock({'setCell': None})
ptid = test_ptid
test_storage_uuid = self.getNewUUID()
......@@ -519,7 +519,7 @@ class ClientHandlerTests(NeoTestBase):
test_master_uuid = self.getNewUUID()
node = Mock({'getType': node_type})
class App:
nm = Mock({'getNodeByUUID': node})
nm = Mock({'getByUUID': node})
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection(uuid=test_master_uuid)
......@@ -533,24 +533,24 @@ class ClientHandlerTests(NeoTestBase):
test_master_uuid = self.getNewUUID()
node = Mock({'getType': MASTER_NODE_TYPE})
class App:
nm = Mock({'getNodeByUUID': node})
nm = Mock({'getByUUID': node})
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection(uuid=test_master_uuid)
self.assertRaises(TypeError, client_handler.handleNotifyNodeInformation,
conn, None, None)
def _testNotifyNodeInformation(self, test_node, getNodeByServer=None, getNodeByUUID=MARKER):
def _testNotifyNodeInformation(self, test_node, getByAddress=None, getByUUID=MARKER):
invalid_uid_test_node = (test_node[0], test_node[1], test_node[2] + 1,
INVALID_UUID, test_node[4])
test_node_list = [test_node, invalid_uid_test_node]
test_master_uuid = self.getNewUUID()
node = Mock({'getType': MASTER_NODE_TYPE})
if getNodeByUUID is not MARKER:
getNodeByUUID = ReturnValues(node, getNodeByUUID)
if getByUUID is not MARKER:
getByUUID = ReturnValues(node, getNodeByUUID)
class App:
nm = Mock({'getNodeByUUID': getNodeByUUID,
'getNodeByServer': getNodeByServer,
nm = Mock({'getByUUID': getNodeByUUID,
'getByAddress': getNodeByServer,
'add': None,
'remove': None})
app = App()
......@@ -565,7 +565,7 @@ class ClientHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
test_node = (MASTER_NODE_TYPE, '127.0.0.1', 10010, uuid,
RUNNING_STATE)
nm = self._testNotifyNodeInformation(test_node, getNodeByUUID=None)
nm = self._testNotifyNodeInformation(test_node, getByUUID=None)
# Check that two nodes got added (second is with INVALID_UUID)
add_call_list = nm.mockGetNamedCalls('add')
self.assertEqual(len(add_call_list), 2)
......@@ -579,8 +579,8 @@ class ClientHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
test_node = (MASTER_NODE_TYPE, '127.0.0.1', 10010, uuid,
RUNNING_STATE)
nm = self._testNotifyNodeInformation(test_node, getNodeByServer=node,
getNodeByUUID=node)
nm = self._testNotifyNodeInformation(test_node, getByAddress=node,
getByUUID=node)
# Check that node got replaced
add_call_list = nm.mockGetNamedCalls('add')
self.assertEquals(len(add_call_list), 1)
......@@ -594,7 +594,7 @@ class ClientHandlerTests(NeoTestBase):
def test_unknownStorageNotifyNodeInformation(self):
test_node = (STORAGE_NODE_TYPE, '127.0.0.1', 10010, self.getNewUUID(),
RUNNING_STATE)
nm = self._testNotifyNodeInformation(test_node, getNodeByUUID=None)
nm = self._testNotifyNodeInformation(test_node, getByUUID=None)
# Check that node got added
add_call_list = nm.mockGetNamedCalls('add')
self.assertEqual(len(add_call_list), 1)
......@@ -609,7 +609,7 @@ class ClientHandlerTests(NeoTestBase):
node = Mock({'setState': None, 'setServer': None})
test_node = (STORAGE_NODE_TYPE, '127.0.0.1', 10010, self.getNewUUID(),
RUNNING_STATE)
nm = self._testNotifyNodeInformation(test_node, getNodeByUUID=node)
nm = self._testNotifyNodeInformation(test_node, getByUUID=node)
# Check that node got replaced
add_call_list = nm.mockGetNamedCalls('add')
self.assertEquals(len(add_call_list), 1)
......@@ -636,7 +636,7 @@ class ClientHandlerTests(NeoTestBase):
test_master_uuid = self.getNewUUID()
node = Mock({'getType': node_type, 'getUUID': test_master_uuid})
class App:
nm = Mock({'getNodeByUUID': node})
nm = Mock({'getByUUID': node})
pt = Mock()
ptid = INVALID_PTID
primary_master_node = node
......@@ -651,7 +651,7 @@ class ClientHandlerTests(NeoTestBase):
def test_noPrimaryMasterNotifyPartitionChanges(self):
node = Mock({'getType': MASTER_NODE_TYPE})
class App:
nm = Mock({'getNodeByUUID': node})
nm = Mock({'getByUUID': node})
pt = Mock()
ptid = INVALID_PTID
primary_master_node = None
......@@ -671,7 +671,7 @@ class ClientHandlerTests(NeoTestBase):
node = Mock({'getType': MASTER_NODE_TYPE})
test_master_node = Mock({'getUUID': test_master_uuid})
class App:
nm = Mock({'getNodeByUUID': node})
nm = Mock({'getByUUID': node})
pt = Mock()
ptid = INVALID_PTID
primary_master_node = test_master_node
......@@ -688,7 +688,7 @@ class ClientHandlerTests(NeoTestBase):
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_master_uuid})
test_ptid = 1
class App:
nm = Mock({'getNodeByUUID': node})
nm = Mock({'getByUUID': node})
pt = Mock()
primary_master_node = node
ptid = test_ptid
......@@ -706,7 +706,7 @@ class ClientHandlerTests(NeoTestBase):
test_node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_master_uuid})
test_ptid = 1
class App:
nm = Mock({'getNodeByUUID': ReturnValues(None)})
nm = Mock({'getByUUID': ReturnValues(None)})
pt = Mock({'setCell': None})
primary_master_node = test_node
ptid = test_ptid
......@@ -736,7 +736,7 @@ class ClientHandlerTests(NeoTestBase):
uuid3, uuid4 = self.getNewUUID(), self.getNewUUID()
test_node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': uuid1})
class App:
nm = Mock({'getNodeByUUID': ReturnValues(test_node, None, None, None), 'add': None})
nm = Mock({'getByUUID': ReturnValues(test_node, None, None, None), 'add': None})
pt = Mock({'setCell': None})
primary_master_node = test_node
ptid = test_ptid
......
......@@ -211,7 +211,7 @@ class MasterClientHandlerTests(NeoTestBase):
upper, lower = unpack('!LL', self.app.ltid)
new_tid = pack('!LL', upper, lower + 10)
self.checkUnexpectedPacketRaised(service.handleFinishTransaction, conn, packet, oid_list, new_tid)
old_node = self.app.nm.getNodeByUUID(uuid)
old_node = self.app.nm.getByUUID(uuid)
self.app.nm.remove(old_node)
self.app.pt.dropNode(old_node)
......@@ -309,16 +309,16 @@ class MasterClientHandlerTests(NeoTestBase):
self.assertTrue(self.app.pt.operational())
conn = self.getFakeConnection(storage_uuid, ('127.0.0.1', self.storage_port+1))
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), RUNNING_STATE)
service.peerBroken(conn)
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), BROKEN_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), BROKEN_STATE)
self.failUnless(lptid < self.app.pt.getID())
# give an uuid, must raise as no other storage node available
conn = self.getFakeConnection(uuid, self.storage_address)
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
self.assertRaises(OperationFailure, service.peerBroken, conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), BROKEN_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), BROKEN_STATE)
self.failUnless(lptid < self.app.pt.getID())
# give a client uuid which have unfinished transactions
client_uuid = self.identifyToMasterNode(node_type=CLIENT_NODE_TYPE,
......@@ -329,11 +329,11 @@ class MasterClientHandlerTests(NeoTestBase):
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
service.peerBroken(conn)
# node must be have been remove, and no more transaction must remains
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid), None)
self.assertEquals(self.app.nm.getByUUID(client_uuid), None)
self.assertEquals(lptid, self.app.pt.getID())
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 0)
......@@ -350,16 +350,16 @@ class MasterClientHandlerTests(NeoTestBase):
self.assertTrue(self.app.pt.operational())
conn = self.getFakeConnection(storage_uuid, ('127.0.0.1', self.storage_port+1))
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), RUNNING_STATE)
service.timeoutExpired(conn)
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give an uuid, must raise as no other storage node available
conn = self.getFakeConnection(uuid, self.storage_address)
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
self.assertRaises(OperationFailure, service.timeoutExpired, conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give a client uuid which have unfinished transactions
client_uuid = self.identifyToMasterNode(node_type=CLIENT_NODE_TYPE,
......@@ -370,11 +370,11 @@ class MasterClientHandlerTests(NeoTestBase):
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
service.timeoutExpired(conn)
# node must be have been remove, and no more transaction must remains
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid), None)
self.assertEquals(self.app.nm.getByUUID(client_uuid), None)
self.assertEquals(lptid, self.app.pt.getID())
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 0)
......@@ -391,16 +391,16 @@ class MasterClientHandlerTests(NeoTestBase):
self.assertTrue(self.app.pt.operational())
conn = self.getFakeConnection(storage_uuid, ('127.0.0.1', self.storage_port+1))
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), RUNNING_STATE)
service.connectionClosed(conn)
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give an uuid, must raise as no other storage node available
conn = self.getFakeConnection(uuid, self.storage_address)
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
self.assertRaises(OperationFailure, service.connectionClosed, conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give a client uuid which have unfinished transactions
client_uuid = self.identifyToMasterNode(node_type=CLIENT_NODE_TYPE,
......@@ -411,11 +411,11 @@ class MasterClientHandlerTests(NeoTestBase):
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
service.connectionClosed(conn)
# node must be have been remove, and no more transaction must remains
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid), None)
self.assertEquals(self.app.nm.getByUUID(client_uuid), None)
self.assertEquals(lptid, self.app.pt.getID())
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 0)
......
......@@ -128,11 +128,11 @@ class MasterClientElectionTests(NeoTestBase):
self.election.connectionStarted(conn)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.election.connectionFailed(conn)
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_11_handleAskPrimaryMaster(self):
election = self.election
......@@ -317,11 +317,11 @@ class MasterServerElectionTests(NeoTestBase):
connector_handler = DoNothingConnector)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.election.connectionClosed(conn)
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_05_timeoutExpired(self):
uuid = self.identifyToMasterNode(port=self.master_port)
......@@ -329,11 +329,11 @@ class MasterServerElectionTests(NeoTestBase):
connector_handler = DoNothingConnector)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.election.timeoutExpired(conn)
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_06_peerBroken1(self):
uuid = self.identifyToMasterNode(port=self.master_port)
......@@ -341,11 +341,11 @@ class MasterServerElectionTests(NeoTestBase):
connector_handler = DoNothingConnector)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.election.peerBroken(conn)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), DOWN_STATE)
def test_06_peerBroken2(self):
uuid = self.identifyToMasterNode(port=self.master_port)
......@@ -358,11 +358,11 @@ class MasterServerElectionTests(NeoTestBase):
self.election.connectionStarted(conn)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.election.peerBroken(conn)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), BROKEN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), BROKEN_STATE)
def test_07_packetReceived(self):
uuid = self.identifyToMasterNode(port=self.master_port)
......@@ -373,13 +373,13 @@ class MasterServerElectionTests(NeoTestBase):
connector_handler = DoNothingConnector)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
node = self.app.nm.getNodeByServer(conn.getAddress())
node = self.app.nm.getByAddress(conn.getAddress())
node.setState(DOWN_STATE)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), DOWN_STATE)
self.election.packetReceived(conn, p)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
def test_08_handleAcceptNodeIdentification1(self):
# test with storage node, must be rejected
......@@ -391,7 +391,7 @@ class MasterServerElectionTests(NeoTestBase):
p = protocol.acceptNodeIdentification(*args)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getUUID(), None)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getUUID(), None)
self.assertEqual(conn.getUUID(), None)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.election.handleAcceptNodeIdentification(conn, p, STORAGE_NODE_TYPE,
......@@ -414,7 +414,7 @@ class MasterServerElectionTests(NeoTestBase):
p = protocol.acceptNodeIdentification(*args)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getUUID(), None)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getUUID(), None)
self.assertEqual(conn.getUUID(), None)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.election.handleAcceptNodeIdentification(conn, p, STORAGE_NODE_TYPE,
......@@ -434,7 +434,7 @@ class MasterServerElectionTests(NeoTestBase):
p = protocol.acceptNodeIdentification(*args)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getUUID(), None)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getUUID(), None)
self.assertEqual(conn.getUUID(), None)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
......@@ -443,7 +443,7 @@ class MasterServerElectionTests(NeoTestBase):
self.app.pt.getPartitions(),
self.app.pt.getReplicas(),
self.app.uuid)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getUUID(), uuid)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getUUID(), uuid)
self.assertEqual(conn.getUUID(), uuid)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),2)
self.checkCalledAskPrimaryMaster(conn.getConnector(), 1)
......@@ -516,7 +516,7 @@ class MasterServerElectionTests(NeoTestBase):
# broken node
conn = Mock({"_addPacket" : None, "abort" : None, "expectMessage" : None,
"isServer" : True})
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port+1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port+1))
self.assertEqual(node.getUUID(), new_uuid)
self.assertEqual(node.getState(), RUNNING_STATE)
node.setState(BROKEN_STATE)
......@@ -587,10 +587,10 @@ class MasterServerElectionTests(NeoTestBase):
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.master_port)})
node_list = [(MASTER_NODE_TYPE, ('127.0.0.1', self.master_port - 1), self.app.uuid, DOWN_STATE),]
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port-1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None)
election.handleNotifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port-1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None)
# tell about a storage node, do nothing
conn = Mock({"getUUID" : uuid,
......@@ -610,17 +610,17 @@ class MasterServerElectionTests(NeoTestBase):
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.master_port)})
node_list = [(MASTER_NODE_TYPE, ('127.0.0.1', self.master_port + 1), self.getNewUUID(), RUNNING_STATE),]
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port+1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port+1))
self.assertEqual(node, None)
election.handleNotifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port+1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port+1))
self.assertNotEqual(node, None)
self.assertEqual(node.getServer(), ("127.0.0.1", self.master_port+1))
self.assertEqual(node.getState(), RUNNING_STATE)
# tell that node is down
node_list = [(MASTER_NODE_TYPE, '127.0.0.1', self.master_port + 1, self.getNewUUID(), DOWN_STATE),]
election.handleNotifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port+1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port+1))
self.assertNotEqual(node, None)
self.assertEqual(node.getServer(), ("127.0.0.1", self.master_port+1))
self.assertEqual(node.getState(), DOWN_STATE)
......
......@@ -92,24 +92,24 @@ class MasterRecoveryTests(NeoTestBase):
def test_01_connectionClosed(self):
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
conn = self.getFakeConnection(uuid, self.master_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.recovery.connectionClosed(conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_02_timeoutExpired(self):
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
conn = self.getFakeConnection(uuid, self.master_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.recovery.timeoutExpired(conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_03_peerBroken(self):
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
conn = self.getFakeConnection(uuid, self.master_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.recovery.peerBroken(conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), BROKEN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), BROKEN_STATE)
def test_08_handleNotifyNodeInformation(self):
recovery = self.recovery
......@@ -125,15 +125,15 @@ class MasterRecoveryTests(NeoTestBase):
# tell the master node about itself, if running must do nothing
conn = self.getFakeConnection(uuid, self.master_address)
node_list = [(MASTER_NODE_TYPE, '127.0.0.1', self.master_port-1, self.app.uuid, RUNNING_STATE),]
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port-1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None)
recovery.handleNotifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port-1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
# tell the master node about itself, if down must raise
conn = self.getFakeConnection(uuid, self.master_address)
node_list = [(MASTER_NODE_TYPE, '127.0.0.1', self.master_port-1, self.app.uuid, DOWN_STATE),]
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port-1))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None)
self.assertRaises(RuntimeError, recovery.handleNotifyNodeInformation, conn, packet, node_list)
......@@ -147,19 +147,19 @@ class MasterRecoveryTests(NeoTestBase):
# tell about a known node but different address
conn = self.getFakeConnection(uuid, self.master_address)
node_list = [(MASTER_NODE_TYPE, '127.0.0.2', self.master_port, uuid, DOWN_STATE),]
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), RUNNING_STATE)
recovery.handleNotifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), RUNNING_STATE)
# tell about a known node
conn = self.getFakeConnection(uuid, self.master_address)
node_list = [(MASTER_NODE_TYPE, '127.0.0.1', self.master_port, uuid, DOWN_STATE),]
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), RUNNING_STATE)
recovery.handleNotifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port))
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), DOWN_STATE)
......
......@@ -163,7 +163,7 @@ class MasterStorageHandlerTests(NeoTestBase):
upper, lower = unpack('!LL', self.app.ltid)
new_tid = pack('!LL', upper, lower + 10)
self.checkUnexpectedPacketRaised(service.handleNotifyInformationLocked, conn, packet, new_tid)
old_node = self.app.nm.getNodeByUUID(uuid)
old_node = self.app.nm.getByUUID(uuid)
# job done through dispatch -> peerBroken
self.app.nm.remove(old_node)
self.app.pt.dropNode(old_node)
......@@ -282,7 +282,7 @@ class MasterStorageHandlerTests(NeoTestBase):
self.assertEquals(state, OUT_OF_DATE_STATE)
# mark the second storage node as feeding and say we are up to date
# second node must go to discarded state and first one to up to date state
self.app.pt.setCell(offset, self.app.nm.getNodeByUUID(storage_uuid), FEEDING_STATE)
self.app.pt.setCell(offset, self.app.nm.getByUUID(storage_uuid), FEEDING_STATE)
cell_list = [(offset, uuid, UP_TO_DATE_STATE),]
cells = self.app.pt.getRow(offset)
for cell, state in cells:
......@@ -306,9 +306,9 @@ class MasterStorageHandlerTests(NeoTestBase):
uuid = self.identifyToMasterNode()
# do nothing if no uuid
conn = self.getFakeConnection(None, self.storage_address)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
service.peerBroken(conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
# add a second storage node and then declare it as broken
self.identifyToMasterNode(port = self.storage_port+2)
storage_uuid = self.identifyToMasterNode(port = self.storage_port+1)
......@@ -318,16 +318,16 @@ class MasterStorageHandlerTests(NeoTestBase):
self.assertTrue(self.app.pt.operational())
conn = self.getFakeConnection(storage_uuid, ('127.0.0.1', self.storage_port+1))
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), RUNNING_STATE)
service.peerBroken(conn)
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), BROKEN_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), BROKEN_STATE)
self.failUnless(lptid < self.app.pt.getID())
# give an uuid, must raise as no other storage node available
conn = self.getFakeConnection(uuid, self.storage_address)
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
self.assertRaises(OperationFailure, service.peerBroken, conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), BROKEN_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), BROKEN_STATE)
self.failUnless(lptid < self.app.pt.getID())
# give a client uuid which have unfinished transactions
client_uuid = self.identifyToMasterNode(node_type=CLIENT_NODE_TYPE,
......@@ -338,11 +338,11 @@ class MasterStorageHandlerTests(NeoTestBase):
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
service.peerBroken(conn)
# node must be have been remove, and no more transaction must remains
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid), None)
self.assertEquals(self.app.nm.getByUUID(client_uuid), None)
self.assertEquals(lptid, self.app.pt.getID())
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 0)
......@@ -352,9 +352,9 @@ class MasterStorageHandlerTests(NeoTestBase):
uuid = self.identifyToMasterNode()
# do nothing if no uuid
conn = self.getFakeConnection(None, self.storage_address)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
service.timeoutExpired(conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
# add a second storage node and then declare it as temp down
self.identifyToMasterNode(port = self.storage_port+2)
storage_uuid = self.identifyToMasterNode(port = self.storage_port+1)
......@@ -364,16 +364,16 @@ class MasterStorageHandlerTests(NeoTestBase):
self.assertTrue(self.app.pt.operational())
conn = self.getFakeConnection(storage_uuid, ('127.0.0.1', self.storage_port+1))
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), RUNNING_STATE)
service.timeoutExpired(conn)
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give an uuid, must raise as no other storage node available
conn = self.getFakeConnection(uuid, self.storage_address)
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
self.assertRaises(OperationFailure, service.timeoutExpired, conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give a client uuid which have unfinished transactions
client_uuid = self.identifyToMasterNode(node_type=CLIENT_NODE_TYPE,
......@@ -384,11 +384,11 @@ class MasterStorageHandlerTests(NeoTestBase):
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
service.timeoutExpired(conn)
# node must be have been remove, and no more transaction must remains
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid), None)
self.assertEquals(self.app.nm.getByUUID(client_uuid), None)
self.assertEquals(lptid, self.app.pt.getID())
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 0)
......@@ -398,9 +398,9 @@ class MasterStorageHandlerTests(NeoTestBase):
uuid = self.identifyToMasterNode()
# do nothing if no uuid
conn = self.getFakeConnection(None, self.storage_address)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
service.connectionClosed(conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
# add a second storage node and then declare it as temp down
self.identifyToMasterNode(port = self.storage_port+2)
storage_uuid = self.identifyToMasterNode(port = self.storage_port+1)
......@@ -410,16 +410,16 @@ class MasterStorageHandlerTests(NeoTestBase):
self.assertTrue(self.app.pt.operational())
conn = self.getFakeConnection(storage_uuid, ('127.0.0.1', self.storage_port+1))
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), RUNNING_STATE)
service.connectionClosed(conn)
self.assertEquals(self.app.nm.getNodeByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give an uuid, must raise as no other storage node available
conn = self.getFakeConnection(uuid, self.storage_address)
lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), RUNNING_STATE)
self.assertRaises(OperationFailure, service.connectionClosed, conn)
self.assertEquals(self.app.nm.getNodeByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), TEMPORARILY_DOWN_STATE)
self.assertEquals(lptid, self.app.pt.getID())
# give a client uuid which have unfinished transactions
client_uuid = self.identifyToMasterNode(node_type=CLIENT_NODE_TYPE,
......@@ -430,11 +430,11 @@ class MasterStorageHandlerTests(NeoTestBase):
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(), RUNNING_STATE)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
service.connectionClosed(conn)
# node must be have been remove, and no more transaction must remains
self.assertEquals(self.app.nm.getNodeByUUID(client_uuid), None)
self.assertEquals(self.app.nm.getByUUID(client_uuid), None)
self.assertEquals(lptid, self.app.pt.getID())
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 0)
......
......@@ -89,41 +89,41 @@ class MasterVerificationTests(NeoTestBase):
def test_01_connectionClosed(self):
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
conn = self.getFakeConnection(uuid, self.master_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.verification.connectionClosed(conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
# test a storage, must raise as cluster no longer op
uuid = self.identifyToMasterNode()
conn = self.getFakeConnection(uuid, self.storage_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.assertRaises(VerificationFailure, self.verification.connectionClosed,conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_02_timeoutExpired(self):
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
conn = self.getFakeConnection(uuid, self.master_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.verification.timeoutExpired(conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
# test a storage, must raise as cluster no longer op
uuid = self.identifyToMasterNode()
conn = self.getFakeConnection(uuid, self.storage_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.assertRaises(VerificationFailure, self.verification.connectionClosed,conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_03_peerBroken(self):
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
conn = self.getFakeConnection(uuid, self.master_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.verification.peerBroken(conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), BROKEN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), BROKEN_STATE)
# test a storage, must raise as cluster no longer op
uuid = self.identifyToMasterNode()
conn = self.getFakeConnection(uuid, self.storage_address)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), RUNNING_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), RUNNING_STATE)
self.assertRaises(VerificationFailure, self.verification.connectionClosed,conn)
self.assertEqual(self.app.nm.getNodeByServer(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), TEMPORARILY_DOWN_STATE)
def test_09_handleAnswerLastIDs(self):
verification = self.verification
......
......@@ -150,11 +150,11 @@ class NodeManagerTests(NeoTestBase):
self.assertEqual(manager.getClientNodeList(), client_list)
def checkByServer(self, node):
node_found = self.manager.getNodeByServer(node.getServer())
node_found = self.manager.getByAddress(node.getServer())
self.assertEqual(node_found, node)
def checkByUUID(self, node):
node_found = self.manager.getNodeByUUID(node.getUUID())
node_found = self.manager.getByUUID(node.getUUID())
self.assertEqual(node_found, node)
def testInit(self):
......@@ -165,11 +165,11 @@ class NodeManagerTests(NeoTestBase):
self.checkStorages([])
self.checkClients([])
server = ('127.0.0.1', 10000)
self.assertEqual(manager.getNodeByServer(server), None)
self.assertEqual(manager.getNodeByServer(None), None)
self.assertEqual(manager.getByAddress(server), None)
self.assertEqual(manager.getByAddress(None), None)
uuid = self.getNewUUID()
self.assertEqual(manager.getNodeByUUID(uuid), None)
self.assertEqual(manager.getNodeByUUID(None), None)
self.assertEqual(manager.getByUUID(uuid), None)
self.assertEqual(manager.getByUUID(None), None)
def testAdd(self):
""" Check if new nodes are registered in the manager """
......@@ -198,7 +198,7 @@ class NodeManagerTests(NeoTestBase):
self.checkMasters([self.master])
self.checkClients([self.client])
# client node has no server
self.assertEqual(manager.getNodeByServer(self.client.getServer()), None)
self.assertEqual(manager.getByAddress(self.client.getServer()), None)
self.checkByUUID(self.client)
# admin
manager.add(self.admin)
......@@ -260,7 +260,7 @@ class NodeManagerTests(NeoTestBase):
self.checkClients([])
# - master change it's address
self.checkMasters([self.master])
self.assertEqual(manager.getNodeByServer(old_address), None)
self.assertEqual(manager.getByAddress(old_address), None)
self.master.setServer(new_address)
self.checkByServer(self.master)
# a new storage replaced the old one
......
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