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