Commit a72ddfb3 authored by Julien Muchembled's avatar Julien Muchembled

admin: do not reset the list of known masters from configuration (or command...

admin: do not reset the list of known masters from configuration (or command line) when reconnecting

This is questionable but a lot of NodeManager must be reviewed if we want to do
differently. At least, admin nodes now behave like clients.
parent 6f6d071d
...@@ -34,18 +34,18 @@ class Application(object): ...@@ -34,18 +34,18 @@ class Application(object):
# Internal attributes. # Internal attributes.
self.em = EventManager() self.em = EventManager()
self.nm = NodeManager(config.getDynamicMasterList()) self.nm = NodeManager(config.getDynamicMasterList())
for address in config.getMasters():
self.nm.createMaster(address=address)
self.name = config.getCluster() self.name = config.getCluster()
self.server = config.getBind() self.server = config.getBind()
self.master_addresses = config.getMasters()
logging.debug('IP address is %s, port is %d', *self.server) logging.debug('IP address is %s, port is %d', *self.server)
# The partition table is initialized after getting the number of # The partition table is initialized after getting the number of
# partitions. # partitions.
self.pt = None self.pt = None
self.uuid = config.getUUID() self.uuid = config.getUUID()
self.primary_master_node = None
self.request_handler = MasterRequestEventHandler(self) self.request_handler = MasterRequestEventHandler(self)
self.master_event_handler = MasterEventHandler(self) self.master_event_handler = MasterEventHandler(self)
self.cluster_state = None self.cluster_state = None
...@@ -105,22 +105,14 @@ class Application(object): ...@@ -105,22 +105,14 @@ class Application(object):
the attempt of a connection periodically. the attempt of a connection periodically.
Note that I do not accept any connection from non-master nodes Note that I do not accept any connection from non-master nodes
at this stage.""" at this stage.
"""
nm = self.nm
nm.init()
self.cluster_state = None self.cluster_state = None
for address in self.master_addresses:
self.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, NodeTypes.ADMIN, bootstrap = BootstrapManager(self, self.name, NodeTypes.ADMIN,
self.uuid, self.server) self.uuid, self.server)
data = bootstrap.getPrimaryConnection() data = bootstrap.getPrimaryConnection()
(node, conn, uuid, num_partitions, num_replicas) = data (node, conn, uuid, num_partitions, num_replicas) = data
nm.update([(node.getType(), node.getAddress(), node.getUUID(),
NodeStates.RUNNING)])
self.master_node = node self.master_node = node
self.master_conn = conn self.master_conn = conn
self.uuid = uuid self.uuid = uuid
......
...@@ -556,13 +556,6 @@ class NodeManager(object): ...@@ -556,13 +556,6 @@ class NodeManager(object):
def createFromNodeType(self, node_type, **kw): def createFromNodeType(self, node_type, **kw):
return self._createNode(self._getClassFromNodeType(node_type), **kw) return self._createNode(self._getClassFromNodeType(node_type), **kw)
def init(self):
self._node_set.clear()
self._type_dict.clear()
self._state_dict.clear()
self._uuid_dict.clear()
self._address_dict.clear()
def update(self, node_list): def update(self, node_list):
for node_type, addr, uuid, state in node_list: for node_type, addr, uuid, state in node_list:
# This should be done here (although klass might not be used in this # This should be done here (although klass might not be used in this
......
...@@ -97,6 +97,12 @@ class MasterTests(NEOFunctionalTest): ...@@ -97,6 +97,12 @@ class MasterTests(NEOFunctionalTest):
# Stop the cluster (so we can start processes manually) # Stop the cluster (so we can start processes manually)
self.neo.killMasters() self.neo.killMasters()
# Restart admin to make sure it knows all masters.
admin, = self.neo.getAdminProcessList()
admin.kill()
admin.wait()
admin.start()
# Start the first master. # Start the first master.
first_master = master_list[0] first_master = master_list[0]
first_master.start() first_master.start()
......
...@@ -222,29 +222,6 @@ class NodeManagerTests(NeoUnitTestBase): ...@@ -222,29 +222,6 @@ class NodeManagerTests(NeoUnitTestBase):
self.checkByServer(self.admin) self.checkByServer(self.admin)
self.checkByUUID(self.admin) self.checkByUUID(self.admin)
def testReInit(self):
""" Check that the manager clear all its content """
manager = self.manager
self.checkNodes([])
self.checkStorages([])
self.checkMasters([])
self.checkClients([])
self._addMaster()
self.checkMasters([self.master])
manager.init()
self.checkNodes([])
self.checkMasters([])
self._addStorage()
self.checkStorages([self.storage])
manager.init()
self.checkNodes([])
self.checkStorages([])
self._addClient()
self.checkClients([self.client])
manager.init()
self.checkNodes([])
self.checkClients([])
def testUpdate(self): def testUpdate(self):
""" Check manager content update """ """ Check manager content update """
# set up four nodes # set up four nodes
......
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