Commit 2f907bf3 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Correct the logic of dropping cells.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@209 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 9141c717
...@@ -280,8 +280,8 @@ class PartitionTable(object): ...@@ -280,8 +280,8 @@ class PartitionTable(object):
return [(cell.getUUID(), cell.getState()) for cell in row] return [(cell.getUUID(), cell.getState()) for cell in row]
def tweak(self): def tweak(self):
"""Test if nodes are distributed uniformly. Otherwise, correct the partition """Test if nodes are distributed uniformly. Otherwise, correct the
table.""" partition table."""
changed_cell_list = [] changed_cell_list = []
for offset, row in enumerate(self.partition_list): for offset, row in enumerate(self.partition_list):
...@@ -322,13 +322,16 @@ class PartitionTable(object): ...@@ -322,13 +322,16 @@ class PartitionTable(object):
max_count = 0 max_count = 0
chosen_cell = None chosen_cell = None
for cell in out_of_date_cell_list + up_to_date_cell_list: for cell in cell_list:
count = self.count_dict[cell.getNode()] count = self.count_dict[cell.getNode()]
if max_count < count: if max_count < count:
max_count = count max_count = count
chosen_cell = cell chosen_cell = cell
removed_cell_list.append(chosen_cell) removed_cell_list.append(chosen_cell)
ideal_num -= 1 try:
out_of_date_cell_list.remove(chosen_cell)
except ValueError:
up_to_date_cell_list.remove(chosen_cell)
# Now remove cells really. # Now remove cells really.
for cell in removed_cell_list: for cell in removed_cell_list:
......
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