Commit a72ddfb3 by Julien Muchembled

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.
1 parent 6f6d071d
......@@ -34,18 +34,18 @@ class Application(object):
# Internal attributes.
self.em = EventManager()
self.nm = NodeManager(config.getDynamicMasterList())
for address in config.getMasters():
self.nm.createMaster(address=address)
self.name = config.getCluster()
self.server = config.getBind()
self.master_addresses = config.getMasters()
logging.debug('IP address is %s, port is %d', *self.server)
# The partition table is initialized after getting the number of
# partitions.
self.pt = None
self.uuid = config.getUUID()
self.primary_master_node = None
self.request_handler = MasterRequestEventHandler(self)
self.master_event_handler = MasterEventHandler(self)
self.cluster_state = None
......@@ -105,22 +105,14 @@ class Application(object):
the attempt of a connection periodically.
Note that I do not accept any connection from non-master nodes
at this stage."""
nm = self.nm
nm.init()
at this stage.
"""
self.cluster_state = None
for address in self.master_addresses:
self.nm.createMaster(address=address)
# search, find, connect and identify to the primary master
bootstrap = BootstrapManager(self, self.name, NodeTypes.ADMIN,
self.uuid, self.server)
data = bootstrap.getPrimaryConnection()
(node, conn, uuid, num_partitions, num_replicas) = data
nm.update([(node.getType(), node.getAddress(), node.getUUID(),
NodeStates.RUNNING)])
self.master_node = node
self.master_conn = conn
self.uuid = uuid
......
......@@ -556,13 +556,6 @@ class NodeManager(object):
def createFromNodeType(self, 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):
for node_type, addr, uuid, state in node_list:
# This should be done here (although klass might not be used in this
......
......@@ -97,6 +97,12 @@ class MasterTests(NEOFunctionalTest):
# Stop the cluster (so we can start processes manually)
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.
first_master = master_list[0]
first_master.start()
......
......@@ -222,29 +222,6 @@ class NodeManagerTests(NeoUnitTestBase):
self.checkByServer(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):
""" Check manager content update """
# set up four nodes
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!