Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py
- index 43b9288..6b761e9 100644
- --- a/swift/common/ring/builder.py
- +++ b/swift/common/ring/builder.py
- @@ -368,8 +368,17 @@ class RingBuilder(object):
- # Only changed device ids are taken into account; devices might be
- # "touched" during the rebalance, but actually not really moved
- changed_parts = 0
- - for rep_id, _rep in enumerate(self._replica2part2dev):
- - for part_id, new_device in enumerate(_rep):
- + # While iterating over placement count parts who have multiple more
- + # replicas than the maximum number of replicas wanted for that tier
- + max_replicas = self._build_max_replicas_by_tier()
- + at_risk_parts = 0
- + for part_id, dev_ids in enumerate(
- + itertools.izip(*self._replica2part2dev)):
- + replicas_at_tier = defaultdict(int)
- + for rep_id, dev in enumerate(iter(
- + self.devs[dev_id] for dev_id in dev_ids)):
- + for tier in tiers_for_dev(dev):
- + replicas_at_tier[tier] += 1
- # IndexErrors will be raised if the replicas are increased or
- # decreased, and that actually means the partition has changed
- try:
- @@ -378,8 +387,22 @@ class RingBuilder(object):
- changed_parts += 1
- continue
- - if old_device != new_device:
- + if old_device != dev:
- changed_parts += 1
- + for tier, replicas in replicas_at_tier.items():
- + if replicas > max_replicas[tier]:
- + print 'part %s is at risk in %s because %s > %s' % (
- + part_id, tier, replicas, max_replicas[tier])
- + at_risk_parts += 1
- + break
- + dispersion = 1.0 * (self.parts - at_risk_parts) / self.parts
- + print at_risk_parts, dispersion
- +
- + # we'll want to cache dispersion on the builder, clear it on
- + # rebalance, and add it to the return signature (possibly with a
- + # backwards compatibility shim) so that the command line utility can
- + # display a warning and recommend the operator evaluate the situation
- + # with the dispersion command.
- return changed_parts, balance
- def validate(self, stats=False):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement