本文整理汇总了Python中elasticsearch.transport.Transport.sniff_hosts方法的典型用法代码示例。如果您正苦于以下问题:Python Transport.sniff_hosts方法的具体用法?Python Transport.sniff_hosts怎么用?Python Transport.sniff_hosts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elasticsearch.transport.Transport
的用法示例。
在下文中一共展示了Transport.sniff_hosts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sniff_reuses_connection_instances_if_possible
# 需要导入模块: from elasticsearch.transport import Transport [as 别名]
# 或者: from elasticsearch.transport.Transport import sniff_hosts [as 别名]
def test_sniff_reuses_connection_instances_if_possible(self):
t = Transport([{'data': CLUSTER_NODES}, {"host": "1.1.1.1", "port": 123}], connection_class=DummyConnection, randomize_hosts=False)
connection = t.connection_pool.connections[1]
t.sniff_hosts()
self.assertEquals(1, len(t.connection_pool.connections))
self.assertIs(connection, t.get_connection())
示例2: test_sniff_will_use_seed_connections
# 需要导入模块: from elasticsearch.transport import Transport [as 别名]
# 或者: from elasticsearch.transport.Transport import sniff_hosts [as 别名]
def test_sniff_will_use_seed_connections(self):
t = Transport([{'data': CLUSTER_NODES}], connection_class=DummyConnection)
t.set_connections([{'data': 'invalid'}])
t.sniff_hosts()
self.assertEquals(1, len(t.connection_pool.connections))
self.assertEquals('http://1.1.1.1:123', t.get_connection().host)
示例3: test_sniff_uses_sniff_timeout
# 需要导入模块: from elasticsearch.transport import Transport [as 别名]
# 或者: from elasticsearch.transport.Transport import sniff_hosts [as 别名]
def test_sniff_uses_sniff_timeout(self):
t = Transport(
[{"data": CLUSTER_NODES}],
connection_class=DummyConnection,
sniff_timeout=42,
)
t.sniff_hosts()
self.assertEquals(
(("GET", "/_nodes/_all/http"), {"timeout": 42}),
t.seed_connections[0].calls[0],
)
示例4: test_sniff_uses_sniff_timeout
# 需要导入模块: from elasticsearch.transport import Transport [as 别名]
# 或者: from elasticsearch.transport.Transport import sniff_hosts [as 别名]
def test_sniff_uses_sniff_timeout(self):
t = Transport([{'data': CLUSTER_NODES}], connection_class=DummyConnection, sniff_timeout=42)
t.sniff_hosts()
self.assertEquals((('GET', '/_nodes/_all/clear'), {'timeout': 42}), t.seed_connections[0].calls[0])
示例5: test_sniff_will_pick_up_published_host
# 需要导入模块: from elasticsearch.transport import Transport [as 别名]
# 或者: from elasticsearch.transport.Transport import sniff_hosts [as 别名]
def test_sniff_will_pick_up_published_host(self):
t = Transport([{'data': CLUSTER_NODE_PUBLISH_HOST}], connection_class=DummyConnection)
t.sniff_hosts()
self.assertEquals(1, len(t.connection_pool.connections))
self.assertEquals('http://obsidian:9200', t.get_connection().host)