Commit 86337ecc authored by Grégory Wisniewski's avatar Grégory Wisniewski

Factorize partition table loading with update().


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1068 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0bcad6d5
...@@ -112,22 +112,14 @@ class Application(object): ...@@ -112,22 +112,14 @@ class Application(object):
def loadPartitionTable(self): def loadPartitionTable(self):
"""Load a partition table from the database.""" """Load a partition table from the database."""
nm = self.nm ptid = self.dm.getPTID()
pt = self.pt cell_list = self.dm.getPartitionTable()
pt.clear() # dirty, but have to convert states from int to Enum
for offset, uuid, state in self.dm.getPartitionTable(): convert_states = lambda (offset, uuid, state): (offset, uuid,
node = nm.getNodeByUUID(uuid) protocol.partition_cell_states[state])
if node is None: cell_list = map(convert_states, cell_list)
node = StorageNode(uuid = uuid) self.pt.clear()
if uuid != self.uuid: self.pt.update(ptid, cell_list, self.nm)
# 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.
node.setState(TEMPORARILY_DOWN_STATE)
nm.add(node)
state = partition_cell_states.get(state)
pt.setCell(offset, node, state)
def run(self): def run(self):
"""Make sure that the status is sane and start a loop.""" """Make sure that the status is sane and start a loop."""
......
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