e29ca79ed9
This is a consistent hash ring implementation based on the one that can be found in Nova, Ironic, Ceilometer and Aodh. Change-Id: I5d2f4efcd354a187747fa645482db2029a1a14b7
16 lines
523 B
Python
16 lines
523 B
Python
from tooz import hashring
|
|
|
|
hashring = hashring.HashRing({'node1', 'node2', 'node3'})
|
|
|
|
# Returns set(['node2'])
|
|
nodes_for_foo = hashring[b'foo']
|
|
|
|
# Returns set(['node2', 'node3'])
|
|
nodes_for_foo_with_replicas = hashring.get_nodes(b'foo',
|
|
replicas=2)
|
|
|
|
# Returns set(['node1', 'node3'])
|
|
nodes_for_foo_with_replicas = hashring.get_nodes(b'foo',
|
|
replicas=2,
|
|
ignore_nodes={'node2'})
|