Merge "simplify hashring node lookup"

This commit is contained in:
Jenkins 2017-04-27 15:27:36 +00:00 committed by Gerrit Code Review
commit 58219aca5a
1 changed files with 5 additions and 8 deletions

View File

@ -127,15 +127,12 @@ class HashRing(object):
replicas = min(replicas, len(candidates))
nodes = set()
for replica in six.moves.range(0, replicas):
while len(nodes) < replicas:
node = self._get_node(partition)
while node in nodes or node in ignore_nodes:
partition += 1
if partition >= len(self._partitions):
partition = 0
node = self._get_node(partition)
nodes.add(node)
if node not in ignore_nodes:
nodes.add(node)
partition = (partition + 1
if partition + 1 < len(self._partitions) else 0)
return nodes
def __getitem__(self, key):