本文整理汇总了Python中cluster.Cluster.update方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.update方法的具体用法?Python Cluster.update怎么用?Python Cluster.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_test
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import update [as 别名]
def update_test(self):
cluster = Cluster(get_ctool_nodes())
cluster.clean_bootstrap('apache/cassandra-2.1')
[node1, node2] = cluster.get_nodes()
cluster.stress("write n=50000", [node1,node2])
cluster.update('apache/trunk', node1)
示例2: KafkaClient
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import update [as 别名]
class KafkaClient(object):
"""
A high-level pythonic client for Kafka
"""
def __init__(self,
hosts='127.0.0.1:9092',
use_greenlets=False,
socket_timeout_ms=30 * 1000,
offsets_channel_socket_timeout_ms=10 * 1000,
ignore_rdkafka=False,
exclude_internal_topics=True):
"""Create a connection to a Kafka cluster.
:param hosts: Comma-separated list of kafka hosts to used to connect.
:type hosts: str
:param use_greenlets: If True, use gevent instead of threading.
:type use_greenlets: bool
:param socket_timeout_ms: The socket timeout (in milliseconds) for
network requests
:type socket_timeout_ms: int
:param offsets_channel_socket_timeout_ms: The socket timeout (in
milliseconds) when reading responses for offset commit and
offset fetch requests.
:type offsets_channel_socket_timeout_ms: int
:param ignore_rdkafka: Don't use rdkafka, even if installed.
:type ignore_rdkafka: bool
:param exclude_internal_topics: Whether messages from internal topics
(specifically, the offsets topic) should be exposed to the consumer.
:type exclude_internal_topics: bool
"""
self._seed_hosts = hosts
self._socket_timeout_ms = socket_timeout_ms
self._offsets_channel_socket_timeout_ms = offsets_channel_socket_timeout_ms
self._handler = None if use_greenlets else handlers.ThreadingHandler()
self._use_rdkafka = rd_kafka and not ignore_rdkafka
if self._use_rdkafka:
logger.info('Using rd_kafka extensions.')
raise NotImplementedError('Not yet.')
else:
self.cluster = Cluster(
self._seed_hosts,
self._handler,
socket_timeout_ms=self._socket_timeout_ms,
offsets_channel_socket_timeout_ms=self._offsets_channel_socket_timeout_ms,
exclude_internal_topics=exclude_internal_topics
)
self.brokers = self.cluster.brokers
self.topics = self.cluster.topics
def __repr__(self):
return "<{}.{} at {} (hosts={})>".format(
self.__class__.__module__,
self.__class__.__name__,
hex(id(self)),
self._seed_hosts,
)
def update_cluster(self):
"""Update known brokers and topics.
Updates each Topic and Broker, adding new ones as found,
with current metadata from the cluster.
"""
self.cluster.update()