Commit 88d76044 authored by Vincent Pelletier's avatar Vincent Pelletier

Don't depend on connection's uuid to detect primary connection.

parent 0c408964
...@@ -263,7 +263,6 @@ class Application(object): ...@@ -263,7 +263,6 @@ class Application(object):
try: try:
self.new_oid_list = [] self.new_oid_list = []
result = self._connectToPrimaryNode() result = self._connectToPrimaryNode()
self.master_conn = result
finally: finally:
self._connecting_to_master_node_release() self._connecting_to_master_node_release()
return result return result
...@@ -347,7 +346,8 @@ class Application(object): ...@@ -347,7 +346,8 @@ class Application(object):
# Identify to primary master and request initial data # Identify to primary master and request initial data
p = Packets.RequestIdentification(NodeTypes.CLIENT, self.uuid, None, p = Packets.RequestIdentification(NodeTypes.CLIENT, self.uuid, None,
self.name) self.name)
while conn.getUUID() is None: assert self.master_conn is None, self.master_conn
while self.master_conn is None:
ask(conn, p, handler=handler) ask(conn, p, handler=handler)
if conn.getUUID() is None: if conn.getUUID() is None:
# Node identification was refused by master, it is considered # Node identification was refused by master, it is considered
......
...@@ -49,6 +49,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler): ...@@ -49,6 +49,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
# Always create partition table # Always create partition table
app.pt = PartitionTable(num_partitions, num_replicas) app.pt = PartitionTable(num_partitions, num_replicas)
app.master_conn = conn
def answerPrimary(self, conn, primary_uuid, def answerPrimary(self, conn, primary_uuid,
known_master_list): known_master_list):
......
...@@ -29,6 +29,7 @@ class BootstrapManager(EventHandler): ...@@ -29,6 +29,7 @@ class BootstrapManager(EventHandler):
""" """
Manage the bootstrap stage, lookup for the primary master then connect to it Manage the bootstrap stage, lookup for the primary master then connect to it
""" """
accepted = False
def __init__(self, app, name, node_type, uuid=None, server=NO_SERVER): def __init__(self, app, name, node_type, uuid=None, server=NO_SERVER):
""" """
...@@ -119,6 +120,7 @@ class BootstrapManager(EventHandler): ...@@ -119,6 +120,7 @@ class BootstrapManager(EventHandler):
self.uuid = your_uuid self.uuid = your_uuid
neo.lib.logging.info('Got a new UUID : %s' % dump(self.uuid)) neo.lib.logging.info('Got a new UUID : %s' % dump(self.uuid))
conn.setUUID(uuid) conn.setUUID(uuid)
self.accepted = True
def getPrimaryConnection(self, connector_handler): def getPrimaryConnection(self, connector_handler):
""" """
...@@ -131,7 +133,7 @@ class BootstrapManager(EventHandler): ...@@ -131,7 +133,7 @@ class BootstrapManager(EventHandler):
self.current = nm.getMasterList()[0] self.current = nm.getMasterList()[0]
conn = None conn = None
# retry until identified to the primary # retry until identified to the primary
while self.primary is None or conn.getUUID() != self.primary.getUUID(): while not self.accepted:
if self.current is None: if self.current is None:
# conn closed # conn closed
conn = None conn = None
......
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