Commit 3dc40dc6 authored by Vincent Pelletier's avatar Vincent Pelletier

Factorise code.

For easier understanding of answerLastIDs' final else block.
parent 142ad156
...@@ -110,6 +110,12 @@ class RecoveryManager(MasterHandler): ...@@ -110,6 +110,12 @@ class RecoveryManager(MasterHandler):
# ask the last IDs to perform the recovery # ask the last IDs to perform the recovery
conn.ask(Packets.AskLastIDs()) conn.ask(Packets.AskLastIDs())
def _lastIDsCompleted(self, conn):
node = self.app.nm.getByUUID(conn.getUUID())
assert node.isPending()
node.setRunning()
self.app.broadcastNodesInformation([node])
def answerLastIDs(self, conn, loid, ltid, lptid): def answerLastIDs(self, conn, loid, ltid, lptid):
# Get max values. # Get max values.
if loid is not None: if loid is not None:
...@@ -121,22 +127,16 @@ class RecoveryManager(MasterHandler): ...@@ -121,22 +127,16 @@ class RecoveryManager(MasterHandler):
self.target_ptid = lptid self.target_ptid = lptid
conn.ask(Packets.AskPartitionTable()) conn.ask(Packets.AskPartitionTable())
else: else:
node = self.app.nm.getByUUID(conn.getUUID()) self._lastIDsCompleted(conn)
assert node.isPending()
node.setRunning()
self.app.broadcastNodesInformation([node])
def answerPartitionTable(self, conn, ptid, row_list): def answerPartitionTable(self, conn, ptid, row_list):
node = self.app.nm.getByUUID(conn.getUUID())
assert node.isPending()
node.setRunning()
if ptid != self.target_ptid: if ptid != self.target_ptid:
# If this is not from a target node, ignore it. # If this is not from a target node, ignore it.
neo.lib.logging.warn('Got %s while waiting %s', dump(ptid), neo.lib.logging.warn('Got %s while waiting %s', dump(ptid),
dump(self.target_ptid)) dump(self.target_ptid))
else: else:
self._broadcastPartitionTable(ptid, row_list) self._broadcastPartitionTable(ptid, row_list)
self.app.broadcastNodesInformation([node]) self._lastIDsCompleted(conn)
def _broadcastPartitionTable(self, ptid, row_list): def _broadcastPartitionTable(self, ptid, row_list):
try: try:
......
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