Merge "Add ever_rebalanced property to RingBuilder"
This commit is contained in:
commit
4ac456882e
@ -146,6 +146,10 @@ class RingBuilder(object):
|
||||
def part_shift(self):
|
||||
return 32 - self.part_power
|
||||
|
||||
@property
|
||||
def ever_rebalanced(self):
|
||||
return self._last_part_moves is not None
|
||||
|
||||
def _set_part_moved(self, part):
|
||||
self._last_part_moves[part] = 0
|
||||
byte, bit = divmod(part, 8)
|
||||
@ -485,7 +489,7 @@ class RingBuilder(object):
|
||||
|
||||
old_replica2part2dev = copy.deepcopy(self._replica2part2dev)
|
||||
|
||||
if self._last_part_moves is None:
|
||||
if not self.ever_rebalanced:
|
||||
self.logger.debug("New builder; performing initial balance")
|
||||
self._last_part_moves = array('B', itertools.repeat(0, self.parts))
|
||||
self._update_last_part_moves()
|
||||
|
@ -719,7 +719,7 @@ class CooperativeRingBuilder(RingBuilder):
|
||||
:return: True if the partition can be moved, False otherwise.
|
||||
"""
|
||||
# called by parent_builder - now forward to the superclass
|
||||
return (not self._last_part_moves or
|
||||
return (not self.ever_rebalanced or
|
||||
super(CooperativeRingBuilder, self)._can_part_move(part))
|
||||
|
||||
def _update_last_part_moves(self):
|
||||
|
Loading…
Reference in New Issue
Block a user