Commit dbdfd96e authored by Yoshinori Okuji's avatar Yoshinori Okuji

Handle removing cells correctly. Reload a partition table before a new primary...

Handle removing cells correctly. Reload a partition table before a new primary master node is elected.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@57 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 761de356
......@@ -85,6 +85,9 @@ class PartitionTable(object):
self.num_filled_rows = self.np
def setCell(self, offset, node, state):
if state == DISCARDED_STATE:
return self.removeCell(offset, node)
if node.getState() in (BROKEN_STATE, DOWN_STATE):
return
......@@ -110,6 +113,16 @@ class PartitionTable(object):
if state != FEEDING_STATE:
self.count_dict[node] = self.count_dict.get(node, 0) + 1
def removeCell(self, offset, node):
row = self.partition_list[offset]
if row is not None:
for cell in row:
if cell.getNode() == node:
row.remove(cell)
if state != FEEDING_STATE:
self.count_dict[node] = self.count_dict.get(node, 0) - 1
break
def filled(self):
return self.num_filled_rows == self.np
......
......@@ -48,7 +48,6 @@ class Application(object):
self.dm.setup(reset)
self.loadConfiguration()
self.loadPartitionTable()
def loadConfiguration(self):
"""Load persistent configuration data from the database.
......@@ -89,11 +88,12 @@ class Application(object):
"""Load a partition table from the database."""
nm = self.nm
pt = self.pt
pt.clear()
for offset, uuid, state in self.dm.getPartitionTable():
node = nm.getNodeByUUID(uuid)
if node is None:
node = StorageNode(uuid = uuid)
if uuid != self.uiid:
if uuid != self.uuid:
# If this node is not self, assume that it is temporarily
# down at the moment. This state will change once every
# node starts to connect to a primary master node.
......@@ -140,6 +140,12 @@ class Application(object):
at this stage."""
logging.info('connecting to a primary master node')
# Reload a partition table from the database. This is necessary
# when a previous primary master died while sending a partition
# table, because the table might be incomplete.
self.loadPartitionTable()
self.ptid = self.dm.getPTID()
handler = BootstrapEventHandler(self)
em = self.em
nm = self.nm
......
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