本文整理汇总了Python中carbon.hashing.ConsistentHashRing.get_node方法的典型用法代码示例。如果您正苦于以下问题:Python ConsistentHashRing.get_node方法的具体用法?Python ConsistentHashRing.get_node怎么用?Python ConsistentHashRing.get_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类carbon.hashing.ConsistentHashRing
的用法示例。
在下文中一共展示了ConsistentHashRing.get_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_chr_get_node_fnv1a
# 需要导入模块: from carbon.hashing import ConsistentHashRing [as 别名]
# 或者: from carbon.hashing.ConsistentHashRing import get_node [as 别名]
def test_chr_get_node_fnv1a(self):
hosts = [("127.0.0.1", "ba603c36342304ed77953f84ac4d357b"),
("127.0.0.2", "5dd63865534f84899c6e5594dba6749a"),
("127.0.0.3", "866a18b81f2dc4649517a1df13e26f28")]
hashring = ConsistentHashRing(hosts, hash_type='fnv1a_ch')
self.assertEqual(hashring.get_node('hosts.worker1.cpu'),
('127.0.0.1', 'ba603c36342304ed77953f84ac4d357b'))
self.assertEqual(hashring.get_node('hosts.worker2.cpu'),
('127.0.0.3', '866a18b81f2dc4649517a1df13e26f28'))
self.assertEqual(hashring.get_node(
'stats.checkout.cluster.padamski-wro.api.v1.payment-initialize.count'),
('127.0.0.3', '866a18b81f2dc4649517a1df13e26f28'))
示例2: test_10_get_node
# 需要导入模块: from carbon.hashing import ConsistentHashRing [as 别名]
# 或者: from carbon.hashing.ConsistentHashRing import get_node [as 别名]
def test_10_get_node(self):
"""Trigger bisect on identical first key, see: issues/766"""
ring = ConsistentHashRing([], replica_count=1)
ring.add_node(("1", "1"))
n = ring.get_node("('1', '1'):0")
self.assertEqual(('1', '1'), n)