partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
SubscriptionState.need_offset_reset
Mark partition for offset reset using specified or default strategy. Arguments: partition (TopicPartition): partition to mark offset_reset_strategy (OffsetResetStrategy, optional)
kafka/consumer/subscription_state.py
def need_offset_reset(self, partition, offset_reset_strategy=None): """Mark partition for offset reset using specified or default strategy. Arguments: partition (TopicPartition): partition to mark offset_reset_strategy (OffsetResetStrategy, optional) """ if offse...
def need_offset_reset(self, partition, offset_reset_strategy=None): """Mark partition for offset reset using specified or default strategy. Arguments: partition (TopicPartition): partition to mark offset_reset_strategy (OffsetResetStrategy, optional) """ if offse...
[ "Mark", "partition", "for", "offset", "reset", "using", "specified", "or", "default", "strategy", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L325-L334
[ "def", "need_offset_reset", "(", "self", ",", "partition", ",", "offset_reset_strategy", "=", "None", ")", ":", "if", "offset_reset_strategy", "is", "None", ":", "offset_reset_strategy", "=", "self", ".", "_default_offset_reset_strategy", "self", ".", "assignment", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer._cleanup_factory
Build a cleanup clojure that doesn't increase our ref count
kafka/producer/kafka.py
def _cleanup_factory(self): """Build a cleanup clojure that doesn't increase our ref count""" _self = weakref.proxy(self) def wrapper(): try: _self.close(timeout=0) except (ReferenceError, AttributeError): pass return wrapper
def _cleanup_factory(self): """Build a cleanup clojure that doesn't increase our ref count""" _self = weakref.proxy(self) def wrapper(): try: _self.close(timeout=0) except (ReferenceError, AttributeError): pass return wrapper
[ "Build", "a", "cleanup", "clojure", "that", "doesn", "t", "increase", "our", "ref", "count" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L415-L423
[ "def", "_cleanup_factory", "(", "self", ")", ":", "_self", "=", "weakref", ".", "proxy", "(", "self", ")", "def", "wrapper", "(", ")", ":", "try", ":", "_self", ".", "close", "(", "timeout", "=", "0", ")", "except", "(", "ReferenceError", ",", "Attri...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer.close
Close this producer. Arguments: timeout (float, optional): timeout in seconds to wait for completion.
kafka/producer/kafka.py
def close(self, timeout=None): """Close this producer. Arguments: timeout (float, optional): timeout in seconds to wait for completion. """ # drop our atexit handler now to avoid leaks self._unregister_cleanup() if not hasattr(self, '_closed') or self._clos...
def close(self, timeout=None): """Close this producer. Arguments: timeout (float, optional): timeout in seconds to wait for completion. """ # drop our atexit handler now to avoid leaks self._unregister_cleanup() if not hasattr(self, '_closed') or self._clos...
[ "Close", "this", "producer", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L445-L502
[ "def", "close", "(", "self", ",", "timeout", "=", "None", ")", ":", "# drop our atexit handler now to avoid leaks", "self", ".", "_unregister_cleanup", "(", ")", "if", "not", "hasattr", "(", "self", ",", "'_closed'", ")", "or", "self", ".", "_closed", ":", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer.partitions_for
Returns set of all known partitions for the topic.
kafka/producer/kafka.py
def partitions_for(self, topic): """Returns set of all known partitions for the topic.""" max_wait = self.config['max_block_ms'] / 1000.0 return self._wait_on_metadata(topic, max_wait)
def partitions_for(self, topic): """Returns set of all known partitions for the topic.""" max_wait = self.config['max_block_ms'] / 1000.0 return self._wait_on_metadata(topic, max_wait)
[ "Returns", "set", "of", "all", "known", "partitions", "for", "the", "topic", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L504-L507
[ "def", "partitions_for", "(", "self", ",", "topic", ")", ":", "max_wait", "=", "self", ".", "config", "[", "'max_block_ms'", "]", "/", "1000.0", "return", "self", ".", "_wait_on_metadata", "(", "topic", ",", "max_wait", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer.send
Publish a message to a topic. Arguments: topic (str): topic where the message will be published value (optional): message value. Must be type bytes, or be serializable to bytes via configured value_serializer. If value is None, key is required and message...
kafka/producer/kafka.py
def send(self, topic, value=None, key=None, headers=None, partition=None, timestamp_ms=None): """Publish a message to a topic. Arguments: topic (str): topic where the message will be published value (optional): message value. Must be type bytes, or be serializabl...
def send(self, topic, value=None, key=None, headers=None, partition=None, timestamp_ms=None): """Publish a message to a topic. Arguments: topic (str): topic where the message will be published value (optional): message value. Must be type bytes, or be serializabl...
[ "Publish", "a", "message", "to", "a", "topic", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L526-L610
[ "def", "send", "(", "self", ",", "topic", ",", "value", "=", "None", ",", "key", "=", "None", ",", "headers", "=", "None", ",", "partition", "=", "None", ",", "timestamp_ms", "=", "None", ")", ":", "assert", "value", "is", "not", "None", "or", "sel...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer.flush
Invoking this method makes all buffered records immediately available to send (even if linger_ms is greater than 0) and blocks on the completion of the requests associated with these records. The post-condition of :meth:`~kafka.KafkaProducer.flush` is that any previously sent record will...
kafka/producer/kafka.py
def flush(self, timeout=None): """ Invoking this method makes all buffered records immediately available to send (even if linger_ms is greater than 0) and blocks on the completion of the requests associated with these records. The post-condition of :meth:`~kafka.KafkaProducer.flu...
def flush(self, timeout=None): """ Invoking this method makes all buffered records immediately available to send (even if linger_ms is greater than 0) and blocks on the completion of the requests associated with these records. The post-condition of :meth:`~kafka.KafkaProducer.flu...
[ "Invoking", "this", "method", "makes", "all", "buffered", "records", "immediately", "available", "to", "send", "(", "even", "if", "linger_ms", "is", "greater", "than", "0", ")", "and", "blocks", "on", "the", "completion", "of", "the", "requests", "associated",...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L612-L637
[ "def", "flush", "(", "self", ",", "timeout", "=", "None", ")", ":", "log", ".", "debug", "(", "\"Flushing accumulated records in producer.\"", ")", "# trace", "self", ".", "_accumulator", ".", "begin_flush", "(", ")", "self", ".", "_sender", ".", "wakeup", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer._ensure_valid_record_size
Validate that the record size isn't too large.
kafka/producer/kafka.py
def _ensure_valid_record_size(self, size): """Validate that the record size isn't too large.""" if size > self.config['max_request_size']: raise Errors.MessageSizeTooLargeError( "The message is %d bytes when serialized which is larger than" " the maximum reque...
def _ensure_valid_record_size(self, size): """Validate that the record size isn't too large.""" if size > self.config['max_request_size']: raise Errors.MessageSizeTooLargeError( "The message is %d bytes when serialized which is larger than" " the maximum reque...
[ "Validate", "that", "the", "record", "size", "isn", "t", "too", "large", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L639-L650
[ "def", "_ensure_valid_record_size", "(", "self", ",", "size", ")", ":", "if", "size", ">", "self", ".", "config", "[", "'max_request_size'", "]", ":", "raise", "Errors", ".", "MessageSizeTooLargeError", "(", "\"The message is %d bytes when serialized which is larger tha...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer._wait_on_metadata
Wait for cluster metadata including partitions for the given topic to be available. Arguments: topic (str): topic we want metadata for max_wait (float): maximum time in secs for waiting on the metadata Returns: set: partition ids for the topic Raise...
kafka/producer/kafka.py
def _wait_on_metadata(self, topic, max_wait): """ Wait for cluster metadata including partitions for the given topic to be available. Arguments: topic (str): topic we want metadata for max_wait (float): maximum time in secs for waiting on the metadata Re...
def _wait_on_metadata(self, topic, max_wait): """ Wait for cluster metadata including partitions for the given topic to be available. Arguments: topic (str): topic we want metadata for max_wait (float): maximum time in secs for waiting on the metadata Re...
[ "Wait", "for", "cluster", "metadata", "including", "partitions", "for", "the", "given", "topic", "to", "be", "available", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L652-L695
[ "def", "_wait_on_metadata", "(", "self", ",", "topic", ",", "max_wait", ")", ":", "# add topic to metadata topic list if it is not there already.", "self", ".", "_sender", ".", "add_topic", "(", "topic", ")", "begin", "=", "time", ".", "time", "(", ")", "elapsed",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProducer.metrics
Get metrics on producer performance. This is ported from the Java Producer, for details see: https://kafka.apache.org/documentation/#producer_monitoring Warning: This is an unstable interface. It may change in future releases without warning.
kafka/producer/kafka.py
def metrics(self, raw=False): """Get metrics on producer performance. This is ported from the Java Producer, for details see: https://kafka.apache.org/documentation/#producer_monitoring Warning: This is an unstable interface. It may change in future releases wit...
def metrics(self, raw=False): """Get metrics on producer performance. This is ported from the Java Producer, for details see: https://kafka.apache.org/documentation/#producer_monitoring Warning: This is an unstable interface. It may change in future releases wit...
[ "Get", "metrics", "on", "producer", "performance", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/kafka.py#L717-L737
[ "def", "metrics", "(", "self", ",", "raw", "=", "False", ")", ":", "if", "raw", ":", "return", "self", ".", "_metrics", ".", "metrics", ".", "copy", "(", ")", "metrics", "=", "{", "}", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SimpleConsumer.reset_partition_offset
Update offsets using auto_offset_reset policy (smallest|largest) Arguments: partition (int): the partition for which offsets should be updated Returns: Updated offset on success, None on failure
kafka/consumer/simple.py
def reset_partition_offset(self, partition): """Update offsets using auto_offset_reset policy (smallest|largest) Arguments: partition (int): the partition for which offsets should be updated Returns: Updated offset on success, None on failure """ LATEST = -1 ...
def reset_partition_offset(self, partition): """Update offsets using auto_offset_reset policy (smallest|largest) Arguments: partition (int): the partition for which offsets should be updated Returns: Updated offset on success, None on failure """ LATEST = -1 ...
[ "Update", "offsets", "using", "auto_offset_reset", "policy", "(", "smallest|largest", ")" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/simple.py#L149-L186
[ "def", "reset_partition_offset", "(", "self", ",", "partition", ")", ":", "LATEST", "=", "-", "1", "EARLIEST", "=", "-", "2", "if", "self", ".", "auto_offset_reset", "==", "'largest'", ":", "reqs", "=", "[", "OffsetRequestPayload", "(", "self", ".", "topic...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SimpleConsumer.seek
Alter the current offset in the consumer, similar to fseek Arguments: offset: how much to modify the offset whence: where to modify it from, default is None * None is an absolute offset * 0 is relative to the earliest available offset (head) ...
kafka/consumer/simple.py
def seek(self, offset, whence=None, partition=None): """ Alter the current offset in the consumer, similar to fseek Arguments: offset: how much to modify the offset whence: where to modify it from, default is None * None is an absolute offset ...
def seek(self, offset, whence=None, partition=None): """ Alter the current offset in the consumer, similar to fseek Arguments: offset: how much to modify the offset whence: where to modify it from, default is None * None is an absolute offset ...
[ "Alter", "the", "current", "offset", "in", "the", "consumer", "similar", "to", "fseek" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/simple.py#L188-L258
[ "def", "seek", "(", "self", ",", "offset", ",", "whence", "=", "None", ",", "partition", "=", "None", ")", ":", "if", "whence", "is", "None", ":", "# set an absolute offset", "if", "partition", "is", "None", ":", "for", "tmp_partition", "in", "self", "."...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SimpleConsumer.get_messages
Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If block is a positive integer the API will block until that many mes...
kafka/consumer/simple.py
def get_messages(self, count=1, block=True, timeout=0.1): """ Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If bloc...
def get_messages(self, count=1, block=True, timeout=0.1): """ Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If bloc...
[ "Fetch", "the", "specified", "number", "of", "messages" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/simple.py#L260-L302
[ "def", "get_messages", "(", "self", ",", "count", "=", "1", ",", "block", "=", "True", ",", "timeout", "=", "0.1", ")", ":", "messages", "=", "[", "]", "if", "timeout", "is", "not", "None", ":", "timeout", "+=", "time", ".", "time", "(", ")", "ne...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SimpleConsumer._get_message
If no messages can be fetched, returns None. If get_partition_info is None, it defaults to self.partition_info If get_partition_info is True, returns (partition, message) If get_partition_info is False, returns message
kafka/consumer/simple.py
def _get_message(self, block=True, timeout=0.1, get_partition_info=None, update_offset=True): """ If no messages can be fetched, returns None. If get_partition_info is None, it defaults to self.partition_info If get_partition_info is True, returns (partition, message...
def _get_message(self, block=True, timeout=0.1, get_partition_info=None, update_offset=True): """ If no messages can be fetched, returns None. If get_partition_info is None, it defaults to self.partition_info If get_partition_info is True, returns (partition, message...
[ "If", "no", "messages", "can", "be", "fetched", "returns", "None", ".", "If", "get_partition_info", "is", "None", "it", "defaults", "to", "self", ".", "partition_info", "If", "get_partition_info", "is", "True", "returns", "(", "partition", "message", ")", "If"...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/simple.py#L307-L344
[ "def", "_get_message", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "0.1", ",", "get_partition_info", "=", "None", ",", "update_offset", "=", "True", ")", ":", "start_at", "=", "time", ".", "time", "(", ")", "while", "self", ".", "queue...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
encode_varint_1
Encode an integer to a varint presentation. See https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints on how those can be produced. Arguments: num (int): Value to encode Returns: bytearray: Encoded presentation of integer with length from 1 to 10 ...
benchmarks/varint_speed.py
def encode_varint_1(num): """ Encode an integer to a varint presentation. See https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints on how those can be produced. Arguments: num (int): Value to encode Returns: bytearray: Encoded presentation of i...
def encode_varint_1(num): """ Encode an integer to a varint presentation. See https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints on how those can be produced. Arguments: num (int): Value to encode Returns: bytearray: Encoded presentation of i...
[ "Encode", "an", "integer", "to", "a", "varint", "presentation", ".", "See", "https", ":", "//", "developers", ".", "google", ".", "com", "/", "protocol", "-", "buffers", "/", "docs", "/", "encoding?csw", "=", "1#varints", "on", "how", "those", "can", "be...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/benchmarks/varint_speed.py#L87-L114
[ "def", "encode_varint_1", "(", "num", ")", ":", "# Shift sign to the end of number", "num", "=", "(", "num", "<<", "1", ")", "^", "(", "num", ">>", "63", ")", "# Max 10 bytes. We assert those are allocated", "buf", "=", "bytearray", "(", "10", ")", "for", "i",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
size_of_varint_1
Number of bytes needed to encode an integer in variable-length format.
benchmarks/varint_speed.py
def size_of_varint_1(value): """ Number of bytes needed to encode an integer in variable-length format. """ value = (value << 1) ^ (value >> 63) res = 0 while True: res += 1 value = value >> 7 if value == 0: break return res
def size_of_varint_1(value): """ Number of bytes needed to encode an integer in variable-length format. """ value = (value << 1) ^ (value >> 63) res = 0 while True: res += 1 value = value >> 7 if value == 0: break return res
[ "Number", "of", "bytes", "needed", "to", "encode", "an", "integer", "in", "variable", "-", "length", "format", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/benchmarks/varint_speed.py#L262-L272
[ "def", "size_of_varint_1", "(", "value", ")", ":", "value", "=", "(", "value", "<<", "1", ")", "^", "(", "value", ">>", "63", ")", "res", "=", "0", "while", "True", ":", "res", "+=", "1", "value", "=", "value", ">>", "7", "if", "value", "==", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
size_of_varint_2
Number of bytes needed to encode an integer in variable-length format.
benchmarks/varint_speed.py
def size_of_varint_2(value): """ Number of bytes needed to encode an integer in variable-length format. """ value = (value << 1) ^ (value >> 63) if value <= 0x7f: return 1 if value <= 0x3fff: return 2 if value <= 0x1fffff: return 3 if value <= 0xfffffff: retur...
def size_of_varint_2(value): """ Number of bytes needed to encode an integer in variable-length format. """ value = (value << 1) ^ (value >> 63) if value <= 0x7f: return 1 if value <= 0x3fff: return 2 if value <= 0x1fffff: return 3 if value <= 0xfffffff: retur...
[ "Number", "of", "bytes", "needed", "to", "encode", "an", "integer", "in", "variable", "-", "length", "format", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/benchmarks/varint_speed.py#L277-L299
[ "def", "size_of_varint_2", "(", "value", ")", ":", "value", "=", "(", "value", "<<", "1", ")", "^", "(", "value", ">>", "63", ")", "if", "value", "<=", "0x7f", ":", "return", "1", "if", "value", "<=", "0x3fff", ":", "return", "2", "if", "value", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
decode_varint_1
Decode an integer from a varint presentation. See https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints on how those can be produced. Arguments: buffer (bytes-like): any object acceptable by ``memoryview`` pos (int): optional position to read from R...
benchmarks/varint_speed.py
def decode_varint_1(buffer, pos=0): """ Decode an integer from a varint presentation. See https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints on how those can be produced. Arguments: buffer (bytes-like): any object acceptable by ``memoryview`` pos (int...
def decode_varint_1(buffer, pos=0): """ Decode an integer from a varint presentation. See https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints on how those can be produced. Arguments: buffer (bytes-like): any object acceptable by ``memoryview`` pos (int...
[ "Decode", "an", "integer", "from", "a", "varint", "presentation", ".", "See", "https", ":", "//", "developers", ".", "google", ".", "com", "/", "protocol", "-", "buffers", "/", "docs", "/", "encoding?csw", "=", "1#varints", "on", "how", "those", "can", "...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/benchmarks/varint_speed.py#L322-L352
[ "def", "decode_varint_1", "(", "buffer", ",", "pos", "=", "0", ")", ":", "value", "=", "0", "shift", "=", "0", "memview", "=", "memoryview", "(", "buffer", ")", "for", "i", "in", "range", "(", "pos", ",", "pos", "+", "10", ")", ":", "try", ":", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
AbstractSampledStat.purge_obsolete_samples
Timeout any windows that have expired in the absence of any events
kafka/metrics/stats/sampled_stat.py
def purge_obsolete_samples(self, config, now): """ Timeout any windows that have expired in the absence of any events """ expire_age = config.samples * config.time_window_ms for sample in self._samples: if now - sample.last_window_ms >= expire_age: sam...
def purge_obsolete_samples(self, config, now): """ Timeout any windows that have expired in the absence of any events """ expire_age = config.samples * config.time_window_ms for sample in self._samples: if now - sample.last_window_ms >= expire_age: sam...
[ "Timeout", "any", "windows", "that", "have", "expired", "in", "the", "absence", "of", "any", "events" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/stats/sampled_stat.py#L66-L73
[ "def", "purge_obsolete_samples", "(", "self", ",", "config", ",", "now", ")", ":", "expire_age", "=", "config", ".", "samples", "*", "config", ".", "time_window_ms", "for", "sample", "in", "self", ".", "_samples", ":", "if", "now", "-", "sample", ".", "l...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.close
Close the KafkaAdminClient connection to the Kafka broker.
kafka/admin/client.py
def close(self): """Close the KafkaAdminClient connection to the Kafka broker.""" if not hasattr(self, '_closed') or self._closed: log.info("KafkaAdminClient already closed.") return self._metrics.close() self._client.close() self._closed = True l...
def close(self): """Close the KafkaAdminClient connection to the Kafka broker.""" if not hasattr(self, '_closed') or self._closed: log.info("KafkaAdminClient already closed.") return self._metrics.close() self._client.close() self._closed = True l...
[ "Close", "the", "KafkaAdminClient", "connection", "to", "the", "Kafka", "broker", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L208-L217
[ "def", "close", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_closed'", ")", "or", "self", ".", "_closed", ":", "log", ".", "info", "(", "\"KafkaAdminClient already closed.\"", ")", "return", "self", ".", "_metrics", ".", "close", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient._matching_api_version
Find the latest version of the protocol operation supported by both this library and the broker. This resolves to the lesser of either the latest api version this library supports, or the max version supported by the broker. :param operation: A list of protocol operation versions from ...
kafka/admin/client.py
def _matching_api_version(self, operation): """Find the latest version of the protocol operation supported by both this library and the broker. This resolves to the lesser of either the latest api version this library supports, or the max version supported by the broker. :param...
def _matching_api_version(self, operation): """Find the latest version of the protocol operation supported by both this library and the broker. This resolves to the lesser of either the latest api version this library supports, or the max version supported by the broker. :param...
[ "Find", "the", "latest", "version", "of", "the", "protocol", "operation", "supported", "by", "both", "this", "library", "and", "the", "broker", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L219-L237
[ "def", "_matching_api_version", "(", "self", ",", "operation", ")", ":", "version", "=", "min", "(", "len", "(", "operation", ")", "-", "1", ",", "self", ".", "_client", ".", "get_api_versions", "(", ")", "[", "operation", "[", "0", "]", ".", "API_KEY"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient._refresh_controller_id
Determine the Kafka cluster controller.
kafka/admin/client.py
def _refresh_controller_id(self): """Determine the Kafka cluster controller.""" version = self._matching_api_version(MetadataRequest) if 1 <= version <= 6: request = MetadataRequest[version]() response = self._send_request_to_node(self._client.least_loaded_node(), request...
def _refresh_controller_id(self): """Determine the Kafka cluster controller.""" version = self._matching_api_version(MetadataRequest) if 1 <= version <= 6: request = MetadataRequest[version]() response = self._send_request_to_node(self._client.least_loaded_node(), request...
[ "Determine", "the", "Kafka", "cluster", "controller", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L247-L264
[ "def", "_refresh_controller_id", "(", "self", ")", ":", "version", "=", "self", ".", "_matching_api_version", "(", "MetadataRequest", ")", "if", "1", "<=", "version", "<=", "6", ":", "request", "=", "MetadataRequest", "[", "version", "]", "(", ")", "response...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient._find_group_coordinator_id
Find the broker node_id of the coordinator of the given group. Sends a FindCoordinatorRequest message to the cluster. Will block until the FindCoordinatorResponse is received. Any errors are immediately raised. :param group_id: The consumer group ID. This is typically the group ...
kafka/admin/client.py
def _find_group_coordinator_id(self, group_id): """Find the broker node_id of the coordinator of the given group. Sends a FindCoordinatorRequest message to the cluster. Will block until the FindCoordinatorResponse is received. Any errors are immediately raised. :param group_id:...
def _find_group_coordinator_id(self, group_id): """Find the broker node_id of the coordinator of the given group. Sends a FindCoordinatorRequest message to the cluster. Will block until the FindCoordinatorResponse is received. Any errors are immediately raised. :param group_id:...
[ "Find", "the", "broker", "node_id", "of", "the", "coordinator", "of", "the", "given", "group", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L266-L302
[ "def", "_find_group_coordinator_id", "(", "self", ",", "group_id", ")", ":", "# Note: Java may change how this is implemented in KAFKA-6791.", "#", "# TODO add support for dynamically picking version of", "# GroupCoordinatorRequest which was renamed to FindCoordinatorRequest.", "# When I exp...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient._send_request_to_node
Send a Kafka protocol message to a specific broker. Will block until the message result is received. :param node_id: The broker id to which to send the message. :param request: The message to send. :return: The Kafka protocol response for the message. :exception: The exception ...
kafka/admin/client.py
def _send_request_to_node(self, node_id, request): """Send a Kafka protocol message to a specific broker. Will block until the message result is received. :param node_id: The broker id to which to send the message. :param request: The message to send. :return: The Kafka protoco...
def _send_request_to_node(self, node_id, request): """Send a Kafka protocol message to a specific broker. Will block until the message result is received. :param node_id: The broker id to which to send the message. :param request: The message to send. :return: The Kafka protoco...
[ "Send", "a", "Kafka", "protocol", "message", "to", "a", "specific", "broker", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L304-L323
[ "def", "_send_request_to_node", "(", "self", ",", "node_id", ",", "request", ")", ":", "while", "not", "self", ".", "_client", ".", "ready", "(", "node_id", ")", ":", "# poll until the connection to broker is ready, otherwise send()", "# will fail with NodeNotReadyError",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient._send_request_to_controller
Send a Kafka protocol message to the cluster controller. Will block until the message result is received. :param request: The message to send. :return: The Kafka protocol response for the message.
kafka/admin/client.py
def _send_request_to_controller(self, request): """Send a Kafka protocol message to the cluster controller. Will block until the message result is received. :param request: The message to send. :return: The Kafka protocol response for the message. """ tries = 2 # in ca...
def _send_request_to_controller(self, request): """Send a Kafka protocol message to the cluster controller. Will block until the message result is received. :param request: The message to send. :return: The Kafka protocol response for the message. """ tries = 2 # in ca...
[ "Send", "a", "Kafka", "protocol", "message", "to", "the", "cluster", "controller", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L325-L363
[ "def", "_send_request_to_controller", "(", "self", ",", "request", ")", ":", "tries", "=", "2", "# in case our cached self._controller_id is outdated", "while", "tries", ":", "tries", "-=", "1", "response", "=", "self", ".", "_send_request_to_node", "(", "self", "."...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.create_topics
Create new topics in the cluster. :param new_topics: A list of NewTopic objects. :param timeout_ms: Milliseconds to wait for new topics to be created before the broker returns. :param validate_only: If True, don't actually create new topics. Not supported by all versions...
kafka/admin/client.py
def create_topics(self, new_topics, timeout_ms=None, validate_only=False): """Create new topics in the cluster. :param new_topics: A list of NewTopic objects. :param timeout_ms: Milliseconds to wait for new topics to be created before the broker returns. :param validate_only...
def create_topics(self, new_topics, timeout_ms=None, validate_only=False): """Create new topics in the cluster. :param new_topics: A list of NewTopic objects. :param timeout_ms: Milliseconds to wait for new topics to be created before the broker returns. :param validate_only...
[ "Create", "new", "topics", "in", "the", "cluster", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L379-L412
[ "def", "create_topics", "(", "self", ",", "new_topics", ",", "timeout_ms", "=", "None", ",", "validate_only", "=", "False", ")", ":", "version", "=", "self", ".", "_matching_api_version", "(", "CreateTopicsRequest", ")", "timeout_ms", "=", "self", ".", "_valid...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.delete_topics
Delete topics from the cluster. :param topics: A list of topic name strings. :param timeout_ms: Milliseconds to wait for topics to be deleted before the broker returns. :return: Appropriate version of DeleteTopicsResponse class.
kafka/admin/client.py
def delete_topics(self, topics, timeout_ms=None): """Delete topics from the cluster. :param topics: A list of topic name strings. :param timeout_ms: Milliseconds to wait for topics to be deleted before the broker returns. :return: Appropriate version of DeleteTopicsResponse ...
def delete_topics(self, topics, timeout_ms=None): """Delete topics from the cluster. :param topics: A list of topic name strings. :param timeout_ms: Milliseconds to wait for topics to be deleted before the broker returns. :return: Appropriate version of DeleteTopicsResponse ...
[ "Delete", "topics", "from", "the", "cluster", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L414-L434
[ "def", "delete_topics", "(", "self", ",", "topics", ",", "timeout_ms", "=", "None", ")", ":", "version", "=", "self", ".", "_matching_api_version", "(", "DeleteTopicsRequest", ")", "timeout_ms", "=", "self", ".", "_validate_timeout", "(", "timeout_ms", ")", "i...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.describe_configs
Fetch configuration parameters for one or more Kafka resources. :param config_resources: An list of ConfigResource objects. Any keys in ConfigResource.configs dict will be used to filter the result. Setting the configs dict to None will get all values. An empty dict will get...
kafka/admin/client.py
def describe_configs(self, config_resources, include_synonyms=False): """Fetch configuration parameters for one or more Kafka resources. :param config_resources: An list of ConfigResource objects. Any keys in ConfigResource.configs dict will be used to filter the result. Setting...
def describe_configs(self, config_resources, include_synonyms=False): """Fetch configuration parameters for one or more Kafka resources. :param config_resources: An list of ConfigResource objects. Any keys in ConfigResource.configs dict will be used to filter the result. Setting...
[ "Fetch", "configuration", "parameters", "for", "one", "or", "more", "Kafka", "resources", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L464-L493
[ "def", "describe_configs", "(", "self", ",", "config_resources", ",", "include_synonyms", "=", "False", ")", ":", "version", "=", "self", ".", "_matching_api_version", "(", "DescribeConfigsRequest", ")", "if", "version", "==", "0", ":", "if", "include_synonyms", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.alter_configs
Alter configuration parameters of one or more Kafka resources. Warning: This is currently broken for BROKER resources because those must be sent to that specific broker, versus this always picks the least-loaded node. See the comment in the source code for details. ...
kafka/admin/client.py
def alter_configs(self, config_resources): """Alter configuration parameters of one or more Kafka resources. Warning: This is currently broken for BROKER resources because those must be sent to that specific broker, versus this always picks the least-loaded node. See...
def alter_configs(self, config_resources): """Alter configuration parameters of one or more Kafka resources. Warning: This is currently broken for BROKER resources because those must be sent to that specific broker, versus this always picks the least-loaded node. See...
[ "Alter", "configuration", "parameters", "of", "one", "or", "more", "Kafka", "resources", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L505-L532
[ "def", "alter_configs", "(", "self", ",", "config_resources", ")", ":", "version", "=", "self", ".", "_matching_api_version", "(", "AlterConfigsRequest", ")", "if", "version", "==", "0", ":", "request", "=", "AlterConfigsRequest", "[", "version", "]", "(", "re...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.create_partitions
Create additional partitions for an existing topic. :param topic_partitions: A map of topic name strings to NewPartition objects. :param timeout_ms: Milliseconds to wait for new partitions to be created before the broker returns. :param validate_only: If True, don't actually create ...
kafka/admin/client.py
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=False): """Create additional partitions for an existing topic. :param topic_partitions: A map of topic name strings to NewPartition objects. :param timeout_ms: Milliseconds to wait for new partitions to be ...
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=False): """Create additional partitions for an existing topic. :param topic_partitions: A map of topic name strings to NewPartition objects. :param timeout_ms: Milliseconds to wait for new partitions to be ...
[ "Create", "additional", "partitions", "for", "an", "existing", "topic", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L550-L572
[ "def", "create_partitions", "(", "self", ",", "topic_partitions", ",", "timeout_ms", "=", "None", ",", "validate_only", "=", "False", ")", ":", "version", "=", "self", ".", "_matching_api_version", "(", "CreatePartitionsRequest", ")", "timeout_ms", "=", "self", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.describe_consumer_groups
Describe a set of consumer groups. Any errors are immediately raised. :param group_ids: A list of consumer group IDs. These are typically the group names as strings. :param group_coordinator_id: The node_id of the groups' coordinator broker. If set to None, it will quer...
kafka/admin/client.py
def describe_consumer_groups(self, group_ids, group_coordinator_id=None): """Describe a set of consumer groups. Any errors are immediately raised. :param group_ids: A list of consumer group IDs. These are typically the group names as strings. :param group_coordinator_id: Th...
def describe_consumer_groups(self, group_ids, group_coordinator_id=None): """Describe a set of consumer groups. Any errors are immediately raised. :param group_ids: A list of consumer group IDs. These are typically the group names as strings. :param group_coordinator_id: Th...
[ "Describe", "a", "set", "of", "consumer", "groups", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L589-L644
[ "def", "describe_consumer_groups", "(", "self", ",", "group_ids", ",", "group_coordinator_id", "=", "None", ")", ":", "group_descriptions", "=", "[", "]", "version", "=", "self", ".", "_matching_api_version", "(", "DescribeGroupsRequest", ")", "for", "group_id", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.list_consumer_groups
List all consumer groups known to the cluster. This returns a list of Consumer Group tuples. The tuples are composed of the consumer group name and the consumer group protocol type. Only consumer groups that store their offsets in Kafka are returned. The protocol type will be a...
kafka/admin/client.py
def list_consumer_groups(self, broker_ids=None): """List all consumer groups known to the cluster. This returns a list of Consumer Group tuples. The tuples are composed of the consumer group name and the consumer group protocol type. Only consumer groups that store their offset...
def list_consumer_groups(self, broker_ids=None): """List all consumer groups known to the cluster. This returns a list of Consumer Group tuples. The tuples are composed of the consumer group name and the consumer group protocol type. Only consumer groups that store their offset...
[ "List", "all", "consumer", "groups", "known", "to", "the", "cluster", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L646-L693
[ "def", "list_consumer_groups", "(", "self", ",", "broker_ids", "=", "None", ")", ":", "# While we return a list, internally use a set to prevent duplicates", "# because if a group coordinator fails after being queried, and its", "# consumer groups move to new brokers that haven't yet been qu...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaAdminClient.list_consumer_group_offsets
Fetch Consumer Group Offsets. Note: This does not verify that the group_id or partitions actually exist in the cluster. As soon as any error is encountered, it is immediately raised. :param group_id: The consumer group id name for which to fetch offsets. :param group_c...
kafka/admin/client.py
def list_consumer_group_offsets(self, group_id, group_coordinator_id=None, partitions=None): """Fetch Consumer Group Offsets. Note: This does not verify that the group_id or partitions actually exist in the cluster. As soon as any error is en...
def list_consumer_group_offsets(self, group_id, group_coordinator_id=None, partitions=None): """Fetch Consumer Group Offsets. Note: This does not verify that the group_id or partitions actually exist in the cluster. As soon as any error is en...
[ "Fetch", "Consumer", "Group", "Offsets", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L695-L763
[ "def", "list_consumer_group_offsets", "(", "self", ",", "group_id", ",", "group_coordinator_id", "=", "None", ",", "partitions", "=", "None", ")", ":", "group_offsets_listing", "=", "{", "}", "if", "group_coordinator_id", "is", "None", ":", "group_coordinator_id", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
crc_update
Update CRC-32C checksum with data. Args: crc: 32-bit checksum to update as long. data: byte array, string or iterable over bytes. Returns: 32-bit updated CRC-32C as long.
kafka/record/_crc32c.py
def crc_update(crc, data): """Update CRC-32C checksum with data. Args: crc: 32-bit checksum to update as long. data: byte array, string or iterable over bytes. Returns: 32-bit updated CRC-32C as long. """ if type(data) != array.array or data.itemsize != 1: buf = array...
def crc_update(crc, data): """Update CRC-32C checksum with data. Args: crc: 32-bit checksum to update as long. data: byte array, string or iterable over bytes. Returns: 32-bit updated CRC-32C as long. """ if type(data) != array.array or data.itemsize != 1: buf = array...
[ "Update", "CRC", "-", "32C", "checksum", "with", "data", ".", "Args", ":", "crc", ":", "32", "-", "bit", "checksum", "to", "update", "as", "long", ".", "data", ":", "byte", "array", "string", "or", "iterable", "over", "bytes", ".", "Returns", ":", "3...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/record/_crc32c.py#L100-L116
[ "def", "crc_update", "(", "crc", ",", "data", ")", ":", "if", "type", "(", "data", ")", "!=", "array", ".", "array", "or", "data", ".", "itemsize", "!=", "1", ":", "buf", "=", "array", ".", "array", "(", "\"B\"", ",", "data", ")", "else", ":", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ProducerBatch.maybe_expire
Expire batches if metadata is not available A batch whose metadata is not available should be expired if one of the following is true: * the batch is not in retry AND request timeout has elapsed after it is ready (full or linger.ms has reached). * the batch is in retry...
kafka/producer/record_accumulator.py
def maybe_expire(self, request_timeout_ms, retry_backoff_ms, linger_ms, is_full): """Expire batches if metadata is not available A batch whose metadata is not available should be expired if one of the following is true: * the batch is not in retry AND request timeout has elapsed afte...
def maybe_expire(self, request_timeout_ms, retry_backoff_ms, linger_ms, is_full): """Expire batches if metadata is not available A batch whose metadata is not available should be expired if one of the following is true: * the batch is not in retry AND request timeout has elapsed afte...
[ "Expire", "batches", "if", "metadata", "is", "not", "available" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L84-L116
[ "def", "maybe_expire", "(", "self", ",", "request_timeout_ms", ",", "retry_backoff_ms", ",", "linger_ms", ",", "is_full", ")", ":", "now", "=", "time", ".", "time", "(", ")", "since_append", "=", "now", "-", "self", ".", "last_append", "since_ready", "=", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.append
Add a record to the accumulator, return the append result. The append result will contain the future metadata, and flag for whether the appended batch is full or a new batch is created Arguments: tp (TopicPartition): The topic/partition to which this record is being...
kafka/producer/record_accumulator.py
def append(self, tp, timestamp_ms, key, value, headers, max_time_to_block_ms, estimated_size=0): """Add a record to the accumulator, return the append result. The append result will contain the future metadata, and flag for whether the appended batch is full or a new batch is cre...
def append(self, tp, timestamp_ms, key, value, headers, max_time_to_block_ms, estimated_size=0): """Add a record to the accumulator, return the append result. The append result will contain the future metadata, and flag for whether the appended batch is full or a new batch is cre...
[ "Add", "a", "record", "to", "the", "accumulator", "return", "the", "append", "result", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L200-L275
[ "def", "append", "(", "self", ",", "tp", ",", "timestamp_ms", ",", "key", ",", "value", ",", "headers", ",", "max_time_to_block_ms", ",", "estimated_size", "=", "0", ")", ":", "assert", "isinstance", "(", "tp", ",", "TopicPartition", ")", ",", "'not TopicP...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.abort_expired_batches
Abort the batches that have been sitting in RecordAccumulator for more than the configured request_timeout due to metadata being unavailable. Arguments: request_timeout_ms (int): milliseconds to timeout cluster (ClusterMetadata): current metadata for kafka cluster ...
kafka/producer/record_accumulator.py
def abort_expired_batches(self, request_timeout_ms, cluster): """Abort the batches that have been sitting in RecordAccumulator for more than the configured request_timeout due to metadata being unavailable. Arguments: request_timeout_ms (int): milliseconds to timeout ...
def abort_expired_batches(self, request_timeout_ms, cluster): """Abort the batches that have been sitting in RecordAccumulator for more than the configured request_timeout due to metadata being unavailable. Arguments: request_timeout_ms (int): milliseconds to timeout ...
[ "Abort", "the", "batches", "that", "have", "been", "sitting", "in", "RecordAccumulator", "for", "more", "than", "the", "configured", "request_timeout", "due", "to", "metadata", "being", "unavailable", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L277-L334
[ "def", "abort_expired_batches", "(", "self", ",", "request_timeout_ms", ",", "cluster", ")", ":", "expired_batches", "=", "[", "]", "to_remove", "=", "[", "]", "count", "=", "0", "for", "tp", "in", "list", "(", "self", ".", "_batches", ".", "keys", "(", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.reenqueue
Re-enqueue the given record batch in the accumulator to retry.
kafka/producer/record_accumulator.py
def reenqueue(self, batch): """Re-enqueue the given record batch in the accumulator to retry.""" now = time.time() batch.attempts += 1 batch.last_attempt = now batch.last_append = now batch.set_retry() assert batch.topic_partition in self._tp_locks, 'TopicPartitio...
def reenqueue(self, batch): """Re-enqueue the given record batch in the accumulator to retry.""" now = time.time() batch.attempts += 1 batch.last_attempt = now batch.last_append = now batch.set_retry() assert batch.topic_partition in self._tp_locks, 'TopicPartitio...
[ "Re", "-", "enqueue", "the", "given", "record", "batch", "in", "the", "accumulator", "to", "retry", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L336-L347
[ "def", "reenqueue", "(", "self", ",", "batch", ")", ":", "now", "=", "time", ".", "time", "(", ")", "batch", ".", "attempts", "+=", "1", "batch", ".", "last_attempt", "=", "now", "batch", ".", "last_append", "=", "now", "batch", ".", "set_retry", "("...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.ready
Get a list of nodes whose partitions are ready to be sent, and the earliest time at which any non-sendable partition will be ready; Also return the flag for whether there are any unknown leaders for the accumulated partition batches. A destination node is ready to send if: * T...
kafka/producer/record_accumulator.py
def ready(self, cluster): """ Get a list of nodes whose partitions are ready to be sent, and the earliest time at which any non-sendable partition will be ready; Also return the flag for whether there are any unknown leaders for the accumulated partition batches. A desti...
def ready(self, cluster): """ Get a list of nodes whose partitions are ready to be sent, and the earliest time at which any non-sendable partition will be ready; Also return the flag for whether there are any unknown leaders for the accumulated partition batches. A desti...
[ "Get", "a", "list", "of", "nodes", "whose", "partitions", "are", "ready", "to", "be", "sent", "and", "the", "earliest", "time", "at", "which", "any", "non", "-", "sendable", "partition", "will", "be", "ready", ";", "Also", "return", "the", "flag", "for",...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L349-L428
[ "def", "ready", "(", "self", ",", "cluster", ")", ":", "ready_nodes", "=", "set", "(", ")", "next_ready_check", "=", "9999999.99", "unknown_leaders_exist", "=", "False", "now", "=", "time", ".", "time", "(", ")", "exhausted", "=", "bool", "(", "self", "....
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.has_unsent
Return whether there is any unsent record in the accumulator.
kafka/producer/record_accumulator.py
def has_unsent(self): """Return whether there is any unsent record in the accumulator.""" for tp in list(self._batches.keys()): with self._tp_locks[tp]: dq = self._batches[tp] if len(dq): return True return False
def has_unsent(self): """Return whether there is any unsent record in the accumulator.""" for tp in list(self._batches.keys()): with self._tp_locks[tp]: dq = self._batches[tp] if len(dq): return True return False
[ "Return", "whether", "there", "is", "any", "unsent", "record", "in", "the", "accumulator", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L430-L437
[ "def", "has_unsent", "(", "self", ")", ":", "for", "tp", "in", "list", "(", "self", ".", "_batches", ".", "keys", "(", ")", ")", ":", "with", "self", ".", "_tp_locks", "[", "tp", "]", ":", "dq", "=", "self", ".", "_batches", "[", "tp", "]", "if...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.drain
Drain all the data for the given nodes and collate them into a list of batches that will fit within the specified size on a per-node basis. This method attempts to avoid choosing the same topic-node repeatedly. Arguments: cluster (ClusterMetadata): The current cluster metadata ...
kafka/producer/record_accumulator.py
def drain(self, cluster, nodes, max_size): """ Drain all the data for the given nodes and collate them into a list of batches that will fit within the specified size on a per-node basis. This method attempts to avoid choosing the same topic-node repeatedly. Arguments: ...
def drain(self, cluster, nodes, max_size): """ Drain all the data for the given nodes and collate them into a list of batches that will fit within the specified size on a per-node basis. This method attempts to avoid choosing the same topic-node repeatedly. Arguments: ...
[ "Drain", "all", "the", "data", "for", "the", "given", "nodes", "and", "collate", "them", "into", "a", "list", "of", "batches", "that", "will", "fit", "within", "the", "specified", "size", "on", "a", "per", "-", "node", "basis", ".", "This", "method", "...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L439-L502
[ "def", "drain", "(", "self", ",", "cluster", ",", "nodes", ",", "max_size", ")", ":", "if", "not", "nodes", ":", "return", "{", "}", "now", "=", "time", ".", "time", "(", ")", "batches", "=", "{", "}", "for", "node_id", "in", "nodes", ":", "size"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.deallocate
Deallocate the record batch.
kafka/producer/record_accumulator.py
def deallocate(self, batch): """Deallocate the record batch.""" self._incomplete.remove(batch) self._free.deallocate(batch.buffer())
def deallocate(self, batch): """Deallocate the record batch.""" self._incomplete.remove(batch) self._free.deallocate(batch.buffer())
[ "Deallocate", "the", "record", "batch", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L504-L507
[ "def", "deallocate", "(", "self", ",", "batch", ")", ":", "self", ".", "_incomplete", ".", "remove", "(", "batch", ")", "self", ".", "_free", ".", "deallocate", "(", "batch", ".", "buffer", "(", ")", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.await_flush_completion
Mark all partitions as ready to send and block until the send is complete
kafka/producer/record_accumulator.py
def await_flush_completion(self, timeout=None): """ Mark all partitions as ready to send and block until the send is complete """ try: for batch in self._incomplete.all(): log.debug('Waiting on produce to %s', batch.produce_future.top...
def await_flush_completion(self, timeout=None): """ Mark all partitions as ready to send and block until the send is complete """ try: for batch in self._incomplete.all(): log.debug('Waiting on produce to %s', batch.produce_future.top...
[ "Mark", "all", "partitions", "as", "ready", "to", "send", "and", "block", "until", "the", "send", "is", "complete" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L520-L536
[ "def", "await_flush_completion", "(", "self", ",", "timeout", "=", "None", ")", ":", "try", ":", "for", "batch", "in", "self", ".", "_incomplete", ".", "all", "(", ")", ":", "log", ".", "debug", "(", "'Waiting on produce to %s'", ",", "batch", ".", "prod...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator.abort_incomplete_batches
This function is only called when sender is closed forcefully. It will fail all the incomplete batches and return.
kafka/producer/record_accumulator.py
def abort_incomplete_batches(self): """ This function is only called when sender is closed forcefully. It will fail all the incomplete batches and return. """ # We need to keep aborting the incomplete batch until no thread is trying to append to # 1. Avoid losing batches....
def abort_incomplete_batches(self): """ This function is only called when sender is closed forcefully. It will fail all the incomplete batches and return. """ # We need to keep aborting the incomplete batch until no thread is trying to append to # 1. Avoid losing batches....
[ "This", "function", "is", "only", "called", "when", "sender", "is", "closed", "forcefully", ".", "It", "will", "fail", "all", "the", "incomplete", "batches", "and", "return", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L538-L555
[ "def", "abort_incomplete_batches", "(", "self", ")", ":", "# We need to keep aborting the incomplete batch until no thread is trying to append to", "# 1. Avoid losing batches.", "# 2. Free up memory in case appending threads are blocked on buffer full.", "# This is a tight loop but should be able ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
RecordAccumulator._abort_batches
Go through incomplete batches and abort them.
kafka/producer/record_accumulator.py
def _abort_batches(self): """Go through incomplete batches and abort them.""" error = Errors.IllegalStateError("Producer is closed forcefully.") for batch in self._incomplete.all(): tp = batch.topic_partition # Close the batch before aborting with self._tp_loc...
def _abort_batches(self): """Go through incomplete batches and abort them.""" error = Errors.IllegalStateError("Producer is closed forcefully.") for batch in self._incomplete.all(): tp = batch.topic_partition # Close the batch before aborting with self._tp_loc...
[ "Go", "through", "incomplete", "batches", "and", "abort", "them", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/record_accumulator.py#L557-L566
[ "def", "_abort_batches", "(", "self", ")", ":", "error", "=", "Errors", ".", "IllegalStateError", "(", "\"Producer is closed forcefully.\"", ")", "for", "batch", "in", "self", ".", "_incomplete", ".", "all", "(", ")", ":", "tp", "=", "batch", ".", "topic_par...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
MemoryRecordsBuilder.append
Append a message to the buffer. Returns: RecordMetadata or None if unable to append
kafka/record/memory_records.py
def append(self, timestamp, key, value, headers=[]): """ Append a message to the buffer. Returns: RecordMetadata or None if unable to append """ if self._closed: return None offset = self._next_offset metadata = self._builder.append(offset, timestamp, key, v...
def append(self, timestamp, key, value, headers=[]): """ Append a message to the buffer. Returns: RecordMetadata or None if unable to append """ if self._closed: return None offset = self._next_offset metadata = self._builder.append(offset, timestamp, key, v...
[ "Append", "a", "message", "to", "the", "buffer", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/record/memory_records.py#L132-L147
[ "def", "append", "(", "self", ",", "timestamp", ",", "key", ",", "value", ",", "headers", "=", "[", "]", ")", ":", "if", "self", ".", "_closed", ":", "return", "None", "offset", "=", "self", ".", "_next_offset", "metadata", "=", "self", ".", "_builde...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
DefaultRecordBatchBuilder.append
Write message to messageset buffer with MsgVersion 2
kafka/record/default_records.py
def append(self, offset, timestamp, key, value, headers, # Cache for LOAD_FAST opcodes encode_varint=encode_varint, size_of_varint=size_of_varint, get_type=type, type_int=int, time_time=time.time, byte_like=(bytes, bytearray, memoryview), bytear...
def append(self, offset, timestamp, key, value, headers, # Cache for LOAD_FAST opcodes encode_varint=encode_varint, size_of_varint=size_of_varint, get_type=type, type_int=int, time_time=time.time, byte_like=(bytes, bytearray, memoryview), bytear...
[ "Write", "message", "to", "messageset", "buffer", "with", "MsgVersion", "2" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/record/default_records.py#L391-L476
[ "def", "append", "(", "self", ",", "offset", ",", "timestamp", ",", "key", ",", "value", ",", "headers", ",", "# Cache for LOAD_FAST opcodes", "encode_varint", "=", "encode_varint", ",", "size_of_varint", "=", "size_of_varint", ",", "get_type", "=", "type", ",",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
DefaultRecordBatchBuilder.estimate_size_in_bytes
Get the upper bound estimate on the size of record
kafka/record/default_records.py
def estimate_size_in_bytes(cls, key, value, headers): """ Get the upper bound estimate on the size of record """ return ( cls.HEADER_STRUCT.size + cls.MAX_RECORD_OVERHEAD + cls.size_of(key, value, headers) )
def estimate_size_in_bytes(cls, key, value, headers): """ Get the upper bound estimate on the size of record """ return ( cls.HEADER_STRUCT.size + cls.MAX_RECORD_OVERHEAD + cls.size_of(key, value, headers) )
[ "Get", "the", "upper", "bound", "estimate", "on", "the", "size", "of", "record" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/record/default_records.py#L575-L581
[ "def", "estimate_size_in_bytes", "(", "cls", ",", "key", ",", "value", ",", "headers", ")", ":", "return", "(", "cls", ".", "HEADER_STRUCT", ".", "size", "+", "cls", ".", "MAX_RECORD_OVERHEAD", "+", "cls", ".", "size_of", "(", "key", ",", "value", ",", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Heartbeat.time_to_next_heartbeat
Returns seconds (float) remaining before next heartbeat should be sent
kafka/coordinator/heartbeat.py
def time_to_next_heartbeat(self): """Returns seconds (float) remaining before next heartbeat should be sent""" time_since_last_heartbeat = time.time() - max(self.last_send, self.last_reset) if self.heartbeat_failed: delay_to_next_heartbeat = self.config['retry_backoff_ms'] / 1000 ...
def time_to_next_heartbeat(self): """Returns seconds (float) remaining before next heartbeat should be sent""" time_since_last_heartbeat = time.time() - max(self.last_send, self.last_reset) if self.heartbeat_failed: delay_to_next_heartbeat = self.config['retry_backoff_ms'] / 1000 ...
[ "Returns", "seconds", "(", "float", ")", "remaining", "before", "next", "heartbeat", "should", "be", "sent" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/heartbeat.py#L46-L53
[ "def", "time_to_next_heartbeat", "(", "self", ")", ":", "time_since_last_heartbeat", "=", "time", ".", "time", "(", ")", "-", "max", "(", "self", ".", "last_send", ",", "self", ".", "last_reset", ")", "if", "self", ".", "heartbeat_failed", ":", "delay_to_nex...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
_address_family
Attempt to determine the family of an address (or hostname) :return: either socket.AF_INET or socket.AF_INET6 or socket.AF_UNSPEC if the address family could not be determined
kafka/conn.py
def _address_family(address): """ Attempt to determine the family of an address (or hostname) :return: either socket.AF_INET or socket.AF_INET6 or socket.AF_UNSPEC if the address family could not be determined """ if address.startswith('[') and address.endswith(']'): ...
def _address_family(address): """ Attempt to determine the family of an address (or hostname) :return: either socket.AF_INET or socket.AF_INET6 or socket.AF_UNSPEC if the address family could not be determined """ if address.startswith('[') and address.endswith(']'): ...
[ "Attempt", "to", "determine", "the", "family", "of", "an", "address", "(", "or", "hostname", ")" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L1256-L1271
[ "def", "_address_family", "(", "address", ")", ":", "if", "address", ".", "startswith", "(", "'['", ")", "and", "address", ".", "endswith", "(", "']'", ")", ":", "return", "socket", ".", "AF_INET6", "for", "af", "in", "(", "socket", ".", "AF_INET", ","...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
get_ip_port_afi
Parse the IP and port from a string in the format of: * host_or_ip <- Can be either IPv4 address literal or hostname/fqdn * host_or_ipv4:port <- Can be either IPv4 address literal or hostname/fqdn * [host_or_ip] <- IPv6 address literal * [host_or_ip]:po...
kafka/conn.py
def get_ip_port_afi(host_and_port_str): """ Parse the IP and port from a string in the format of: * host_or_ip <- Can be either IPv4 address literal or hostname/fqdn * host_or_ipv4:port <- Can be either IPv4 address literal or hostname/fqdn * [host_or_ip] ...
def get_ip_port_afi(host_and_port_str): """ Parse the IP and port from a string in the format of: * host_or_ip <- Can be either IPv4 address literal or hostname/fqdn * host_or_ipv4:port <- Can be either IPv4 address literal or hostname/fqdn * [host_or_ip] ...
[ "Parse", "the", "IP", "and", "port", "from", "a", "string", "in", "the", "format", "of", ":" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L1274-L1320
[ "def", "get_ip_port_afi", "(", "host_and_port_str", ")", ":", "host_and_port_str", "=", "host_and_port_str", ".", "strip", "(", ")", "if", "host_and_port_str", ".", "startswith", "(", "'['", ")", ":", "af", "=", "socket", ".", "AF_INET6", "host", ",", "rest", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
collect_hosts
Collects a comma-separated set of hosts (host:port) and optionally randomize the returned list.
kafka/conn.py
def collect_hosts(hosts, randomize=True): """ Collects a comma-separated set of hosts (host:port) and optionally randomize the returned list. """ if isinstance(hosts, six.string_types): hosts = hosts.strip().split(',') result = [] afi = socket.AF_INET for host_port in hosts: ...
def collect_hosts(hosts, randomize=True): """ Collects a comma-separated set of hosts (host:port) and optionally randomize the returned list. """ if isinstance(hosts, six.string_types): hosts = hosts.strip().split(',') result = [] afi = socket.AF_INET for host_port in hosts: ...
[ "Collects", "a", "comma", "-", "separated", "set", "of", "hosts", "(", "host", ":", "port", ")", "and", "optionally", "randomize", "the", "returned", "list", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L1323-L1346
[ "def", "collect_hosts", "(", "hosts", ",", "randomize", "=", "True", ")", ":", "if", "isinstance", "(", "hosts", ",", "six", ".", "string_types", ")", ":", "hosts", "=", "hosts", ".", "strip", "(", ")", ".", "split", "(", "','", ")", "result", "=", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
dns_lookup
Returns a list of getaddrinfo structs, optionally filtered to an afi (ipv4 / ipv6)
kafka/conn.py
def dns_lookup(host, port, afi=socket.AF_UNSPEC): """Returns a list of getaddrinfo structs, optionally filtered to an afi (ipv4 / ipv6)""" # XXX: all DNS functions in Python are blocking. If we really # want to be non-blocking here, we need to use a 3rd-party # library like python-adns, or move resoluti...
def dns_lookup(host, port, afi=socket.AF_UNSPEC): """Returns a list of getaddrinfo structs, optionally filtered to an afi (ipv4 / ipv6)""" # XXX: all DNS functions in Python are blocking. If we really # want to be non-blocking here, we need to use a 3rd-party # library like python-adns, or move resoluti...
[ "Returns", "a", "list", "of", "getaddrinfo", "structs", "optionally", "filtered", "to", "an", "afi", "(", "ipv4", "/", "ipv6", ")" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L1354-L1372
[ "def", "dns_lookup", "(", "host", ",", "port", ",", "afi", "=", "socket", ".", "AF_UNSPEC", ")", ":", "# XXX: all DNS functions in Python are blocking. If we really", "# want to be non-blocking here, we need to use a 3rd-party", "# library like python-adns, or move resolution onto it...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.connect
Attempt to connect and return ConnectionState
kafka/conn.py
def connect(self): """Attempt to connect and return ConnectionState""" if self.state is ConnectionStates.DISCONNECTED and not self.blacked_out(): self.last_attempt = time.time() next_lookup = self._next_afi_sockaddr() if not next_lookup: self.close(Err...
def connect(self): """Attempt to connect and return ConnectionState""" if self.state is ConnectionStates.DISCONNECTED and not self.blacked_out(): self.last_attempt = time.time() next_lookup = self._next_afi_sockaddr() if not next_lookup: self.close(Err...
[ "Attempt", "to", "connect", "and", "return", "ConnectionState" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L350-L450
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "state", "is", "ConnectionStates", ".", "DISCONNECTED", "and", "not", "self", ".", "blacked_out", "(", ")", ":", "self", ".", "last_attempt", "=", "time", ".", "time", "(", ")", "next_lookup", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection._token_extensions
Return a string representation of the OPTIONAL key-value pairs that can be sent with an OAUTHBEARER initial request.
kafka/conn.py
def _token_extensions(self): """ Return a string representation of the OPTIONAL key-value pairs that can be sent with an OAUTHBEARER initial request. """ token_provider = self.config['sasl_oauth_token_provider'] # Only run if the #extensions() method is implemented by th...
def _token_extensions(self): """ Return a string representation of the OPTIONAL key-value pairs that can be sent with an OAUTHBEARER initial request. """ token_provider = self.config['sasl_oauth_token_provider'] # Only run if the #extensions() method is implemented by th...
[ "Return", "a", "string", "representation", "of", "the", "OPTIONAL", "key", "-", "value", "pairs", "that", "can", "be", "sent", "with", "an", "OAUTHBEARER", "initial", "request", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L718-L731
[ "def", "_token_extensions", "(", "self", ")", ":", "token_provider", "=", "self", ".", "config", "[", "'sasl_oauth_token_provider'", "]", "# Only run if the #extensions() method is implemented by the clients Token Provider class", "# Builds up a string separated by \\x01 via a dict of ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.blacked_out
Return true if we are disconnected from the given node and can't re-establish a connection yet
kafka/conn.py
def blacked_out(self): """ Return true if we are disconnected from the given node and can't re-establish a connection yet """ if self.state is ConnectionStates.DISCONNECTED: if time.time() < self.last_attempt + self._reconnect_backoff: return True ...
def blacked_out(self): """ Return true if we are disconnected from the given node and can't re-establish a connection yet """ if self.state is ConnectionStates.DISCONNECTED: if time.time() < self.last_attempt + self._reconnect_backoff: return True ...
[ "Return", "true", "if", "we", "are", "disconnected", "from", "the", "given", "node", "and", "can", "t", "re", "-", "establish", "a", "connection", "yet" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L733-L741
[ "def", "blacked_out", "(", "self", ")", ":", "if", "self", ".", "state", "is", "ConnectionStates", ".", "DISCONNECTED", ":", "if", "time", ".", "time", "(", ")", "<", "self", ".", "last_attempt", "+", "self", ".", "_reconnect_backoff", ":", "return", "Tr...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.connection_delay
Return the number of milliseconds to wait, based on the connection state, before attempting to send data. When disconnected, this respects the reconnect backoff time. When connecting, returns 0 to allow non-blocking connect to finish. When connected, returns a very large number to handle...
kafka/conn.py
def connection_delay(self): """ Return the number of milliseconds to wait, based on the connection state, before attempting to send data. When disconnected, this respects the reconnect backoff time. When connecting, returns 0 to allow non-blocking connect to finish. When connecte...
def connection_delay(self): """ Return the number of milliseconds to wait, based on the connection state, before attempting to send data. When disconnected, this respects the reconnect backoff time. When connecting, returns 0 to allow non-blocking connect to finish. When connecte...
[ "Return", "the", "number", "of", "milliseconds", "to", "wait", "based", "on", "the", "connection", "state", "before", "attempting", "to", "send", "data", ".", "When", "disconnected", "this", "respects", "the", "reconnect", "backoff", "time", ".", "When", "conn...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L743-L757
[ "def", "connection_delay", "(", "self", ")", ":", "time_waited", "=", "time", ".", "time", "(", ")", "-", "(", "self", ".", "last_attempt", "or", "0", ")", "if", "self", ".", "state", "is", "ConnectionStates", ".", "DISCONNECTED", ":", "return", "max", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.connecting
Returns True if still connecting (this may encompass several different states, such as SSL handshake, authorization, etc).
kafka/conn.py
def connecting(self): """Returns True if still connecting (this may encompass several different states, such as SSL handshake, authorization, etc).""" return self.state in (ConnectionStates.CONNECTING, ConnectionStates.HANDSHAKE, Connec...
def connecting(self): """Returns True if still connecting (this may encompass several different states, such as SSL handshake, authorization, etc).""" return self.state in (ConnectionStates.CONNECTING, ConnectionStates.HANDSHAKE, Connec...
[ "Returns", "True", "if", "still", "connecting", "(", "this", "may", "encompass", "several", "different", "states", "such", "as", "SSL", "handshake", "authorization", "etc", ")", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L763-L768
[ "def", "connecting", "(", "self", ")", ":", "return", "self", ".", "state", "in", "(", "ConnectionStates", ".", "CONNECTING", ",", "ConnectionStates", ".", "HANDSHAKE", ",", "ConnectionStates", ".", "AUTHENTICATING", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.close
Close socket and fail all in-flight-requests. Arguments: error (Exception, optional): pending in-flight-requests will be failed with this exception. Default: kafka.errors.KafkaConnectionError.
kafka/conn.py
def close(self, error=None): """Close socket and fail all in-flight-requests. Arguments: error (Exception, optional): pending in-flight-requests will be failed with this exception. Default: kafka.errors.KafkaConnectionError. """ if self.state ...
def close(self, error=None): """Close socket and fail all in-flight-requests. Arguments: error (Exception, optional): pending in-flight-requests will be failed with this exception. Default: kafka.errors.KafkaConnectionError. """ if self.state ...
[ "Close", "socket", "and", "fail", "all", "in", "-", "flight", "-", "requests", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L798-L834
[ "def", "close", "(", "self", ",", "error", "=", "None", ")", ":", "if", "self", ".", "state", "is", "ConnectionStates", ".", "DISCONNECTED", ":", "return", "with", "self", ".", "_lock", ":", "if", "self", ".", "state", "is", "ConnectionStates", ".", "D...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.send
Queue request for async network send, return Future()
kafka/conn.py
def send(self, request, blocking=True): """Queue request for async network send, return Future()""" future = Future() if self.connecting(): return future.failure(Errors.NodeNotReadyError(str(self))) elif not self.connected(): return future.failure(Errors.KafkaConn...
def send(self, request, blocking=True): """Queue request for async network send, return Future()""" future = Future() if self.connecting(): return future.failure(Errors.NodeNotReadyError(str(self))) elif not self.connected(): return future.failure(Errors.KafkaConn...
[ "Queue", "request", "for", "async", "network", "send", "return", "Future", "()" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L841-L850
[ "def", "send", "(", "self", ",", "request", ",", "blocking", "=", "True", ")", ":", "future", "=", "Future", "(", ")", "if", "self", ".", "connecting", "(", ")", ":", "return", "future", ".", "failure", "(", "Errors", ".", "NodeNotReadyError", "(", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.send_pending_requests
Can block on network if request is larger than send_buffer_bytes
kafka/conn.py
def send_pending_requests(self): """Can block on network if request is larger than send_buffer_bytes""" try: with self._lock: if not self._can_send_recv(): return Errors.NodeNotReadyError(str(self)) # In the future we might manage an intern...
def send_pending_requests(self): """Can block on network if request is larger than send_buffer_bytes""" try: with self._lock: if not self._can_send_recv(): return Errors.NodeNotReadyError(str(self)) # In the future we might manage an intern...
[ "Can", "block", "on", "network", "if", "request", "is", "larger", "than", "send_buffer_bytes" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L875-L893
[ "def", "send_pending_requests", "(", "self", ")", ":", "try", ":", "with", "self", ".", "_lock", ":", "if", "not", "self", ".", "_can_send_recv", "(", ")", ":", "return", "Errors", ".", "NodeNotReadyError", "(", "str", "(", "self", ")", ")", "# In the fu...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.recv
Non-blocking network receive. Return list of (response, future) tuples
kafka/conn.py
def recv(self): """Non-blocking network receive. Return list of (response, future) tuples """ responses = self._recv() if not responses and self.requests_timed_out(): log.warning('%s timed out after %s ms. Closing connection.', self, self.conf...
def recv(self): """Non-blocking network receive. Return list of (response, future) tuples """ responses = self._recv() if not responses and self.requests_timed_out(): log.warning('%s timed out after %s ms. Closing connection.', self, self.conf...
[ "Non", "-", "blocking", "network", "receive", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L900-L929
[ "def", "recv", "(", "self", ")", ":", "responses", "=", "self", ".", "_recv", "(", ")", "if", "not", "responses", "and", "self", ".", "requests_timed_out", "(", ")", ":", "log", ".", "warning", "(", "'%s timed out after %s ms. Closing connection.'", ",", "se...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection._recv
Take all available bytes from socket, return list of any responses from parser
kafka/conn.py
def _recv(self): """Take all available bytes from socket, return list of any responses from parser""" recvd = [] self._lock.acquire() if not self._can_send_recv(): log.warning('%s cannot recv: socket not connected', self) self._lock.release() return ()...
def _recv(self): """Take all available bytes from socket, return list of any responses from parser""" recvd = [] self._lock.acquire() if not self._can_send_recv(): log.warning('%s cannot recv: socket not connected', self) self._lock.release() return ()...
[ "Take", "all", "available", "bytes", "from", "socket", "return", "list", "of", "any", "responses", "from", "parser" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L931-L983
[ "def", "_recv", "(", "self", ")", ":", "recvd", "=", "[", "]", "self", ".", "_lock", ".", "acquire", "(", ")", "if", "not", "self", ".", "_can_send_recv", "(", ")", ":", "log", ".", "warning", "(", "'%s cannot recv: socket not connected'", ",", "self", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BrokerConnection.check_version
Attempt to guess the broker version. Note: This is a blocking call. Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ...
kafka/conn.py
def check_version(self, timeout=2, strict=False, topics=[]): """Attempt to guess the broker version. Note: This is a blocking call. Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ... """ timeout_at = time.time() + timeout log.info('Probing node %s broker versi...
def check_version(self, timeout=2, strict=False, topics=[]): """Attempt to guess the broker version. Note: This is a blocking call. Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ... """ timeout_at = time.time() + timeout log.info('Probing node %s broker versi...
[ "Attempt", "to", "guess", "the", "broker", "version", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/conn.py#L1041-L1139
[ "def", "check_version", "(", "self", ",", "timeout", "=", "2", ",", "strict", "=", "False", ",", "topics", "=", "[", "]", ")", ":", "timeout_at", "=", "time", ".", "time", "(", ")", "+", "timeout", "log", ".", "info", "(", "'Probing node %s broker vers...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender.run
The main run loop for the sender thread.
kafka/producer/sender.py
def run(self): """The main run loop for the sender thread.""" log.debug("Starting Kafka producer I/O thread.") # main loop, runs until close is called while self._running: try: self.run_once() except Exception: log.exception("Uncau...
def run(self): """The main run loop for the sender thread.""" log.debug("Starting Kafka producer I/O thread.") # main loop, runs until close is called while self._running: try: self.run_once() except Exception: log.exception("Uncau...
[ "The", "main", "run", "loop", "for", "the", "sender", "thread", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L53-L88
[ "def", "run", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Starting Kafka producer I/O thread.\"", ")", "# main loop, runs until close is called", "while", "self", ".", "_running", ":", "try", ":", "self", ".", "run_once", "(", ")", "except", "Exception", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender.run_once
Run a single iteration of sending.
kafka/producer/sender.py
def run_once(self): """Run a single iteration of sending.""" while self._topics_to_add: self._client.add_topic(self._topics_to_add.pop()) # get the list of partitions with data ready to send result = self._accumulator.ready(self._metadata) ready_nodes, next_ready_che...
def run_once(self): """Run a single iteration of sending.""" while self._topics_to_add: self._client.add_topic(self._topics_to_add.pop()) # get the list of partitions with data ready to send result = self._accumulator.ready(self._metadata) ready_nodes, next_ready_che...
[ "Run", "a", "single", "iteration", "of", "sending", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L90-L160
[ "def", "run_once", "(", "self", ")", ":", "while", "self", ".", "_topics_to_add", ":", "self", ".", "_client", ".", "add_topic", "(", "self", ".", "_topics_to_add", ".", "pop", "(", ")", ")", "# get the list of partitions with data ready to send", "result", "=",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender.initiate_close
Start closing the sender (won't complete until all data is sent).
kafka/producer/sender.py
def initiate_close(self): """Start closing the sender (won't complete until all data is sent).""" self._running = False self._accumulator.close() self.wakeup()
def initiate_close(self): """Start closing the sender (won't complete until all data is sent).""" self._running = False self._accumulator.close() self.wakeup()
[ "Start", "closing", "the", "sender", "(", "won", "t", "complete", "until", "all", "data", "is", "sent", ")", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L162-L166
[ "def", "initiate_close", "(", "self", ")", ":", "self", ".", "_running", "=", "False", "self", ".", "_accumulator", ".", "close", "(", ")", "self", ".", "wakeup", "(", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender._handle_produce_response
Handle a produce response.
kafka/producer/sender.py
def _handle_produce_response(self, node_id, send_time, batches, response): """Handle a produce response.""" # if we have a response, parse it log.debug('Parsing produce response: %r', response) if response: batches_by_partition = dict([(batch.topic_partition, batch) ...
def _handle_produce_response(self, node_id, send_time, batches, response): """Handle a produce response.""" # if we have a response, parse it log.debug('Parsing produce response: %r', response) if response: batches_by_partition = dict([(batch.topic_partition, batch) ...
[ "Handle", "a", "produce", "response", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L188-L214
[ "def", "_handle_produce_response", "(", "self", ",", "node_id", ",", "send_time", ",", "batches", ",", "response", ")", ":", "# if we have a response, parse it", "log", ".", "debug", "(", "'Parsing produce response: %r'", ",", "response", ")", "if", "response", ":",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender._complete_batch
Complete or retry the given batch of records. Arguments: batch (RecordBatch): The record batch error (Exception): The error (or None if none) base_offset (int): The base offset assigned to the records if successful timestamp_ms (int, optional): The timestamp retu...
kafka/producer/sender.py
def _complete_batch(self, batch, error, base_offset, timestamp_ms=None): """Complete or retry the given batch of records. Arguments: batch (RecordBatch): The record batch error (Exception): The error (or None if none) base_offset (int): The base offset assigned to th...
def _complete_batch(self, batch, error, base_offset, timestamp_ms=None): """Complete or retry the given batch of records. Arguments: batch (RecordBatch): The record batch error (Exception): The error (or None if none) base_offset (int): The base offset assigned to th...
[ "Complete", "or", "retry", "the", "given", "batch", "of", "records", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L216-L253
[ "def", "_complete_batch", "(", "self", ",", "batch", ",", "error", ",", "base_offset", ",", "timestamp_ms", "=", "None", ")", ":", "# Standardize no-error to None", "if", "error", "is", "Errors", ".", "NoError", ":", "error", "=", "None", "if", "error", "is"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender._can_retry
We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed
kafka/producer/sender.py
def _can_retry(self, batch, error): """ We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed """ return (batch.attempts < self.config['retries'] and getattr(error, 'retriable', False))
def _can_retry(self, batch, error): """ We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed """ return (batch.attempts < self.config['retries'] and getattr(error, 'retriable', False))
[ "We", "can", "retry", "a", "send", "if", "the", "error", "is", "transient", "and", "the", "number", "of", "attempts", "taken", "is", "fewer", "than", "the", "maximum", "allowed" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L255-L261
[ "def", "_can_retry", "(", "self", ",", "batch", ",", "error", ")", ":", "return", "(", "batch", ".", "attempts", "<", "self", ".", "config", "[", "'retries'", "]", "and", "getattr", "(", "error", ",", "'retriable'", ",", "False", ")", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender._create_produce_requests
Transfer the record batches into a list of produce requests on a per-node basis. Arguments: collated: {node_id: [RecordBatch]} Returns: dict: {node_id: ProduceRequest} (version depends on api_version)
kafka/producer/sender.py
def _create_produce_requests(self, collated): """ Transfer the record batches into a list of produce requests on a per-node basis. Arguments: collated: {node_id: [RecordBatch]} Returns: dict: {node_id: ProduceRequest} (version depends on api_version) ...
def _create_produce_requests(self, collated): """ Transfer the record batches into a list of produce requests on a per-node basis. Arguments: collated: {node_id: [RecordBatch]} Returns: dict: {node_id: ProduceRequest} (version depends on api_version) ...
[ "Transfer", "the", "record", "batches", "into", "a", "list", "of", "produce", "requests", "on", "a", "per", "-", "node", "basis", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L263-L279
[ "def", "_create_produce_requests", "(", "self", ",", "collated", ")", ":", "requests", "=", "{", "}", "for", "node_id", ",", "batches", "in", "six", ".", "iteritems", "(", "collated", ")", ":", "requests", "[", "node_id", "]", "=", "self", ".", "_produce...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sender._produce_request
Create a produce request from the given record batches. Returns: ProduceRequest (version depends on api_version)
kafka/producer/sender.py
def _produce_request(self, node_id, acks, timeout, batches): """Create a produce request from the given record batches. Returns: ProduceRequest (version depends on api_version) """ produce_records_by_partition = collections.defaultdict(dict) for batch in batches: ...
def _produce_request(self, node_id, acks, timeout, batches): """Create a produce request from the given record batches. Returns: ProduceRequest (version depends on api_version) """ produce_records_by_partition = collections.defaultdict(dict) for batch in batches: ...
[ "Create", "a", "produce", "request", "from", "the", "given", "record", "batches", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L281-L312
[ "def", "_produce_request", "(", "self", ",", "node_id", ",", "acks", ",", "timeout", ",", "batches", ")", ":", "produce_records_by_partition", "=", "collections", ".", "defaultdict", "(", "dict", ")", "for", "batch", "in", "batches", ":", "topic", "=", "batc...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
snappy_encode
Encodes the given data with snappy compression. If xerial_compatible is set then the stream is encoded in a fashion compatible with the xerial snappy library. The block size (xerial_blocksize) controls how frequent the blocking occurs 32k is the default in the xerial library. The format winds up ...
kafka/codec.py
def snappy_encode(payload, xerial_compatible=True, xerial_blocksize=32*1024): """Encodes the given data with snappy compression. If xerial_compatible is set then the stream is encoded in a fashion compatible with the xerial snappy library. The block size (xerial_blocksize) controls how frequent the bl...
def snappy_encode(payload, xerial_compatible=True, xerial_blocksize=32*1024): """Encodes the given data with snappy compression. If xerial_compatible is set then the stream is encoded in a fashion compatible with the xerial snappy library. The block size (xerial_blocksize) controls how frequent the bl...
[ "Encodes", "the", "given", "data", "with", "snappy", "compression", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/codec.py#L100-L160
[ "def", "snappy_encode", "(", "payload", ",", "xerial_compatible", "=", "True", ",", "xerial_blocksize", "=", "32", "*", "1024", ")", ":", "if", "not", "has_snappy", "(", ")", ":", "raise", "NotImplementedError", "(", "\"Snappy codec is not available\"", ")", "if...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
_detect_xerial_stream
Detects if the data given might have been encoded with the blocking mode of the xerial snappy library. This mode writes a magic header of the format: +--------+--------------+------------+---------+--------+ | Marker | Magic String | Null / Pad | Version | Compat | +...
kafka/codec.py
def _detect_xerial_stream(payload): """Detects if the data given might have been encoded with the blocking mode of the xerial snappy library. This mode writes a magic header of the format: +--------+--------------+------------+---------+--------+ | Marker | Magic String | Nu...
def _detect_xerial_stream(payload): """Detects if the data given might have been encoded with the blocking mode of the xerial snappy library. This mode writes a magic header of the format: +--------+--------------+------------+---------+--------+ | Marker | Magic String | Nu...
[ "Detects", "if", "the", "data", "given", "might", "have", "been", "encoded", "with", "the", "blocking", "mode", "of", "the", "xerial", "snappy", "library", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/codec.py#L163-L188
[ "def", "_detect_xerial_stream", "(", "payload", ")", ":", "if", "len", "(", "payload", ")", ">", "16", ":", "header", "=", "struct", ".", "unpack", "(", "'!'", "+", "_XERIAL_V1_FORMAT", ",", "bytes", "(", "payload", ")", "[", ":", "16", "]", ")", "re...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
lz4f_decode
Decode payload using interoperable LZ4 framing. Requires Kafka >= 0.10
kafka/codec.py
def lz4f_decode(payload): """Decode payload using interoperable LZ4 framing. Requires Kafka >= 0.10""" # pylint: disable-msg=no-member ctx = lz4f.createDecompContext() data = lz4f.decompressFrame(payload, ctx) lz4f.freeDecompContext(ctx) # lz4f python module does not expose how much of the payl...
def lz4f_decode(payload): """Decode payload using interoperable LZ4 framing. Requires Kafka >= 0.10""" # pylint: disable-msg=no-member ctx = lz4f.createDecompContext() data = lz4f.decompressFrame(payload, ctx) lz4f.freeDecompContext(ctx) # lz4f python module does not expose how much of the payl...
[ "Decode", "payload", "using", "interoperable", "LZ4", "framing", ".", "Requires", "Kafka", ">", "=", "0", ".", "10" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/codec.py#L226-L237
[ "def", "lz4f_decode", "(", "payload", ")", ":", "# pylint: disable-msg=no-member", "ctx", "=", "lz4f", ".", "createDecompContext", "(", ")", "data", "=", "lz4f", ".", "decompressFrame", "(", "payload", ",", "ctx", ")", "lz4f", ".", "freeDecompContext", "(", "c...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
lz4_encode_old_kafka
Encode payload for 0.8/0.9 brokers -- requires an incorrect header checksum.
kafka/codec.py
def lz4_encode_old_kafka(payload): """Encode payload for 0.8/0.9 brokers -- requires an incorrect header checksum.""" assert xxhash is not None data = lz4_encode(payload) header_size = 7 flg = data[4] if not isinstance(flg, int): flg = ord(flg) content_size_bit = ((flg >> 3) & 1) ...
def lz4_encode_old_kafka(payload): """Encode payload for 0.8/0.9 brokers -- requires an incorrect header checksum.""" assert xxhash is not None data = lz4_encode(payload) header_size = 7 flg = data[4] if not isinstance(flg, int): flg = ord(flg) content_size_bit = ((flg >> 3) & 1) ...
[ "Encode", "payload", "for", "0", ".", "8", "/", "0", ".", "9", "brokers", "--", "requires", "an", "incorrect", "header", "checksum", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/codec.py#L250-L278
[ "def", "lz4_encode_old_kafka", "(", "payload", ")", ":", "assert", "xxhash", "is", "not", "None", "data", "=", "lz4_encode", "(", "payload", ")", "header_size", "=", "7", "flg", "=", "data", "[", "4", "]", "if", "not", "isinstance", "(", "flg", ",", "i...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.brokers
Get all BrokerMetadata Returns: set: {BrokerMetadata, ...}
kafka/cluster.py
def brokers(self): """Get all BrokerMetadata Returns: set: {BrokerMetadata, ...} """ return set(self._brokers.values()) or set(self._bootstrap_brokers.values())
def brokers(self): """Get all BrokerMetadata Returns: set: {BrokerMetadata, ...} """ return set(self._brokers.values()) or set(self._bootstrap_brokers.values())
[ "Get", "all", "BrokerMetadata" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L82-L88
[ "def", "brokers", "(", "self", ")", ":", "return", "set", "(", "self", ".", "_brokers", ".", "values", "(", ")", ")", "or", "set", "(", "self", ".", "_bootstrap_brokers", ".", "values", "(", ")", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.broker_metadata
Get BrokerMetadata Arguments: broker_id (int): node_id for a broker to check Returns: BrokerMetadata or None if not found
kafka/cluster.py
def broker_metadata(self, broker_id): """Get BrokerMetadata Arguments: broker_id (int): node_id for a broker to check Returns: BrokerMetadata or None if not found """ return self._brokers.get(broker_id) or self._bootstrap_brokers.get(broker_id)
def broker_metadata(self, broker_id): """Get BrokerMetadata Arguments: broker_id (int): node_id for a broker to check Returns: BrokerMetadata or None if not found """ return self._brokers.get(broker_id) or self._bootstrap_brokers.get(broker_id)
[ "Get", "BrokerMetadata" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L90-L99
[ "def", "broker_metadata", "(", "self", ",", "broker_id", ")", ":", "return", "self", ".", "_brokers", ".", "get", "(", "broker_id", ")", "or", "self", ".", "_bootstrap_brokers", ".", "get", "(", "broker_id", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.partitions_for_topic
Return set of all partitions for topic (whether available or not) Arguments: topic (str): topic to check for partitions Returns: set: {partition (int), ...}
kafka/cluster.py
def partitions_for_topic(self, topic): """Return set of all partitions for topic (whether available or not) Arguments: topic (str): topic to check for partitions Returns: set: {partition (int), ...} """ if topic not in self._partitions: retur...
def partitions_for_topic(self, topic): """Return set of all partitions for topic (whether available or not) Arguments: topic (str): topic to check for partitions Returns: set: {partition (int), ...} """ if topic not in self._partitions: retur...
[ "Return", "set", "of", "all", "partitions", "for", "topic", "(", "whether", "available", "or", "not", ")" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L101-L112
[ "def", "partitions_for_topic", "(", "self", ",", "topic", ")", ":", "if", "topic", "not", "in", "self", ".", "_partitions", ":", "return", "None", "return", "set", "(", "self", ".", "_partitions", "[", "topic", "]", ".", "keys", "(", ")", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.available_partitions_for_topic
Return set of partitions with known leaders Arguments: topic (str): topic to check for partitions Returns: set: {partition (int), ...} None if topic not found.
kafka/cluster.py
def available_partitions_for_topic(self, topic): """Return set of partitions with known leaders Arguments: topic (str): topic to check for partitions Returns: set: {partition (int), ...} None if topic not found. """ if topic not in self._part...
def available_partitions_for_topic(self, topic): """Return set of partitions with known leaders Arguments: topic (str): topic to check for partitions Returns: set: {partition (int), ...} None if topic not found. """ if topic not in self._part...
[ "Return", "set", "of", "partitions", "with", "known", "leaders" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L114-L128
[ "def", "available_partitions_for_topic", "(", "self", ",", "topic", ")", ":", "if", "topic", "not", "in", "self", ".", "_partitions", ":", "return", "None", "return", "set", "(", "[", "partition", "for", "partition", ",", "metadata", "in", "six", ".", "ite...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.leader_for_partition
Return node_id of leader, -1 unavailable, None if unknown.
kafka/cluster.py
def leader_for_partition(self, partition): """Return node_id of leader, -1 unavailable, None if unknown.""" if partition.topic not in self._partitions: return None elif partition.partition not in self._partitions[partition.topic]: return None return self._partitio...
def leader_for_partition(self, partition): """Return node_id of leader, -1 unavailable, None if unknown.""" if partition.topic not in self._partitions: return None elif partition.partition not in self._partitions[partition.topic]: return None return self._partitio...
[ "Return", "node_id", "of", "leader", "-", "1", "unavailable", "None", "if", "unknown", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L130-L136
[ "def", "leader_for_partition", "(", "self", ",", "partition", ")", ":", "if", "partition", ".", "topic", "not", "in", "self", ".", "_partitions", ":", "return", "None", "elif", "partition", ".", "partition", "not", "in", "self", ".", "_partitions", "[", "p...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.ttl
Milliseconds until metadata should be refreshed
kafka/cluster.py
def ttl(self): """Milliseconds until metadata should be refreshed""" now = time.time() * 1000 if self._need_update: ttl = 0 else: metadata_age = now - self._last_successful_refresh_ms ttl = self.config['metadata_max_age_ms'] - metadata_age ret...
def ttl(self): """Milliseconds until metadata should be refreshed""" now = time.time() * 1000 if self._need_update: ttl = 0 else: metadata_age = now - self._last_successful_refresh_ms ttl = self.config['metadata_max_age_ms'] - metadata_age ret...
[ "Milliseconds", "until", "metadata", "should", "be", "refreshed" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L162-L174
[ "def", "ttl", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "*", "1000", "if", "self", ".", "_need_update", ":", "ttl", "=", "0", "else", ":", "metadata_age", "=", "now", "-", "self", ".", "_last_successful_refresh_ms", "ttl", "="...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.request_update
Flags metadata for update, return Future() Actual update must be handled separately. This method will only change the reported ttl() Returns: kafka.future.Future (value will be the cluster object after update)
kafka/cluster.py
def request_update(self): """Flags metadata for update, return Future() Actual update must be handled separately. This method will only change the reported ttl() Returns: kafka.future.Future (value will be the cluster object after update) """ with self._lock...
def request_update(self): """Flags metadata for update, return Future() Actual update must be handled separately. This method will only change the reported ttl() Returns: kafka.future.Future (value will be the cluster object after update) """ with self._lock...
[ "Flags", "metadata", "for", "update", "return", "Future", "()" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L180-L193
[ "def", "request_update", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_need_update", "=", "True", "if", "not", "self", ".", "_future", "or", "self", ".", "_future", ".", "is_done", ":", "self", ".", "_future", "=", "Future", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.topics
Get set of known topics. Arguments: exclude_internal_topics (bool): Whether records from internal topics (such as offsets) should be exposed to the consumer. If set to True the only way to receive records from an internal topic is subscribing to it. D...
kafka/cluster.py
def topics(self, exclude_internal_topics=True): """Get set of known topics. Arguments: exclude_internal_topics (bool): Whether records from internal topics (such as offsets) should be exposed to the consumer. If set to True the only way to receive records fro...
def topics(self, exclude_internal_topics=True): """Get set of known topics. Arguments: exclude_internal_topics (bool): Whether records from internal topics (such as offsets) should be exposed to the consumer. If set to True the only way to receive records fro...
[ "Get", "set", "of", "known", "topics", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L195-L211
[ "def", "topics", "(", "self", ",", "exclude_internal_topics", "=", "True", ")", ":", "topics", "=", "set", "(", "self", ".", "_partitions", ".", "keys", "(", ")", ")", "if", "exclude_internal_topics", ":", "return", "topics", "-", "self", ".", "internal_to...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.failed_update
Update cluster state given a failed MetadataRequest.
kafka/cluster.py
def failed_update(self, exception): """Update cluster state given a failed MetadataRequest.""" f = None with self._lock: if self._future: f = self._future self._future = None if f: f.failure(exception) self._last_refresh_ms ...
def failed_update(self, exception): """Update cluster state given a failed MetadataRequest.""" f = None with self._lock: if self._future: f = self._future self._future = None if f: f.failure(exception) self._last_refresh_ms ...
[ "Update", "cluster", "state", "given", "a", "failed", "MetadataRequest", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L213-L222
[ "def", "failed_update", "(", "self", ",", "exception", ")", ":", "f", "=", "None", "with", "self", ".", "_lock", ":", "if", "self", ".", "_future", ":", "f", "=", "self", ".", "_future", "self", ".", "_future", "=", "None", "if", "f", ":", "f", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.update_metadata
Update cluster state given a MetadataResponse. Arguments: metadata (MetadataResponse): broker response to a metadata request Returns: None
kafka/cluster.py
def update_metadata(self, metadata): """Update cluster state given a MetadataResponse. Arguments: metadata (MetadataResponse): broker response to a metadata request Returns: None """ # In the common case where we ask for a single topic and get back an # erro...
def update_metadata(self, metadata): """Update cluster state given a MetadataResponse. Arguments: metadata (MetadataResponse): broker response to a metadata request Returns: None """ # In the common case where we ask for a single topic and get back an # erro...
[ "Update", "cluster", "state", "given", "a", "MetadataResponse", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L224-L326
[ "def", "update_metadata", "(", "self", ",", "metadata", ")", ":", "# In the common case where we ask for a single topic and get back an", "# error, we should fail the future", "if", "len", "(", "metadata", ".", "topics", ")", "==", "1", "and", "metadata", ".", "topics", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.add_group_coordinator
Update with metadata for a group coordinator Arguments: group (str): name of group from GroupCoordinatorRequest response (GroupCoordinatorResponse): broker response Returns: bool: True if metadata is updated, False on error
kafka/cluster.py
def add_group_coordinator(self, group, response): """Update with metadata for a group coordinator Arguments: group (str): name of group from GroupCoordinatorRequest response (GroupCoordinatorResponse): broker response Returns: bool: True if metadata is updat...
def add_group_coordinator(self, group, response): """Update with metadata for a group coordinator Arguments: group (str): name of group from GroupCoordinatorRequest response (GroupCoordinatorResponse): broker response Returns: bool: True if metadata is updat...
[ "Update", "with", "metadata", "for", "a", "group", "coordinator" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L336-L378
[ "def", "add_group_coordinator", "(", "self", ",", "group", ",", "response", ")", ":", "log", ".", "debug", "(", "\"Updating coordinator for %s: %s\"", ",", "group", ",", "response", ")", "error_type", "=", "Errors", ".", "for_code", "(", "response", ".", "erro...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ClusterMetadata.with_partitions
Returns a copy of cluster metadata with partitions added
kafka/cluster.py
def with_partitions(self, partitions_to_add): """Returns a copy of cluster metadata with partitions added""" new_metadata = ClusterMetadata(**self.config) new_metadata._brokers = copy.deepcopy(self._brokers) new_metadata._partitions = copy.deepcopy(self._partitions) new_metadata....
def with_partitions(self, partitions_to_add): """Returns a copy of cluster metadata with partitions added""" new_metadata = ClusterMetadata(**self.config) new_metadata._brokers = copy.deepcopy(self._brokers) new_metadata._partitions = copy.deepcopy(self._partitions) new_metadata....
[ "Returns", "a", "copy", "of", "cluster", "metadata", "with", "partitions", "added" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L380-L397
[ "def", "with_partitions", "(", "self", ",", "partitions_to_add", ")", ":", "new_metadata", "=", "ClusterMetadata", "(", "*", "*", "self", ".", "config", ")", "new_metadata", ".", "_brokers", "=", "copy", ".", "deepcopy", "(", "self", ".", "_brokers", ")", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.assign
Manually assign a list of TopicPartitions to this consumer. Arguments: partitions (list of TopicPartition): Assignment for this instance. Raises: IllegalStateError: If consumer has already called :meth:`~kafka.KafkaConsumer.subscribe`. Warning: ...
kafka/consumer/group.py
def assign(self, partitions): """Manually assign a list of TopicPartitions to this consumer. Arguments: partitions (list of TopicPartition): Assignment for this instance. Raises: IllegalStateError: If consumer has already called :meth:`~kafka.KafkaConsumer.s...
def assign(self, partitions): """Manually assign a list of TopicPartitions to this consumer. Arguments: partitions (list of TopicPartition): Assignment for this instance. Raises: IllegalStateError: If consumer has already called :meth:`~kafka.KafkaConsumer.s...
[ "Manually", "assign", "a", "list", "of", "TopicPartitions", "to", "this", "consumer", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L393-L419
[ "def", "assign", "(", "self", ",", "partitions", ")", ":", "self", ".", "_subscription", ".", "assign_from_user", "(", "partitions", ")", "self", ".", "_client", ".", "set_topics", "(", "[", "tp", ".", "topic", "for", "tp", "in", "partitions", "]", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.close
Close the consumer, waiting indefinitely for any needed cleanup. Keyword Arguments: autocommit (bool): If auto-commit is configured for this consumer, this optional flag causes the consumer to attempt to commit any pending consumed offsets prior to close. Default: Tr...
kafka/consumer/group.py
def close(self, autocommit=True): """Close the consumer, waiting indefinitely for any needed cleanup. Keyword Arguments: autocommit (bool): If auto-commit is configured for this consumer, this optional flag causes the consumer to attempt to commit any pending...
def close(self, autocommit=True): """Close the consumer, waiting indefinitely for any needed cleanup. Keyword Arguments: autocommit (bool): If auto-commit is configured for this consumer, this optional flag causes the consumer to attempt to commit any pending...
[ "Close", "the", "consumer", "waiting", "indefinitely", "for", "any", "needed", "cleanup", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L437-L460
[ "def", "close", "(", "self", ",", "autocommit", "=", "True", ")", ":", "if", "self", ".", "_closed", ":", "return", "log", ".", "debug", "(", "\"Closing the KafkaConsumer.\"", ")", "self", ".", "_closed", "=", "True", "self", ".", "_coordinator", ".", "c...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.commit_async
Commit offsets to kafka asynchronously, optionally firing callback. This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after every rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, thi...
kafka/consumer/group.py
def commit_async(self, offsets=None, callback=None): """Commit offsets to kafka asynchronously, optionally firing callback. This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after every rebalance and also on startup. As such, if you...
def commit_async(self, offsets=None, callback=None): """Commit offsets to kafka asynchronously, optionally firing callback. This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after every rebalance and also on startup. As such, if you...
[ "Commit", "offsets", "to", "kafka", "asynchronously", "optionally", "firing", "callback", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L462-L494
[ "def", "commit_async", "(", "self", ",", "offsets", "=", "None", ",", "callback", "=", "None", ")", ":", "assert", "self", ".", "config", "[", "'api_version'", "]", ">=", "(", "0", ",", "8", ",", "1", ")", ",", "'Requires >= Kafka 0.8.1'", "assert", "s...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.commit
Commit offsets to kafka, blocking until success or error. This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after every rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, this API shou...
kafka/consumer/group.py
def commit(self, offsets=None): """Commit offsets to kafka, blocking until success or error. This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after every rebalance and also on startup. As such, if you need to store offsets in anyth...
def commit(self, offsets=None): """Commit offsets to kafka, blocking until success or error. This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after every rebalance and also on startup. As such, if you need to store offsets in anyth...
[ "Commit", "offsets", "to", "kafka", "blocking", "until", "success", "or", "error", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L496-L520
[ "def", "commit", "(", "self", ",", "offsets", "=", "None", ")", ":", "assert", "self", ".", "config", "[", "'api_version'", "]", ">=", "(", "0", ",", "8", ",", "1", ")", ",", "'Requires >= Kafka 0.8.1'", "assert", "self", ".", "config", "[", "'group_id...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.committed
Get the last committed offset for the given partition. This offset will be used as the position for the consumer in the event of a failure. This call may block to do a remote call if the partition in question isn't assigned to this consumer or if the consumer hasn't yet initial...
kafka/consumer/group.py
def committed(self, partition): """Get the last committed offset for the given partition. This offset will be used as the position for the consumer in the event of a failure. This call may block to do a remote call if the partition in question isn't assigned to this consumer or...
def committed(self, partition): """Get the last committed offset for the given partition. This offset will be used as the position for the consumer in the event of a failure. This call may block to do a remote call if the partition in question isn't assigned to this consumer or...
[ "Get", "the", "last", "committed", "offset", "for", "the", "given", "partition", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L522-L553
[ "def", "committed", "(", "self", ",", "partition", ")", ":", "assert", "self", ".", "config", "[", "'api_version'", "]", ">=", "(", "0", ",", "8", ",", "1", ")", ",", "'Requires >= Kafka 0.8.1'", "assert", "self", ".", "config", "[", "'group_id'", "]", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.topics
Get all topics the user is authorized to view. Returns: set: topics
kafka/consumer/group.py
def topics(self): """Get all topics the user is authorized to view. Returns: set: topics """ cluster = self._client.cluster if self._client._metadata_refresh_in_progress and self._client._topics: future = cluster.request_update() self._client....
def topics(self): """Get all topics the user is authorized to view. Returns: set: topics """ cluster = self._client.cluster if self._client._metadata_refresh_in_progress and self._client._topics: future = cluster.request_update() self._client....
[ "Get", "all", "topics", "the", "user", "is", "authorized", "to", "view", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L555-L570
[ "def", "topics", "(", "self", ")", ":", "cluster", "=", "self", ".", "_client", ".", "cluster", "if", "self", ".", "_client", ".", "_metadata_refresh_in_progress", "and", "self", ".", "_client", ".", "_topics", ":", "future", "=", "cluster", ".", "request_...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.poll
Fetch data from assigned topics / partitions. Records are fetched and returned in batches by topic-partition. On each poll, consumer will try to use the last consumed offset as the starting offset and fetch sequentially. The last consumed offset can be manually set through :meth:`~kafka...
kafka/consumer/group.py
def poll(self, timeout_ms=0, max_records=None): """Fetch data from assigned topics / partitions. Records are fetched and returned in batches by topic-partition. On each poll, consumer will try to use the last consumed offset as the starting offset and fetch sequentially. The last consum...
def poll(self, timeout_ms=0, max_records=None): """Fetch data from assigned topics / partitions. Records are fetched and returned in batches by topic-partition. On each poll, consumer will try to use the last consumed offset as the starting offset and fetch sequentially. The last consum...
[ "Fetch", "data", "from", "assigned", "topics", "/", "partitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L583-L625
[ "def", "poll", "(", "self", ",", "timeout_ms", "=", "0", ",", "max_records", "=", "None", ")", ":", "assert", "timeout_ms", ">=", "0", ",", "'Timeout must not be negative'", "if", "max_records", "is", "None", ":", "max_records", "=", "self", ".", "config", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer._poll_once
Do one round of polling. In addition to checking for new data, this does any needed heart-beating, auto-commits, and offset updates. Arguments: timeout_ms (int): The maximum time in milliseconds to block. Returns: dict: Map of topic to list of records (may be empty).
kafka/consumer/group.py
def _poll_once(self, timeout_ms, max_records): """Do one round of polling. In addition to checking for new data, this does any needed heart-beating, auto-commits, and offset updates. Arguments: timeout_ms (int): The maximum time in milliseconds to block. Returns: ...
def _poll_once(self, timeout_ms, max_records): """Do one round of polling. In addition to checking for new data, this does any needed heart-beating, auto-commits, and offset updates. Arguments: timeout_ms (int): The maximum time in milliseconds to block. Returns: ...
[ "Do", "one", "round", "of", "polling", ".", "In", "addition", "to", "checking", "for", "new", "data", "this", "does", "any", "needed", "heart", "-", "beating", "auto", "-", "commits", "and", "offset", "updates", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L627-L667
[ "def", "_poll_once", "(", "self", ",", "timeout_ms", ",", "max_records", ")", ":", "self", ".", "_coordinator", ".", "poll", "(", ")", "# Fetch positions if we have partitions we're subscribed to that we", "# don't know the offset for", "if", "not", "self", ".", "_subsc...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.position
Get the offset of the next record that will be fetched Arguments: partition (TopicPartition): Partition to check Returns: int: Offset
kafka/consumer/group.py
def position(self, partition): """Get the offset of the next record that will be fetched Arguments: partition (TopicPartition): Partition to check Returns: int: Offset """ if not isinstance(partition, TopicPartition): raise TypeError('partiti...
def position(self, partition): """Get the offset of the next record that will be fetched Arguments: partition (TopicPartition): Partition to check Returns: int: Offset """ if not isinstance(partition, TopicPartition): raise TypeError('partiti...
[ "Get", "the", "offset", "of", "the", "next", "record", "that", "will", "be", "fetched" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L669-L685
[ "def", "position", "(", "self", ",", "partition", ")", ":", "if", "not", "isinstance", "(", "partition", ",", "TopicPartition", ")", ":", "raise", "TypeError", "(", "'partition must be a TopicPartition namedtuple'", ")", "assert", "self", ".", "_subscription", "."...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.highwater
Last known highwater offset for a partition. A highwater offset is the offset that will be assigned to the next message that is produced. It may be useful for calculating lag, by comparing with the reported position. Note that both position and highwater refer to the *next* offset -- i....
kafka/consumer/group.py
def highwater(self, partition): """Last known highwater offset for a partition. A highwater offset is the offset that will be assigned to the next message that is produced. It may be useful for calculating lag, by comparing with the reported position. Note that both position and ...
def highwater(self, partition): """Last known highwater offset for a partition. A highwater offset is the offset that will be assigned to the next message that is produced. It may be useful for calculating lag, by comparing with the reported position. Note that both position and ...
[ "Last", "known", "highwater", "offset", "for", "a", "partition", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L687-L709
[ "def", "highwater", "(", "self", ",", "partition", ")", ":", "if", "not", "isinstance", "(", "partition", ",", "TopicPartition", ")", ":", "raise", "TypeError", "(", "'partition must be a TopicPartition namedtuple'", ")", "assert", "self", ".", "_subscription", "....
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.pause
Suspend fetching from the requested partitions. Future calls to :meth:`~kafka.KafkaConsumer.poll` will not return any records from these partitions until they have been resumed using :meth:`~kafka.KafkaConsumer.resume`. Note: This method does not affect partition subscription. In parti...
kafka/consumer/group.py
def pause(self, *partitions): """Suspend fetching from the requested partitions. Future calls to :meth:`~kafka.KafkaConsumer.poll` will not return any records from these partitions until they have been resumed using :meth:`~kafka.KafkaConsumer.resume`. Note: This method does no...
def pause(self, *partitions): """Suspend fetching from the requested partitions. Future calls to :meth:`~kafka.KafkaConsumer.poll` will not return any records from these partitions until they have been resumed using :meth:`~kafka.KafkaConsumer.resume`. Note: This method does no...
[ "Suspend", "fetching", "from", "the", "requested", "partitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L711-L728
[ "def", "pause", "(", "self", ",", "*", "partitions", ")", ":", "if", "not", "all", "(", "[", "isinstance", "(", "p", ",", "TopicPartition", ")", "for", "p", "in", "partitions", "]", ")", ":", "raise", "TypeError", "(", "'partitions must be TopicPartition n...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.seek
Manually specify the fetch offset for a TopicPartition. Overrides the fetch offsets that the consumer will use on the next :meth:`~kafka.KafkaConsumer.poll`. If this API is invoked for the same partition more than once, the latest offset will be used on the next :meth:`~kafka.KafkaConsu...
kafka/consumer/group.py
def seek(self, partition, offset): """Manually specify the fetch offset for a TopicPartition. Overrides the fetch offsets that the consumer will use on the next :meth:`~kafka.KafkaConsumer.poll`. If this API is invoked for the same partition more than once, the latest offset will be use...
def seek(self, partition, offset): """Manually specify the fetch offset for a TopicPartition. Overrides the fetch offsets that the consumer will use on the next :meth:`~kafka.KafkaConsumer.poll`. If this API is invoked for the same partition more than once, the latest offset will be use...
[ "Manually", "specify", "the", "fetch", "offset", "for", "a", "TopicPartition", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L751-L775
[ "def", "seek", "(", "self", ",", "partition", ",", "offset", ")", ":", "if", "not", "isinstance", "(", "partition", ",", "TopicPartition", ")", ":", "raise", "TypeError", "(", "'partition must be a TopicPartition namedtuple'", ")", "assert", "isinstance", "(", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaConsumer.seek_to_beginning
Seek to the oldest available offset for partitions. Arguments: *partitions: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions. Raises: AssertionError: If any partition is not currently assigned, or if no pa...
kafka/consumer/group.py
def seek_to_beginning(self, *partitions): """Seek to the oldest available offset for partitions. Arguments: *partitions: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions. Raises: AssertionError: If any partition i...
def seek_to_beginning(self, *partitions): """Seek to the oldest available offset for partitions. Arguments: *partitions: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions. Raises: AssertionError: If any partition i...
[ "Seek", "to", "the", "oldest", "available", "offset", "for", "partitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/group.py#L777-L799
[ "def", "seek_to_beginning", "(", "self", ",", "*", "partitions", ")", ":", "if", "not", "all", "(", "[", "isinstance", "(", "p", ",", "TopicPartition", ")", "for", "p", "in", "partitions", "]", ")", ":", "raise", "TypeError", "(", "'partitions must be Topi...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5