Commit 225a11ce authored by Grégory Wisniewski's avatar Grégory Wisniewski

Factorize logic when a node is lost from the admin node.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@829 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c6b0a934
......@@ -144,62 +144,28 @@ class MasterBaseEventHandler(EventHandler):
conn.ask(protocol.askPrimaryMaster())
EventHandler.connectionCompleted(self, conn)
def connectionFailed(self, conn):
def _connectionLost(self, conn):
app = self.app
if app.primary_master_node and conn.getUUID() == app.primary_master_node.getUUID():
raise PrimaryFailure
if app.trying_master_node is None:
# Should not happen.
raise RuntimeError('connection failed while not trying to connect')
if app.trying_master_node is app.primary_master_node:
# Tried to connect to a primary master node and failed.
# So this would effectively mean that it is dead.
app.primary_master_node = None
app.trying_master_node = None
def connectionFailed(self, conn):
self._connectionLost(conn)
EventHandler.connectionFailed(self, conn)
def timeoutExpired(self, conn):
app = self.app
if app.primary_master_node and conn.getUUID() == app.primary_master_node.getUUID():
raise PrimaryFailure
if app.trying_master_node is app.primary_master_node:
# If a primary master node timeouts, I should not rely on it.
app.primary_master_node = None
app.trying_master_node = None
self._connectionLost(conn)
EventHandler.timeoutExpired(self, conn)
def connectionClosed(self, conn):
app = self.app
if app.primary_master_node and conn.getUUID() == app.primary_master_node.getUUID():
raise PrimaryFailure
if app.trying_master_node is app.primary_master_node:
# If a primary master node closes, I should not rely on it.
app.primary_master_node = None
app.trying_master_node = None
self._connectionLost(conn)
EventHandler.connectionClosed(self, conn)
def peerBroken(self, conn):
app = self.app
if app.primary_master_node and conn.getUUID() == app.primary_master_node.getUUID():
raise PrimaryFailure
if app.trying_master_node is app.primary_master_node:
# If a primary master node gets broken, I should not rely
# on it.
app.primary_master_node = None
app.trying_master_node = None
self._connectionLost(conn)
EventHandler.peerBroken(self, conn)
@decorators.identification_required
......
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