def _do_refresh(self):
     self.logger.debug("Start updating partitions")
     address = self._client.cluster.owner_connection_address
     connection = self._client.connection_manager.get_connection(address)
     if connection is None:
         self.logger.debug("Could not update partition thread as owner connection is not established yet.")
         return
     request = client_get_partitions_codec.encode_request()
     response = self._client.invoker.invoke_on_connection(request, connection).result()
     partitions = client_get_partitions_codec.decode_response(response)["partitions"]
     # TODO: needs sync
     self.partitions = {}
     for addr, partition_list in partitions.iteritems():
         for partition in partition_list:
             self.partitions[partition] = addr
     self.logger.debug("Finished updating partitions")
Пример #2
0
    def _do_refresh(self, callback=None):
        self.logger.debug("Start updating partitions")
        address = self._client.cluster.owner_connection_address
        connection = self._client.connection_manager.get_connection(address)
        if connection is None:
            self.logger.debug("Could not update partition thread as owner connection is not available.")
            return
        request = client_get_partitions_codec.encode_request()

        def cb(f):
            if f.is_success():
                self.process_partition_response(f.result())
                if callback:
                    callback()

        future = self._client.invoker.invoke_on_connection(request, connection)
        future.add_done_callback(cb)
    def _do_refresh(self, callback=None):
        self.logger.debug("Start updating partitions")
        address = self._client.cluster.owner_connection_address
        connection = self._client.connection_manager.get_connection(address)
        if connection is None:
            self.logger.debug("Could not update partition thread as owner connection is not available.")
            return
        request = client_get_partitions_codec.encode_request()

        def cb(f):
            if f.is_success():
                self.process_partition_response(f.result())
                if callback:
                    callback()

        future = self._client.invoker.invoke_on_connection(request, connection)
        future.add_done_callback(cb)