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


Python Cluster.update方法代码示例

本文整理汇总了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)
开发者ID:hoodedalien,项目名称:uptesting,代码行数:10,代码来源:update_test.py

示例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()
开发者ID:preoctopus,项目名称:pykafka,代码行数:66,代码来源:client.py


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