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