Commit 968cd132 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Move wait|announce primary code at the beginning of the related methods.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1506 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 14078395
...@@ -154,14 +154,7 @@ class Application(object): ...@@ -154,14 +154,7 @@ class Application(object):
self.primary = None self.primary = None
self.primary_master_node = None self.primary_master_node = None
self._doElection(bootstrap) self._doElection(bootstrap)
self.primary = self.primary is None self.primary = self.primary is None
if self.primary:
# i'm the primary, send the announcement
self._announcePrimary()
else:
# otherwise, wait for the primary announcement
self._waitForPrimaryAnnouncement()
break break
except ElectionFailure, m: except ElectionFailure, m:
# something goes wrong, clean then restart # something goes wrong, clean then restart
...@@ -606,6 +599,8 @@ class Application(object): ...@@ -606,6 +599,8 @@ class Application(object):
logging.info('play the primary role with %s (%s:%d)', logging.info('play the primary role with %s (%s:%d)',
dump(self.uuid), *(self.server)) dump(self.uuid), *(self.server))
# i'm the primary, send the announcement
self._announcePrimary()
# all incoming connections identify through this handler # all incoming connections identify through this handler
self.listening_conn.setHandler( self.listening_conn.setHandler(
identification.IdentificationHandler(self)) identification.IdentificationHandler(self))
...@@ -647,6 +642,8 @@ class Application(object): ...@@ -647,6 +642,8 @@ class Application(object):
logging.info('play the secondary role with %s (%s:%d)', logging.info('play the secondary role with %s (%s:%d)',
dump(self.uuid), *(self.server)) dump(self.uuid), *(self.server))
# otherwise, wait for the primary announcement
self._waitForPrimaryAnnouncement()
# apply the new handler to the primary connection # apply the new handler to the primary connection
client_list = self.em.getClientList() client_list = self.em.getClientList()
......
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