当前位置: 首页>>代码示例>>Python>>正文


Python Transport.sniff_hosts方法代码示例

本文整理汇总了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())
开发者ID:CCoffie,项目名称:elasticsearch-py,代码行数:9,代码来源:test_transport.py

示例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)
开发者ID:CCoffie,项目名称:elasticsearch-py,代码行数:9,代码来源:test_transport.py

示例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],
     )
开发者ID:elastic,项目名称:elasticsearch-py,代码行数:13,代码来源:test_transport.py

示例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])
开发者ID:CCoffie,项目名称:elasticsearch-py,代码行数:6,代码来源:test_transport.py

示例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)
开发者ID:Brandondz,项目名称:elasticsearch-py,代码行数:8,代码来源:test_transport.py


注:本文中的elasticsearch.transport.Transport.sniff_hosts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。