Skip to content

Commit

Permalink
Merge "Speed up get_more_nodes() when there is an empty zone"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jan 16, 2016
2 parents 5b35235 + 3c0cf54 commit 4db7e2e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion swift/common/ring/ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,23 @@ def _reload(self, force=False):

# Do this now, when we know the data has changed, rather than
# doing it on every call to get_more_nodes().
#
# Since this is to speed up the finding of handoffs, we only
# consider devices with at least one partition assigned. This
# way, a region, zone, or server with no partitions assigned
# does not count toward our totals, thereby keeping the early
# bailouts in get_more_nodes() working.
dev_ids_with_parts = set()
for part2dev_id in self._replica2part2dev_id:
for dev_id in part2dev_id:
dev_ids_with_parts.add(dev_id)

regions = set()
zones = set()
ips = set()
self._num_devs = 0
for dev in self._devs:
if dev:
if dev and dev['id'] in dev_ids_with_parts:
regions.add(dev['region'])
zones.add((dev['region'], dev['zone']))
ips.add((dev['region'], dev['zone'], dev['ip']))
Expand Down

0 comments on commit 4db7e2e

Please sign in to comment.