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