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