Merge "simplify hashring node lookup"
This commit is contained in:
commit
58219aca5a
|
@ -127,15 +127,12 @@ class HashRing(object):
|
||||||
replicas = min(replicas, len(candidates))
|
replicas = min(replicas, len(candidates))
|
||||||
|
|
||||||
nodes = set()
|
nodes = set()
|
||||||
for replica in six.moves.range(0, replicas):
|
while len(nodes) < replicas:
|
||||||
node = self._get_node(partition)
|
node = self._get_node(partition)
|
||||||
while node in nodes or node in ignore_nodes:
|
if node not in ignore_nodes:
|
||||||
partition += 1
|
nodes.add(node)
|
||||||
if partition >= len(self._partitions):
|
partition = (partition + 1
|
||||||
partition = 0
|
if partition + 1 < len(self._partitions) else 0)
|
||||||
node = self._get_node(partition)
|
|
||||||
nodes.add(node)
|
|
||||||
|
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
|
Loading…
Reference in New Issue