Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py
  2. index 43b9288..6b761e9 100644
  3. --- a/swift/common/ring/builder.py
  4. +++ b/swift/common/ring/builder.py
  5. @@ -368,8 +368,17 @@ class RingBuilder(object):
  6. # Only changed device ids are taken into account; devices might be
  7. # "touched" during the rebalance, but actually not really moved
  8. changed_parts = 0
  9. - for rep_id, _rep in enumerate(self._replica2part2dev):
  10. - for part_id, new_device in enumerate(_rep):
  11. + # While iterating over placement count parts who have multiple more
  12. + # replicas than the maximum number of replicas wanted for that tier
  13. + max_replicas = self._build_max_replicas_by_tier()
  14. + at_risk_parts = 0
  15. + for part_id, dev_ids in enumerate(
  16. + itertools.izip(*self._replica2part2dev)):
  17. + replicas_at_tier = defaultdict(int)
  18. + for rep_id, dev in enumerate(iter(
  19. + self.devs[dev_id] for dev_id in dev_ids)):
  20. + for tier in tiers_for_dev(dev):
  21. + replicas_at_tier[tier] += 1
  22. # IndexErrors will be raised if the replicas are increased or
  23. # decreased, and that actually means the partition has changed
  24. try:
  25. @@ -378,8 +387,22 @@ class RingBuilder(object):
  26. changed_parts += 1
  27. continue
  28.  
  29. - if old_device != new_device:
  30. + if old_device != dev:
  31. changed_parts += 1
  32. + for tier, replicas in replicas_at_tier.items():
  33. + if replicas > max_replicas[tier]:
  34. + print 'part %s is at risk in %s because %s > %s' % (
  35. + part_id, tier, replicas, max_replicas[tier])
  36. + at_risk_parts += 1
  37. + break
  38. + dispersion = 1.0 * (self.parts - at_risk_parts) / self.parts
  39. + print at_risk_parts, dispersion
  40. +
  41. + # we'll want to cache dispersion on the builder, clear it on
  42. + # rebalance, and add it to the return signature (possibly with a
  43. + # backwards compatibility shim) so that the command line utility can
  44. + # display a warning and recommend the operator evaluate the situation
  45. + # with the dispersion command.
  46. return changed_parts, balance
  47.  
  48. def validate(self, stats=False):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement