Commit b43bf3b9 authored by Vincent Pelletier's avatar Vincent Pelletier

Exit election loop when we know we are not the primary.

Expect AcceptnodeIdentification message in secondary handler connected to primary master. It will be received just once (upon election state exit).


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@742 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 18e4cdc5
......@@ -177,8 +177,9 @@ class Application(object):
for addr in list(self.unconnected_master_node_set):
ClientConnection(em, client_handler, addr = addr,
connector_handler = self.connector_handler)
if len(self.unconnected_master_node_set) == 0 \
and len(self.negotiating_master_node_set) == 0:
if (len(self.unconnected_master_node_set) == 0 \
and len(self.negotiating_master_node_set) == 0) \
or self.primary is not None:
break
# Now there are three situations:
......
......@@ -99,3 +99,19 @@ class PrimaryMasterEventHandler(MasterEventHandler):
# told me at the moment.
if n.getUUID() is None:
n.setUUID(uuid)
def handleAcceptNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, num_partitions,
num_replicas, your_uuid):
app = self.app
node = app.nm.getNodeByServer(conn.getAddress())
assert node_type == MASTER_NODE_TYPE
assert conn.getAddress() == (ip_address, port)
if your_uuid != app.uuid:
# uuid conflict happened, accept the new one
app.uuid = your_uuid
conn.setUUID(uuid)
node.setUUID(uuid)
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