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: https://svn.erp5.org/repos/neo/trunk@2091 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 94248a81
......@@ -104,6 +104,28 @@ class PartitionTable(neo.pt.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()
self.id = 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)
new_nodes.append(node)
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),
dump(self.target_ptid))
return
# 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:
new_nodes.append(app.nm.createStorage(uuid=uuid))
# notify about new nodes
if new_nodes:
self.app.broadcastNodesInformation(new_nodes)
# load partition in memory
try:
self.app.pt.load(ptid, row_list, self.app.nm)
new_nodes = self.app.pt.load(ptid, row_list, self.app.nm)
except IndexError:
raise ProtocolError('Invalid offset')
else:
self.app.broadcastNodesInformation(new_nodes)
# notify the admin nodes
for node in self.app.nm.getAdminList(only_identified=True):
self.app.sendPartitionTable(node.getConnection())
......
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