Commit 8e2b08de authored by Grégory Wisniewski's avatar Grégory Wisniewski

To follows changes in r1317, replace 'server' by 'address' for consistency.


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1320 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 36555d9a
...@@ -119,15 +119,15 @@ class Application(object): ...@@ -119,15 +119,15 @@ class Application(object):
nm = self.nm nm = self.nm
nm.clear() nm.clear()
self.cluster_state = None self.cluster_state = None
for server in self.master_node_list: for address in self.master_node_list:
nm.createMaster(server=server) nm.createMaster(address=address)
# search, find, connect and identify to the primary master # search, find, connect and identify to the primary master
bootstrap = BootstrapManager(self, self.name, protocol.ADMIN_NODE_TYPE, bootstrap = BootstrapManager(self, self.name, protocol.ADMIN_NODE_TYPE,
self.uuid, self.server) self.uuid, self.server)
data = bootstrap.getPrimaryConnection(self.connector_handler) data = bootstrap.getPrimaryConnection(self.connector_handler)
(node, conn, uuid, num_partitions, num_replicas) = data (node, conn, uuid, num_partitions, num_replicas) = data
nm.update([(node.getType(), node.getServer(), node.getUUID(), nm.update([(node.getType(), node.getAddress(), node.getUUID(),
protocol.RUNNING_STATE)]) protocol.RUNNING_STATE)])
self.master_node = node self.master_node = node
self.master_conn = conn self.master_conn = conn
......
...@@ -51,7 +51,7 @@ class AdminEventHandler(EventHandler): ...@@ -51,7 +51,7 @@ class AdminEventHandler(EventHandler):
node_information_list = [] node_information_list = []
for node in node_list: for node in node_list:
try: try:
ip, port = node.getServer() ip, port = node.getAddress()
except TypeError: except TypeError:
ip = "0.0.0.0" ip = "0.0.0.0"
port = 0 port = 0
......
...@@ -64,7 +64,7 @@ class BootstrapManager(EventHandler): ...@@ -64,7 +64,7 @@ class BootstrapManager(EventHandler):
for address, uuid in known_master_list: for address, uuid in known_master_list:
node = nm.getByAddress(address) node = nm.getByAddress(address)
if node is None: if node is None:
nm.createMaster(server=address) nm.createMaster(address=address)
node.setUUID(uuid) node.setUUID(uuid)
self.primary = nm.getByUUID(primary_uuid) self.primary = nm.getByUUID(primary_uuid)
...@@ -112,7 +112,7 @@ class BootstrapManager(EventHandler): ...@@ -112,7 +112,7 @@ class BootstrapManager(EventHandler):
sleep(1) sleep(1)
if conn is None: if conn is None:
# open the connection # open the connection
addr = self.current.getServer() addr = self.current.getAddress()
conn = ClientConnection(em, self, addr, connector_handler) conn = ClientConnection(em, self, addr, connector_handler)
# still processing # still processing
em.poll(1) em.poll(1)
......
...@@ -66,7 +66,7 @@ class ConnectionPool(object): ...@@ -66,7 +66,7 @@ class ConnectionPool(object):
def _initNodeConnection(self, node): def _initNodeConnection(self, node):
"""Init a connection to a given storage node.""" """Init a connection to a given storage node."""
addr = node.getServer() addr = node.getAddress()
if addr is None: if addr is None:
return None return None
...@@ -254,8 +254,8 @@ class Application(object): ...@@ -254,8 +254,8 @@ class Application(object):
# load master node list # load master node list
self.master_node_list = parseMasterList(master_nodes) self.master_node_list = parseMasterList(master_nodes)
logging.debug('master nodes are %s', self.master_node_list) logging.debug('master nodes are %s', self.master_node_list)
for server in self.master_node_list: for address in self.master_node_list:
self.nm.createMaster(server=server) self.nm.createMaster(address=address)
# no self-assigned UUID, primary master will supply us one # no self-assigned UUID, primary master will supply us one
self.uuid = None self.uuid = None
...@@ -406,7 +406,7 @@ class Application(object): ...@@ -406,7 +406,7 @@ class Application(object):
index += 1 index += 1
# Connect to master # Connect to master
conn = MTClientConnection(self.em, self.notifications_handler, conn = MTClientConnection(self.em, self.notifications_handler,
addr=self.trying_master_node.getServer(), addr=self.trying_master_node.getAddress(),
connector_handler=self.connector_handler, connector_handler=self.connector_handler,
dispatcher=self.dispatcher) dispatcher=self.dispatcher)
# Query for primary master node # Query for primary master node
...@@ -556,13 +556,13 @@ class Application(object): ...@@ -556,13 +556,13 @@ class Application(object):
if noid != oid: if noid != oid:
# Oops, try with next node # Oops, try with next node
logging.error('got wrong oid %s instead of %s from node %s', logging.error('got wrong oid %s instead of %s from node %s',
noid, dump(oid), cell.getServer()) noid, dump(oid), cell.getAddress())
self.local_var.asked_object = -1 self.local_var.asked_object = -1
continue continue
elif checksum != makeChecksum(data): elif checksum != makeChecksum(data):
# Check checksum. # Check checksum.
logging.error('wrong checksum from node %s for oid %s', logging.error('wrong checksum from node %s for oid %s',
cell.getServer(), dump(oid)) cell.getAddress(), dump(oid))
self.local_var.asked_object = -1 self.local_var.asked_object = -1
continue continue
else: else:
...@@ -715,7 +715,7 @@ class Application(object): ...@@ -715,7 +715,7 @@ class Application(object):
cell_list = self._getCellListForTID(self.local_var.tid, writable=True) cell_list = self._getCellListForTID(self.local_var.tid, writable=True)
self.local_var.voted_counter = 0 self.local_var.voted_counter = 0
for cell in cell_list: for cell in cell_list:
logging.debug("voting object %s %s" %(cell.getServer(), cell.getState())) logging.debug("voting object %s %s" %(cell.getAddress(), cell.getState()))
conn = self.cp.getConnForCell(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
......
...@@ -105,8 +105,8 @@ class Application(object): ...@@ -105,8 +105,8 @@ class Application(object):
def run(self): def run(self):
"""Make sure that the status is sane and start a loop.""" """Make sure that the status is sane and start a loop."""
for server in self.master_node_list: for address in self.master_node_list:
self.nm.createMaster(server=server) self.nm.createMaster(address=address)
# Make a listening port. # Make a listening port.
self.listening_conn = ListeningConnection(self.em, None, self.listening_conn = ListeningConnection(self.em, None,
...@@ -160,7 +160,7 @@ class Application(object): ...@@ -160,7 +160,7 @@ class Application(object):
for node in nm.getMasterList(): for node in nm.getMasterList():
if node.getState() == RUNNING_STATE: if node.getState() == RUNNING_STATE:
self.unconnected_master_node_set.add(node.getServer()) self.unconnected_master_node_set.add(node.getAddress())
# Wait at most 20 seconds at bootstrap. Otherwise, wait at most # Wait at most 20 seconds at bootstrap. Otherwise, wait at most
# 10 seconds to avoid stopping the whole cluster for a long time. # 10 seconds to avoid stopping the whole cluster for a long time.
...@@ -182,7 +182,7 @@ class Application(object): ...@@ -182,7 +182,7 @@ class Application(object):
and node.getLastStateChange() + expiration < current_time: and node.getLastStateChange() + expiration < current_time:
logging.info('%s is down' % (node, )) logging.info('%s is down' % (node, ))
node.setState(DOWN_STATE) node.setState(DOWN_STATE)
self.unconnected_master_node_set.discard(node.getServer()) self.unconnected_master_node_set.discard(node.getAddress())
# Try to connect to master nodes. # Try to connect to master nodes.
if self.unconnected_master_node_set: if self.unconnected_master_node_set:
...@@ -231,7 +231,7 @@ class Application(object): ...@@ -231,7 +231,7 @@ class Application(object):
# Now I need only a connection to the primary master node. # Now I need only a connection to the primary master node.
primary = self.primary_master_node primary = self.primary_master_node
addr = primary.getServer() addr = primary.getAddress()
for conn in em.getConnectionList(): for conn in em.getConnectionList():
if conn.isServer() or conn.isClient() \ if conn.isServer() or conn.isClient() \
and addr != conn.getAddress(): and addr != conn.getAddress():
...@@ -291,7 +291,7 @@ class Application(object): ...@@ -291,7 +291,7 @@ class Application(object):
uuid = node.getUUID() uuid = node.getUUID()
# The server address may be None. # The server address may be None.
address = node.getServer() address = node.getAddress()
if node.isClient(): if node.isClient():
# Only to master nodes and storage nodes. # Only to master nodes and storage nodes.
...@@ -354,7 +354,7 @@ class Application(object): ...@@ -354,7 +354,7 @@ class Application(object):
for n in self.nm.getList(): for n in self.nm.getList():
if not n.isAdmin(): if not n.isAdmin():
try: try:
address = n.getServer() address = n.getAddress()
except TypeError: except TypeError:
address = None address = None
node_list.append((n.getType(), address, n.getUUID(), n.getState())) node_list.append((n.getType(), address, n.getUUID(), n.getState()))
...@@ -724,7 +724,8 @@ class Application(object): ...@@ -724,7 +724,8 @@ class Application(object):
def isValidUUID(self, uuid, addr): def isValidUUID(self, uuid, addr):
node = self.nm.getByUUID(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.getAddress() is not None \
and node.getAddress() != addr:
return False return False
return uuid != self.uuid and uuid is not None return uuid != self.uuid and uuid is not None
...@@ -750,7 +751,7 @@ class Application(object): ...@@ -750,7 +751,7 @@ class Application(object):
for c in self.em.getConnectionList(): for c in self.em.getConnectionList():
node = self.nm.getByUUID(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.getAddress(),
node.getUUID(), DOWN_STATE)] node.getUUID(), DOWN_STATE)]
c.notify(protocol.notifyNodeInformation(node_list)) c.notify(protocol.notifyNodeInformation(node_list))
# then ask storages and master nodes to shutdown # then ask storages and master nodes to shutdown
...@@ -758,7 +759,7 @@ class Application(object): ...@@ -758,7 +759,7 @@ class Application(object):
for c in self.em.getConnectionList(): for c in self.em.getConnectionList():
node = self.nm.getByUUID(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.getAddress(),
node.getUUID(), DOWN_STATE)] node.getUUID(), DOWN_STATE)]
c.notify(protocol.notifyNodeInformation(node_list)) c.notify(protocol.notifyNodeInformation(node_list))
# then shutdown # then shutdown
......
...@@ -46,7 +46,7 @@ class MasterHandler(EventHandler): ...@@ -46,7 +46,7 @@ class MasterHandler(EventHandler):
for n in app.nm.getMasterList(): for n in app.nm.getMasterList():
if n.getState() == protocol.BROKEN_STATE: if n.getState() == protocol.BROKEN_STATE:
continue continue
known_master_list.append((n.getServer(), n.getUUID(), )) known_master_list.append((n.getAddress(), n.getUUID(), ))
conn.answer(protocol.answerPrimaryMaster(primary_uuid, conn.answer(protocol.answerPrimaryMaster(primary_uuid,
known_master_list), known_master_list),
packet.getId()) packet.getId())
......
...@@ -121,7 +121,7 @@ class ClientElectionHandler(ElectionHandler): ...@@ -121,7 +121,7 @@ class ClientElectionHandler(ElectionHandler):
# 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)
app.nm.remove(node) app.nm.remove(node)
app.negotiating_master_node_set.discard(node.getServer()) app.negotiating_master_node_set.discard(node.getAddress())
conn.close() conn.close()
return return
if conn.getAddress() != address: if conn.getAddress() != address:
...@@ -130,7 +130,7 @@ class ClientElectionHandler(ElectionHandler): ...@@ -130,7 +130,7 @@ class ClientElectionHandler(ElectionHandler):
logging.error('%s:%d is waiting for %s:%d', logging.error('%s:%d is waiting for %s:%d',
conn.getAddress()[0], conn.getAddress()[1], *address) conn.getAddress()[0], conn.getAddress()[1], *address)
app.nm.remove(node) app.nm.remove(node)
app.negotiating_master_node_set.discard(node.getServer()) app.negotiating_master_node_set.discard(node.getAddress())
conn.close() conn.close()
return return
...@@ -193,7 +193,7 @@ class ClientElectionHandler(ElectionHandler): ...@@ -193,7 +193,7 @@ class ClientElectionHandler(ElectionHandler):
app.primary_master_node = primary_node app.primary_master_node = primary_node
# Stop waiting for connections than primary master's to # Stop waiting for connections than primary master's to
# complete to exit election phase ASAP. # complete to exit election phase ASAP.
primary_server = primary_node.getServer() primary_server = primary_node.getAddress()
app.unconnected_master_node_set.intersection_update( app.unconnected_master_node_set.intersection_update(
[primary_server]) [primary_server])
app.negotiating_master_node_set.intersection_update( app.negotiating_master_node_set.intersection_update(
......
...@@ -37,23 +37,23 @@ class IdentificationHandler(MasterHandler): ...@@ -37,23 +37,23 @@ class IdentificationHandler(MasterHandler):
# 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
if node_by_uuid is not None: if node_by_uuid is not None:
if node.getServer() == address: if node.getAddress() == address:
if node.getState() == protocol.BROKEN_STATE: if node.getState() == protocol.BROKEN_STATE:
raise protocol.BrokenNodeDisallowedError raise protocol.BrokenNodeDisallowedError
# the node is still alive # the node is still alive
node.setState(protocol.RUNNING_STATE) node.setState(protocol.RUNNING_STATE)
if node.getServer() != address: if node.getAddress() != address:
if node.getState() == protocol.RUNNING_STATE: if node.getState() == protocol.RUNNING_STATE:
# still running, reject this new node # still running, reject this new node
raise protocol.ProtocolError('invalid server address') raise protocol.ProtocolError('invalid server address')
# this node has changed its address # this node has changed its address
node.setServer(address) node.setAddress(address)
node.setState(protocol.RUNNING_STATE) node.setState(protocol.RUNNING_STATE)
if node_by_uuid is None and node_by_addr is not None: if node_by_uuid is None and node_by_addr is not None:
if node.getState() == protocol.RUNNING_STATE: if node.getState() == protocol.RUNNING_STATE:
# still running, reject this new node # still running, reject this new node
raise protocol.ProtocolError('invalid server address') raise protocol.ProtocolError('invalid server address')
node.setServer(address) node.setAddress(address)
node.setState(protocol.RUNNING_STATE) node.setState(protocol.RUNNING_STATE)
# ask the app the node identification, if refused, an exception is raised # ask the app the node identification, if refused, an exception is raised
...@@ -64,7 +64,7 @@ class IdentificationHandler(MasterHandler): ...@@ -64,7 +64,7 @@ class IdentificationHandler(MasterHandler):
uuid = app.getNewUUID(node_type) uuid = app.getNewUUID(node_type)
if node is None: if node is None:
# new node # new node
node = node_ctor(uuid=uuid, server=address) node = node_ctor(uuid=uuid, address=address)
handler = handler(self.app) handler = handler(self.app)
# set up the node # set up the node
node.setUUID(uuid) node.setUUID(uuid)
......
...@@ -25,10 +25,7 @@ class Node(object): ...@@ -25,10 +25,7 @@ class Node(object):
"""This class represents a node.""" """This class represents a node."""
def __init__(self, manager, address=None, uuid=None, def __init__(self, manager, address=None, uuid=None,
state=protocol.UNKNOWN_STATE, server=None): state=protocol.UNKNOWN_STATE):
# XXX: backward compatibility
if server is not None:
address = server
self._state = state self._state = state
self._address = address self._address = address
self._uuid = uuid self._uuid = uuid
...@@ -94,8 +91,6 @@ class Node(object): ...@@ -94,8 +91,6 @@ class Node(object):
return NODE_CLASS_MAPPING[self.__class__] return NODE_CLASS_MAPPING[self.__class__]
except KeyError: except KeyError:
raise NotImplementedError raise NotImplementedError
getServer = getAddress
setServer = setAddress
class MasterNode(Node): class MasterNode(Node):
...@@ -170,8 +165,8 @@ class NodeManager(object): ...@@ -170,8 +165,8 @@ class NodeManager(object):
if new_key is not None: if new_key is not None:
index_dict[new_key] = node index_dict[new_key] = node
def _updateAddress(self, node, old_server): def _updateAddress(self, node, old_address):
self.__update(self._address_dict, old_server, node.getAddress(), node) self.__update(self._address_dict, old_address, node.getAddress(), node)
def _updateUUID(self, node, old_uuid): def _updateUUID(self, node, old_uuid):
self.__update(self._uuid_dict, old_uuid, node.getUUID(), node) self.__update(self._uuid_dict, old_uuid, node.getUUID(), node)
......
...@@ -45,8 +45,8 @@ class Cell(object): ...@@ -45,8 +45,8 @@ class Cell(object):
def getUUID(self): def getUUID(self):
return self.node.getUUID() return self.node.getUUID()
def getServer(self): def getAddress(self):
return self.node.getServer() return self.node.getAddress()
class PartitionTable(object): class PartitionTable(object):
......
...@@ -150,8 +150,8 @@ class Application(object): ...@@ -150,8 +150,8 @@ class Application(object):
if len(self.name) == 0: if len(self.name) == 0:
raise RuntimeError, 'cluster name must be non-empty' raise RuntimeError, 'cluster name must be non-empty'
for server in self.master_node_list: for address in self.master_node_list:
self.nm.createMaster(server=server) self.nm.createMaster(address=address)
# Make a listening port # Make a listening port
handler = identification.IdentificationHandler(self) handler = identification.IdentificationHandler(self)
......
...@@ -163,7 +163,7 @@ class Replicator(object): ...@@ -163,7 +163,7 @@ class Replicator(object):
self.current_partition = None self.current_partition = None
return return
addr = node.getServer() addr = node.getAddress()
if addr is None: if addr is None:
logging.error("no address known for the selected node %s" %(dump(node.getUUID()))) logging.error("no address known for the selected node %s" %(dump(node.getUUID())))
return return
......
...@@ -113,7 +113,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -113,7 +113,7 @@ class ClientApplicationTests(NeoTestBase):
obj = (oid, tid, 'DATA', '', app.local_var.txn) obj = (oid, tid, 'DATA', '', app.local_var.txn)
packet = protocol.answerStoreObject(conflicting=0, oid=oid, serial=tid) packet = protocol.answerStoreObject(conflicting=0, oid=oid, serial=tid)
conn = Mock({ 'getNextId': 1, 'fakeReceived': packet, }) conn = Mock({ 'getNextId': 1, 'fakeReceived': packet, })
cell = Mock({ 'getServer': 'FakeServer', 'getState': 'FakeState', }) cell = Mock({ 'getAddress': 'FakeServer', 'getState': 'FakeState', })
app.cp = Mock({ 'getConnForCell': conn}) app.cp = Mock({ 'getConnForCell': conn})
app.pt = Mock({ 'getCellListForID': (cell, cell, ) }) app.pt = Mock({ 'getCellListForID': (cell, cell, ) })
return oid return oid
...@@ -123,7 +123,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -123,7 +123,7 @@ class ClientApplicationTests(NeoTestBase):
txn = app.local_var.txn txn = app.local_var.txn
packet = protocol.answerStoreTransaction(tid=tid) packet = protocol.answerStoreTransaction(tid=tid)
conn = Mock({ 'getNextId': 1, 'fakeReceived': packet, }) conn = Mock({ 'getNextId': 1, 'fakeReceived': packet, })
cell = Mock({ 'getServer': 'FakeServer', 'getState': 'FakeState', }) cell = Mock({ 'getAddress': 'FakeServer', 'getState': 'FakeState', })
app.pt = Mock({ 'getCellListForID': (cell, cell, ) }) app.pt = Mock({ 'getCellListForID': (cell, cell, ) })
app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), }) app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), })
app.tpc_vote(txn) app.tpc_vote(txn)
...@@ -207,7 +207,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -207,7 +207,7 @@ class ClientApplicationTests(NeoTestBase):
packet = protocol.oidNotFound('') packet = protocol.oidNotFound('')
cell = Mock({ 'getUUID': '\x00' * 16}) cell = Mock({ 'getUUID': '\x00' * 16})
conn = Mock({'getUUID': '\x10' * 16, conn = Mock({'getUUID': '\x10' * 16,
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.local_var.queue = Mock({'get_nowait' : (conn, None)}) app.local_var.queue = Mock({'get_nowait' : (conn, None)})
...@@ -223,7 +223,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -223,7 +223,7 @@ class ClientApplicationTests(NeoTestBase):
packet = protocol.oidNotFound('') packet = protocol.oidNotFound('')
cell = Mock({ 'getUUID': '\x00' * 16}) cell = Mock({ 'getUUID': '\x00' * 16})
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.pt = Mock({ 'getCellListForOID': (cell, ), }) app.pt = Mock({ 'getCellListForOID': (cell, ), })
...@@ -234,7 +234,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -234,7 +234,7 @@ class ClientApplicationTests(NeoTestBase):
# object found on storage nodes and put in cache # object found on storage nodes and put in cache
packet = protocol.answerObject(*an_object[1:]) packet = protocol.answerObject(*an_object[1:])
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
...@@ -245,7 +245,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -245,7 +245,7 @@ class ClientApplicationTests(NeoTestBase):
self.assertTrue(oid in mq) self.assertTrue(oid in mq)
# object is now cached, try to reload it # object is now cached, try to reload it
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
}) })
app.cp = Mock({ '_getConnForCell' : conn}) app.cp = Mock({ '_getConnForCell' : conn})
result = app.load(oid) result = app.load(oid)
...@@ -263,7 +263,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -263,7 +263,7 @@ class ClientApplicationTests(NeoTestBase):
packet = protocol.oidNotFound('') packet = protocol.oidNotFound('')
cell = Mock({ 'getUUID': '\x00' * 16}) cell = Mock({ 'getUUID': '\x00' * 16})
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.pt = Mock({ 'getCellListForID': (cell, ), }) app.pt = Mock({ 'getCellListForID': (cell, ), })
...@@ -279,7 +279,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -279,7 +279,7 @@ class ClientApplicationTests(NeoTestBase):
another_object = (1, oid, tid2, INVALID_SERIAL, 0, makeChecksum('RIGHT'), 'RIGHT') another_object = (1, oid, tid2, INVALID_SERIAL, 0, makeChecksum('RIGHT'), 'RIGHT')
packet = protocol.answerObject(*another_object[1:]) packet = protocol.answerObject(*another_object[1:])
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
...@@ -300,7 +300,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -300,7 +300,7 @@ class ClientApplicationTests(NeoTestBase):
packet = protocol.oidNotFound('') packet = protocol.oidNotFound('')
cell = Mock({ 'getUUID': '\x00' * 16}) cell = Mock({ 'getUUID': '\x00' * 16})
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.pt = Mock({ 'getCellListForID': (cell, ), }) app.pt = Mock({ 'getCellListForID': (cell, ), })
...@@ -312,7 +312,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -312,7 +312,7 @@ class ClientApplicationTests(NeoTestBase):
an_object = (1, oid, tid2, INVALID_SERIAL, 0, makeChecksum(''), '') an_object = (1, oid, tid2, INVALID_SERIAL, 0, makeChecksum(''), '')
packet = protocol.answerObject(*an_object[1:]) packet = protocol.answerObject(*an_object[1:])
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
...@@ -327,7 +327,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -327,7 +327,7 @@ class ClientApplicationTests(NeoTestBase):
another_object = (1, oid, tid1, tid2, 0, makeChecksum('RIGHT'), 'RIGHT') another_object = (1, oid, tid1, tid2, 0, makeChecksum('RIGHT'), 'RIGHT')
packet = protocol.answerObject(*another_object[1:]) packet = protocol.answerObject(*another_object[1:])
conn = Mock({ conn = Mock({
'getServer': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
'fakeReceived': packet, 'fakeReceived': packet,
}) })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
...@@ -407,7 +407,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -407,7 +407,7 @@ class ClientApplicationTests(NeoTestBase):
'fakeReceived': packet, 'fakeReceived': packet,
}) })
cell = Mock({ cell = Mock({
'getServer': 'FakeServer', 'getAddress': 'FakeServer',
'getState': 'FakeState', 'getState': 'FakeState',
}) })
app.pt = Mock({ 'getCellListForID': (cell, cell, )}) app.pt = Mock({ 'getCellListForID': (cell, cell, )})
...@@ -437,7 +437,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -437,7 +437,7 @@ class ClientApplicationTests(NeoTestBase):
}) })
app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn, ) }) app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn, ) })
cell = Mock({ cell = Mock({
'getServer': 'FakeServer', 'getAddress': 'FakeServer',
'getState': 'FakeState', 'getState': 'FakeState',
}) })
app.pt = Mock({ 'getCellListForID': (cell, cell, ) }) app.pt = Mock({ 'getCellListForID': (cell, cell, ) })
...@@ -476,7 +476,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -476,7 +476,7 @@ class ClientApplicationTests(NeoTestBase):
'getAddress': ('127.0.0.1', 0), 'getAddress': ('127.0.0.1', 0),
}) })
cell = Mock({ cell = Mock({
'getServer': 'FakeServer', 'getAddress': 'FakeServer',
'getState': 'FakeState', 'getState': 'FakeState',
}) })
app.pt = Mock({ 'getCellListForID': (cell, cell, ) }) app.pt = Mock({ 'getCellListForID': (cell, cell, ) })
...@@ -504,7 +504,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -504,7 +504,7 @@ class ClientApplicationTests(NeoTestBase):
'fakeReceived': packet, 'fakeReceived': packet,
}) })
cell = Mock({ cell = Mock({
'getServer': 'FakeServer', 'getAddress': 'FakeServer',
'getState': 'FakeState', 'getState': 'FakeState',
}) })
app.pt = Mock({ 'getCellListForID': (cell, cell, ) }) app.pt = Mock({ 'getCellListForID': (cell, cell, ) })
...@@ -705,7 +705,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -705,7 +705,7 @@ class ClientApplicationTests(NeoTestBase):
'fakeReceived': ReturnValues(*packets), 'fakeReceived': ReturnValues(*packets),
'getAddress': ('127.0.0.1', 10010), 'getAddress': ('127.0.0.1', 10010),
}) })
cell = Mock({ 'getServer': 'FakeServer', 'getState': 'FakeState', }) cell = Mock({ 'getAddress': 'FakeServer', 'getState': 'FakeState', })
app.pt = Mock({ 'getCellListForID': (cell, ) }) app.pt = Mock({ 'getCellListForID': (cell, ) })
app.cp = Mock({ 'getConnForCell': conn}) app.cp = Mock({ 'getConnForCell': conn})
wrapper = Mock({'tryToResolveConflict': None}) wrapper = Mock({'tryToResolveConflict': None})
...@@ -813,7 +813,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -813,7 +813,7 @@ class ClientApplicationTests(NeoTestBase):
# fourth iteration : connection to primary master succeeded # fourth iteration : connection to primary master succeeded
def _waitMessage5(self, conn=None, msg_id=None, handler=None): def _waitMessage5(self, conn=None, msg_id=None, handler=None):
app.trying_master_node = app.primary_master_node = Mock({ app.trying_master_node = app.primary_master_node = Mock({
'getServer': ('192.168.1.1', 10000), 'getAddress': ('192.168.1.1', 10000),
'__str__': 'Fake master node', '__str__': 'Fake master node',
}) })
Application._waitMessage = _waitMessage6 Application._waitMessage = _waitMessage6
...@@ -825,7 +825,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -825,7 +825,7 @@ class ClientApplicationTests(NeoTestBase):
# second iteration : master node changed # second iteration : master node changed
def _waitMessage3(app, conn=None, msg_id=None, handler=None): def _waitMessage3(app, conn=None, msg_id=None, handler=None):
app.primary_master_node = Mock({ app.primary_master_node = Mock({
'getServer': ('192.168.1.1', 10000), 'getAddress': ('192.168.1.1', 10000),
'__str__': 'Fake master node', '__str__': 'Fake master node',
}) })
Application._waitMessage = _waitMessage4 Application._waitMessage = _waitMessage4
......
...@@ -95,7 +95,7 @@ class ClientHandlerTests(NeoTestBase): ...@@ -95,7 +95,7 @@ class ClientHandlerTests(NeoTestBase):
storage_ip = '127.0.0.1' storage_ip = '127.0.0.1'
storage_port = 10011 storage_port = 10011
fake_storage_node_uuid = self.getNewUUID() fake_storage_node_uuid = self.getNewUUID()
fake_storage_node = Mock({'getUUID': fake_storage_node_uuid, 'getServer': (storage_ip, storage_port), 'getType': STORAGE_NODE_TYPE}) fake_storage_node = Mock({'getUUID': fake_storage_node_uuid, 'getAddress': (storage_ip, storage_port), 'getType': STORAGE_NODE_TYPE})
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()})
...@@ -606,7 +606,7 @@ class ClientHandlerTests(NeoTestBase): ...@@ -606,7 +606,7 @@ class ClientHandlerTests(NeoTestBase):
# Likewise for server address and node uuid. # Likewise for server address and node uuid.
def test_knownStorageNotifyNodeInformation(self): def test_knownStorageNotifyNodeInformation(self):
node = Mock({'setState': None, 'setServer': None}) node = Mock({'setState': None, 'setAddress': 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, getByUUID=node) nm = self._testNotifyNodeInformation(test_node, getByUUID=node)
......
...@@ -48,8 +48,8 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -48,8 +48,8 @@ class MasterClientHandlerTests(NeoTestBase):
self.app.loid = '\0' * 8 self.app.loid = '\0' * 8
self.app.ltid = '\0' * 8 self.app.ltid = '\0' * 8
self.app.finishing_transaction_dict = {} self.app.finishing_transaction_dict = {}
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
self.service = ClientServiceHandler(self.app) self.service = ClientServiceHandler(self.app)
# define some variable to simulate client and storage node # define some variable to simulate client and storage node
self.client_port = 11022 self.client_port = 11022
...@@ -59,7 +59,7 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -59,7 +59,7 @@ class MasterClientHandlerTests(NeoTestBase):
self.client_address = ('127.0.0.1', self.client_port) self.client_address = ('127.0.0.1', self.client_port)
self.storage_address = ('127.0.0.1', self.storage_port) self.storage_address = ('127.0.0.1', self.storage_port)
# register the storage # register the storage
kw = {'uuid':self.getNewUUID(), 'server': self.master_address} kw = {'uuid':self.getNewUUID(), 'address': self.master_address}
self.app.nm.createStorage(**kw) self.app.nm.createStorage(**kw)
def tearDown(self): def tearDown(self):
...@@ -75,7 +75,7 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -75,7 +75,7 @@ class MasterClientHandlerTests(NeoTestBase):
uuid = self.getNewUUID() uuid = self.getNewUUID()
self.app.nm.createFromNodeType( self.app.nm.createFromNodeType(
node_type, node_type,
server=(ip, port), address=(ip, port),
uuid=uuid, uuid=uuid,
state=protocol.RUNNING_STATE, state=protocol.RUNNING_STATE,
) )
...@@ -111,7 +111,7 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -111,7 +111,7 @@ class MasterClientHandlerTests(NeoTestBase):
self.assertEquals(call.getName(), "getUUID") self.assertEquals(call.getName(), "getUUID")
# notify about a known node but with bad address, don't care # notify about a known node but with bad address, don't care
self.app.nm.createStorage( self.app.nm.createStorage(
server=("127.0.0.1", 11011), address=("127.0.0.1", 11011),
uuid=self.getNewUUID(), uuid=self.getNewUUID(),
) )
conn = self.getFakeConnection(uuid, self.storage_address) conn = self.getFakeConnection(uuid, self.storage_address)
......
...@@ -69,13 +69,13 @@ class MasterClientElectionTests(NeoTestBase): ...@@ -69,13 +69,13 @@ class MasterClientElectionTests(NeoTestBase):
self.app.pt.clear() self.app.pt.clear()
self.app.em = Mock({"getConnectionList" : []}) self.app.em = Mock({"getConnectionList" : []})
self.app.finishing_transaction_dict = {} self.app.finishing_transaction_dict = {}
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
self.election = ClientElectionHandler(self.app) self.election = ClientElectionHandler(self.app)
self.app.unconnected_master_node_set = set() self.app.unconnected_master_node_set = set()
self.app.negotiating_master_node_set = set() self.app.negotiating_master_node_set = set()
for node in self.app.nm.getMasterList(): for node in self.app.nm.getMasterList():
self.app.unconnected_master_node_set.add(node.getServer()) self.app.unconnected_master_node_set.add(node.getAddress())
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
# define some variable to simulate client and storage node # define some variable to simulate client and storage node
self.client_port = 11022 self.client_port = 11022
...@@ -96,7 +96,7 @@ class MasterClientElectionTests(NeoTestBase): ...@@ -96,7 +96,7 @@ class MasterClientElectionTests(NeoTestBase):
def identifyToMasterNode(self, port=10000, ip='127.0.0.1'): def identifyToMasterNode(self, port=10000, ip='127.0.0.1'):
uuid = self.getNewUUID() uuid = self.getNewUUID()
address = (ip, port) address = (ip, port)
self.app.nm.createMaster(server=address, uuid=uuid, self.app.nm.createMaster(address=address, uuid=uuid,
state=protocol.RUNNING_STATE) state=protocol.RUNNING_STATE)
return uuid return uuid
...@@ -198,7 +198,7 @@ class MasterClientElectionTests(NeoTestBase): ...@@ -198,7 +198,7 @@ class MasterClientElectionTests(NeoTestBase):
connector_handler = DoNothingConnector) connector_handler = DoNothingConnector)
conn.setUUID(uuid) conn.setUUID(uuid)
p = protocol.askPrimaryMaster() p = protocol.askPrimaryMaster()
self.app.nm.createMaster(server=("127.0.0.1", self.master_port), uuid=uuid) self.app.nm.createMaster(address=("127.0.0.1", self.master_port), uuid=uuid)
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(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1) self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
...@@ -241,7 +241,7 @@ class MasterClientElectionTests(NeoTestBase): ...@@ -241,7 +241,7 @@ class MasterClientElectionTests(NeoTestBase):
connector_handler = DoNothingConnector) connector_handler = DoNothingConnector)
conn.setUUID(uuid) conn.setUUID(uuid)
p = protocol.askPrimaryMaster() p = protocol.askPrimaryMaster()
self.app.nm.createMaster(server=("127.0.0.1", self.master_port), uuid=uuid) self.app.nm.createMaster(address=("127.0.0.1", self.master_port), uuid=uuid)
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(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1) self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
...@@ -270,13 +270,13 @@ class MasterServerElectionTests(NeoTestBase): ...@@ -270,13 +270,13 @@ class MasterServerElectionTests(NeoTestBase):
self.app.pt.clear() self.app.pt.clear()
self.app.em = Mock({"getConnectionList" : []}) self.app.em = Mock({"getConnectionList" : []})
self.app.finishing_transaction_dict = {} self.app.finishing_transaction_dict = {}
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
self.election = ServerElectionHandler(self.app) self.election = ServerElectionHandler(self.app)
self.app.unconnected_master_node_set = set() self.app.unconnected_master_node_set = set()
self.app.negotiating_master_node_set = set() self.app.negotiating_master_node_set = set()
for node in self.app.nm.getMasterList(): for node in self.app.nm.getMasterList():
self.app.unconnected_master_node_set.add(node.getServer()) self.app.unconnected_master_node_set.add(node.getAddress())
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
# define some variable to simulate client and storage node # define some variable to simulate client and storage node
self.client_port = 11022 self.client_port = 11022
...@@ -603,9 +603,9 @@ class MasterServerElectionTests(NeoTestBase): ...@@ -603,9 +603,9 @@ 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 = [(CLIENT_NODE_TYPE, ('127.0.0.1', self.master_port - 1), self.getNewUUID(), DOWN_STATE),] node_list = [(CLIENT_NODE_TYPE, ('127.0.0.1', self.master_port - 1), self.getNewUUID(), DOWN_STATE),]
self.assertEqual(len(self.app.nm.getClientNodeList()), 0) self.assertEqual(len(self.app.nm.getNodeList()), 0)
election.handleNotifyNodeInformation(conn, packet, node_list) election.handleNotifyNodeInformation(conn, packet, node_list)
self.assertEqual(len(self.app.nm.getClientNodeList()), 0) self.assertEqual(len(self.app.nm.getNodeList()), 0)
# tell about another master node # tell about another master node
conn = Mock({"getUUID" : uuid, conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.master_port)}) "getAddress" : ("127.0.0.1", self.master_port)})
...@@ -615,14 +615,14 @@ class MasterServerElectionTests(NeoTestBase): ...@@ -615,14 +615,14 @@ class MasterServerElectionTests(NeoTestBase):
election.handleNotifyNodeInformation(conn, packet, node_list) election.handleNotifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getByAddress(("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.getAddress(), ("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.getByAddress(("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.getAddress(), ("127.0.0.1", self.master_port+1))
self.assertEqual(node.getState(), DOWN_STATE) self.assertEqual(node.getState(), DOWN_STATE)
......
...@@ -105,7 +105,7 @@ class MasterAppTests(NeoTestBase): ...@@ -105,7 +105,7 @@ class MasterAppTests(NeoTestBase):
self.app.em = Mock({"getConnectionList" : (master_conn, storage_conn, client_conn)}) self.app.em = Mock({"getConnectionList" : (master_conn, storage_conn, client_conn)})
s_node = self.app.nm.createClient( s_node = self.app.nm.createClient(
uuid = self.getNewUUID(), uuid = self.getNewUUID(),
server=("127.1.0.1", 3361) address=("127.1.0.1", 3361)
) )
self.app.broadcastNodeInformation(c_node) self.app.broadcastNodeInformation(c_node)
# check conn # check conn
...@@ -120,7 +120,7 @@ class MasterAppTests(NeoTestBase): ...@@ -120,7 +120,7 @@ class MasterAppTests(NeoTestBase):
self.app.em = Mock({"getConnectionList" : (master_conn, storage_conn, client_conn)}) self.app.em = Mock({"getConnectionList" : (master_conn, storage_conn, client_conn)})
s_node = self.app.nm.createStorage( s_node = self.app.nm.createStorage(
uuid=self.getNewUUID(), uuid=self.getNewUUID(),
server=("127.0.0.1", 1351) address=("127.0.0.1", 1351)
) )
self.app.broadcastNodeInformation(s_node) self.app.broadcastNodeInformation(s_node)
......
...@@ -58,13 +58,13 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -58,13 +58,13 @@ class MasterRecoveryTests(NeoTestBase):
self.app = Application(**config) self.app = Application(**config)
self.app.pt.clear() self.app.pt.clear()
self.app.finishing_transaction_dict = {} self.app.finishing_transaction_dict = {}
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
self.recovery = RecoveryHandler(self.app) self.recovery = RecoveryHandler(self.app)
self.app.unconnected_master_node_set = set() self.app.unconnected_master_node_set = set()
self.app.negotiating_master_node_set = set() self.app.negotiating_master_node_set = set()
for node in self.app.nm.getMasterList(): for node in self.app.nm.getMasterList():
self.app.unconnected_master_node_set.add(node.getServer()) self.app.unconnected_master_node_set.add(node.getAddress())
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
# define some variable to simulate client and storage node # define some variable to simulate client and storage node
...@@ -118,9 +118,9 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -118,9 +118,9 @@ class MasterRecoveryTests(NeoTestBase):
# tell about a client node, do nothing # tell about a client node, do nothing
conn = self.getFakeConnection(uuid, self.master_address) conn = self.getFakeConnection(uuid, self.master_address)
node_list = [(CLIENT_NODE_TYPE, '127.0.0.1', self.client_port, self.getNewUUID(), DOWN_STATE),] node_list = [(CLIENT_NODE_TYPE, '127.0.0.1', self.client_port, self.getNewUUID(), DOWN_STATE),]
self.assertEqual(len(self.app.nm.getClientNodeList()), 0) self.assertEqual(len(self.app.nm.getNodeList()), 0)
recovery.handleNotifyNodeInformation(conn, packet, node_list) recovery.handleNotifyNodeInformation(conn, packet, node_list)
self.assertEqual(len(self.app.nm.getClientNodeList()), 0) self.assertEqual(len(self.app.nm.getNodeList()), 0)
# 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)
......
...@@ -46,8 +46,8 @@ class MasterStorageHandlerTests(NeoTestBase): ...@@ -46,8 +46,8 @@ class MasterStorageHandlerTests(NeoTestBase):
self.app.pt.setID(pack('!Q', 1)) self.app.pt.setID(pack('!Q', 1))
self.app.em = Mock({"getConnectionList" : []}) self.app.em = Mock({"getConnectionList" : []})
self.app.finishing_transaction_dict = {} self.app.finishing_transaction_dict = {}
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
self.service = StorageServiceHandler(self.app) self.service = StorageServiceHandler(self.app)
# define some variable to simulate client and storage node # define some variable to simulate client and storage node
self.client_port = 11022 self.client_port = 11022
...@@ -101,7 +101,7 @@ class MasterStorageHandlerTests(NeoTestBase): ...@@ -101,7 +101,7 @@ class MasterStorageHandlerTests(NeoTestBase):
self.assertEquals(call.getName(), "getUUID") self.assertEquals(call.getName(), "getUUID")
# notify about a known node but with bad address, don't care # notify about a known node but with bad address, don't care
self.app.nm.createStorage( self.app.nm.createStorage(
server=("127.0.0.1", 11011), address=("127.0.0.1", 11011),
uuid=self.getNewUUID(), uuid=self.getNewUUID(),
) )
conn = self.getFakeConnection(uuid, self.storage_address) conn = self.getFakeConnection(uuid, self.storage_address)
......
...@@ -46,8 +46,8 @@ class MasterVerificationTests(NeoTestBase): ...@@ -46,8 +46,8 @@ class MasterVerificationTests(NeoTestBase):
self.app = Application(**config) self.app = Application(**config)
self.app.pt.clear() self.app.pt.clear()
self.app.finishing_transaction_dict = {} self.app.finishing_transaction_dict = {}
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
self.verification = VerificationHandler(self.app) self.verification = VerificationHandler(self.app)
self.app.unconnected_master_node_set = set() self.app.unconnected_master_node_set = set()
self.app.negotiating_master_node_set = set() self.app.negotiating_master_node_set = set()
...@@ -56,7 +56,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -56,7 +56,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.loid = '\0' * 8 self.app.loid = '\0' * 8
self.app.ltid = '\0' * 8 self.app.ltid = '\0' * 8
for node in self.app.nm.getMasterList(): for node in self.app.nm.getMasterList():
self.app.unconnected_master_node_set.add(node.getServer()) self.app.unconnected_master_node_set.add(node.getAddress())
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
# define some variable to simulate client and storage node # define some variable to simulate client and storage node
...@@ -80,7 +80,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -80,7 +80,7 @@ class MasterVerificationTests(NeoTestBase):
uuid = self.getNewUUID() uuid = self.getNewUUID()
self.app.nm.createFromNodeType( self.app.nm.createFromNodeType(
node_type, node_type,
server=(ip, port), address=(ip, port),
uuid=uuid, uuid=uuid,
) )
return uuid return uuid
......
...@@ -51,8 +51,8 @@ class StorageClientHandlerTests(NeoTestBase): ...@@ -51,8 +51,8 @@ class StorageClientHandlerTests(NeoTestBase):
self.app.store_lock_dict = {} self.app.store_lock_dict = {}
self.app.load_lock_dict = {} self.app.load_lock_dict = {}
self.app.event_queue = deque() self.app.event_queue = deque()
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
# handler # handler
self.operation = ClientOperationHandler(self.app) self.operation = ClientOperationHandler(self.app)
# set pmn # set pmn
...@@ -89,7 +89,7 @@ class StorageClientHandlerTests(NeoTestBase): ...@@ -89,7 +89,7 @@ class StorageClientHandlerTests(NeoTestBase):
uuid = self.getNewUUID() uuid = self.getNewUUID()
client = self.app.nm.createClient( client = self.app.nm.createClient(
uuid=uuid, uuid=uuid,
server=('127.0.0.1', 10010) address=('127.0.0.1', 10010)
) )
self.app.store_lock_dict[0] = object() self.app.store_lock_dict[0] = object()
transaction = Mock({ transaction = Mock({
......
...@@ -50,8 +50,8 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -50,8 +50,8 @@ class StorageMasterHandlerTests(NeoTestBase):
self.app.store_lock_dict = {} self.app.store_lock_dict = {}
self.app.load_lock_dict = {} self.app.load_lock_dict = {}
self.app.event_queue = deque() self.app.event_queue = deque()
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
# handler # handler
self.operation = MasterOperationHandler(self.app) self.operation = MasterOperationHandler(self.app)
# set pmn # set pmn
......
...@@ -48,8 +48,8 @@ class StorageStorageHandlerTests(NeoTestBase): ...@@ -48,8 +48,8 @@ class StorageStorageHandlerTests(NeoTestBase):
self.app.store_lock_dict = {} self.app.store_lock_dict = {}
self.app.load_lock_dict = {} self.app.load_lock_dict = {}
self.app.event_queue = deque() self.app.event_queue = deque()
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
# handler # handler
self.operation = StorageOperationHandler(self.app) self.operation = StorageOperationHandler(self.app)
# set pmn # set pmn
......
...@@ -162,7 +162,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -162,7 +162,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
# try to get known offset # try to get known offset
node = self.app.nm.createStorage( node = self.app.nm.createStorage(
server=("127.7.9.9", 1), address=("127.7.9.9", 1),
uuid=self.getNewUUID() uuid=self.getNewUUID()
) )
self.app.pt.setCell(1, node, UP_TO_DATE_STATE) self.app.pt.setCell(1, node, UP_TO_DATE_STATE)
......
...@@ -37,8 +37,8 @@ class BootstrapManagerTests(NeoTestBase): ...@@ -37,8 +37,8 @@ class BootstrapManagerTests(NeoTestBase):
# create an application object # create an application object
config = self.getStorageConfiguration() config = self.getStorageConfiguration()
self.app = Application(**config) self.app = Application(**config)
for server in self.app.master_node_list: for address in self.app.master_node_list:
self.app.nm.createMaster(server=server) self.app.nm.createMaster(address=address)
self.bootstrap = BootstrapManager(self.app, 'main', protocol.STORAGE_NODE_TYPE) self.bootstrap = BootstrapManager(self.app, 'main', protocol.STORAGE_NODE_TYPE)
# define some variable to simulate client and storage node # define some variable to simulate client and storage node
self.master_port = 10010 self.master_port = 10010
......
...@@ -43,11 +43,11 @@ class NodesTests(NeoTestBase): ...@@ -43,11 +43,11 @@ class NodesTests(NeoTestBase):
def testInit(self): def testInit(self):
""" Check the node initialization """ """ Check the node initialization """
server = ('127.0.0.1', 10000) address = ('127.0.0.1', 10000)
uuid = self.getNewUUID() uuid = self.getNewUUID()
node = Node(self.manager, server=server, uuid=uuid) node = Node(self.manager, address=address, uuid=uuid)
self.assertEqual(node.getState(), protocol.UNKNOWN_STATE) self.assertEqual(node.getState(), protocol.UNKNOWN_STATE)
self.assertEqual(node.getServer(), server) self.assertEqual(node.getAddress(), address)
self.assertEqual(node.getUUID(), uuid) self.assertEqual(node.getUUID(), uuid)
self.assertTrue(time() - 1 < node.getLastStateChange() < time()) self.assertTrue(time() - 1 < node.getLastStateChange() < time())
...@@ -62,18 +62,18 @@ class NodesTests(NeoTestBase): ...@@ -62,18 +62,18 @@ class NodesTests(NeoTestBase):
self.assertTrue(previous_time < node.getLastStateChange()) self.assertTrue(previous_time < node.getLastStateChange())
self.assertTrue(time() - 1 < node.getLastStateChange() < time()) self.assertTrue(time() - 1 < node.getLastStateChange() < time())
def testServer(self): def testAddress(self):
""" Check if the node is indexed by server """ """ Check if the node is indexed by address """
node = Node(self.manager) node = Node(self.manager)
self.assertEqual(node.getServer(), None) self.assertEqual(node.getAddress(), None)
server = ('127.0.0.1', 10000) address = ('127.0.0.1', 10000)
node.setServer(server) node.setAddress(address)
self._updatedByAddress(node) self._updatedByAddress(node)
def testUUID(self): def testUUID(self):
""" As for Server but UUID """ """ As for Address but UUID """
node = Node(self.manager) node = Node(self.manager)
self.assertEqual(node.getServer(), None) self.assertEqual(node.getAddress(), None)
uuid = self.getNewUUID() uuid = self.getNewUUID()
node.setUUID(uuid) node.setUUID(uuid)
self._updatedByUUID(node) self._updatedByUUID(node)
...@@ -150,7 +150,7 @@ class NodeManagerTests(NeoTestBase): ...@@ -150,7 +150,7 @@ class NodeManagerTests(NeoTestBase):
self.assertEqual(manager.getClientList(), client_list) self.assertEqual(manager.getClientList(), client_list)
def checkByServer(self, node): def checkByServer(self, node):
node_found = self.manager.getByAddress(node.getServer()) node_found = self.manager.getByAddress(node.getAddress())
self.assertEqual(node_found, node) self.assertEqual(node_found, node)
def checkByUUID(self, node): def checkByUUID(self, node):
...@@ -164,8 +164,8 @@ class NodeManagerTests(NeoTestBase): ...@@ -164,8 +164,8 @@ class NodeManagerTests(NeoTestBase):
self.checkMasters([]) self.checkMasters([])
self.checkStorages([]) self.checkStorages([])
self.checkClients([]) self.checkClients([])
server = ('127.0.0.1', 10000) address = ('127.0.0.1', 10000)
self.assertEqual(manager.getByAddress(server), None) self.assertEqual(manager.getByAddress(address), None)
self.assertEqual(manager.getByAddress(None), None) self.assertEqual(manager.getByAddress(None), None)
uuid = self.getNewUUID() uuid = self.getNewUUID()
self.assertEqual(manager.getByUUID(uuid), None) self.assertEqual(manager.getByUUID(uuid), None)
...@@ -197,8 +197,8 @@ class NodeManagerTests(NeoTestBase): ...@@ -197,8 +197,8 @@ class NodeManagerTests(NeoTestBase):
self.checkStorages([self.storage]) self.checkStorages([self.storage])
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 address
self.assertEqual(manager.getByAddress(self.client.getServer()), None) self.assertEqual(manager.getByAddress(self.client.getAddress()), None)
self.checkByUUID(self.client) self.checkByUUID(self.client)
# admin # admin
manager.add(self.admin) manager.add(self.admin)
...@@ -245,14 +245,14 @@ class NodeManagerTests(NeoTestBase): ...@@ -245,14 +245,14 @@ class NodeManagerTests(NeoTestBase):
self.checkStorages([self.storage]) self.checkStorages([self.storage])
self.checkClients([self.client]) self.checkClients([self.client])
# build changes # build changes
old_address = self.master.getServer() old_address = self.master.getAddress()
new_address = ('127.0.0.1', 2001) new_address = ('127.0.0.1', 2001)
new_uuid = self.getNewUUID() new_uuid = self.getNewUUID()
node_list = ( node_list = (
(CLIENT_NODE_TYPE, None, self.client.getUUID(), DOWN_STATE), (CLIENT_NODE_TYPE, None, self.client.getUUID(), DOWN_STATE),
(MASTER_NODE_TYPE, new_address, self.master.getUUID(), RUNNING_STATE), (MASTER_NODE_TYPE, new_address, self.master.getUUID(), RUNNING_STATE),
(STORAGE_NODE_TYPE, self.storage.getServer(), new_uuid, RUNNING_STATE), (STORAGE_NODE_TYPE, self.storage.getAddress(), new_uuid, RUNNING_STATE),
(ADMIN_NODE_TYPE, self.admin.getServer(), self.admin.getUUID(), UNKNOWN_STATE), (ADMIN_NODE_TYPE, self.admin.getAddress(), self.admin.getUUID(), UNKNOWN_STATE),
) )
# update manager content # update manager content
manager.update(node_list) manager.update(node_list)
...@@ -261,7 +261,7 @@ class NodeManagerTests(NeoTestBase): ...@@ -261,7 +261,7 @@ class NodeManagerTests(NeoTestBase):
# - master change it's address # - master change it's address
self.checkMasters([self.master]) self.checkMasters([self.master])
self.assertEqual(manager.getByAddress(old_address), None) self.assertEqual(manager.getByAddress(old_address), None)
self.master.setServer(new_address) self.master.setAddress(new_address)
self.checkByServer(self.master) self.checkByServer(self.master)
# a new storage replaced the old one # a new storage replaced the old one
self.assertNotEqual(manager.getStorageList(), [self.storage]) self.assertNotEqual(manager.getStorageList(), [self.storage])
......
...@@ -41,7 +41,7 @@ class PartitionTableTests(NeoTestBase): ...@@ -41,7 +41,7 @@ class PartitionTableTests(NeoTestBase):
self.assertEquals(cell.getState(), OUT_OF_DATE_STATE) self.assertEquals(cell.getState(), OUT_OF_DATE_STATE)
self.assertEquals(cell.getNodeState(), UNKNOWN_STATE) self.assertEquals(cell.getNodeState(), UNKNOWN_STATE)
self.assertEquals(cell.getUUID(), uuid) self.assertEquals(cell.getUUID(), uuid)
self.assertEquals(cell.getServer(), server) self.assertEquals(cell.getAddress(), server)
# check state setter # check state setter
cell.setState(FEEDING_STATE) cell.setState(FEEDING_STATE)
self.assertEquals(cell.getState(), FEEDING_STATE) self.assertEquals(cell.getState(), FEEDING_STATE)
......
...@@ -85,9 +85,9 @@ def parseMasterList(masters, except_node=None): ...@@ -85,9 +85,9 @@ def parseMasterList(masters, except_node=None):
master_node_list = [] master_node_list = []
for node in masters.split('/'): for node in masters.split('/'):
ip_address, port = node.split(':') ip_address, port = node.split(':')
server = (ip_address, int(port)) address = (ip_address, int(port))
if (server != except_node): if (address != except_node):
master_node_list.append(server) master_node_list.append(address)
return master_node_list return master_node_list
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