本文整理匯總了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)