Commit 9552321b authored by Grégory Wisniewski's avatar Grégory Wisniewski

Implement master-dedicated PartitionTable.load() method.

A master load a partition table from the network only during recovery, this
operation requires a different behaviour than the load() for other nodes.
Check incoming data and raise before any change on the partition table to
avoid inconsistency between ptid and partition table data.

git-svn-id: 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 94248a81
......@@ -104,6 +104,28 @@ class PartitionTable(
return cell_list
def load(self, ptid, row_list, nm):
Load a partition table from a storage node during the recovery.
Return the new storage nodes registered
# check offsets
for offset, _row in row_list:
if offset >= self.getPartitions():
raise IndexError, offset
# store the partition table
self.clear() = ptid
new_nodes = []
for offset, row in row_list:
for uuid, state in row:
node = nm.getByUUID(uuid)
if node is None:
node = nm.createStorage(uuid=uuid)
self.setCell(offset, node, state)
return new_nodes
def addNode(self, node):
"""Add a node. Take it into account that it might not be really a new
node. The strategy is, if a row does not contain a good number of
......@@ -136,22 +136,12 @@ class RecoveryManager(MasterHandler):
logging.warn('Got %s while waiting %s', dump(ptid),
# load unknown storage nodes
new_nodes = []
for _offset, row in row_list:
for uuid, _state in row:
node = app.nm.getByUUID(uuid)
if node is None:
# notify about new nodes
if new_nodes:
# load partition in memory
try:, row_list,
new_nodes =, row_list,
except IndexError:
raise ProtocolError('Invalid offset')
# notify the admin nodes
for node in
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