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
......
This diff is collapsed.
......@@ -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)
......
This diff is collapsed.
......@@ -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)
......
This diff is collapsed.
......@@ -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