Commit 63f617bb authored by Vincent Pelletier's avatar Vincent Pelletier

Make count_dict property always contain all nodes, even if they are registered...

Make count_dict property always contain all nodes, even if they are registered for the first time in FEEDING state.
This fixes the annoying KeyError raised in log method when it happens.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1112 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent cd29ad22
......@@ -129,12 +129,13 @@ class PartitionTable(object):
if node.getState() in (protocol.BROKEN_STATE, protocol.DOWN_STATE):
return
self.count_dict.setdefault(node, 0)
row = self.partition_list[offset]
if len(row) == 0:
# Create a new row.
row = [Cell(node, state), ]
if state != protocol.FEEDING_STATE:
self.count_dict[node] = self.count_dict.get(node, 0) + 1
self.count_dict[node] += 1
self.partition_list[offset] = row
self.num_filled_rows += 1
......@@ -145,11 +146,11 @@ class PartitionTable(object):
if cell.getNode() == node:
row.remove(cell)
if cell.getState() != protocol.FEEDING_STATE:
self.count_dict[node] = self.count_dict.get(node, 0) - 1
self.count_dict[node] -= 1
break
row.append(Cell(node, state))
if state != protocol.FEEDING_STATE:
self.count_dict[node] = self.count_dict.get(node, 0) + 1
self.count_dict[node] += 1
def removeCell(self, offset, node):
row = self.partition_list[offset]
......@@ -158,7 +159,7 @@ class PartitionTable(object):
if cell.getNode() == node:
row.remove(cell)
if cell.getState() != protocol.FEEDING_STATE:
self.count_dict[node] = self.count_dict.get(node, 0) - 1
self.count_dict[node] -= 1
break
def load(self, ptid, row_list, 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