Class TopicPartitionsOffsetsTracker
java.lang.Object
com.linkedin.venice.pubsub.adapter.kafka.TopicPartitionsOffsetsTracker
This class tracks consumed topic partitions' offsets
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear all tracked offsets statelong
getEndOffset
(String topic, int partition) Get the end offset of a topic partitionlong
getOffsetLag
(String topic, int partition) Get consuming offset lag on a topic partitionvoid
removeTrackedOffsets
(org.apache.kafka.common.TopicPartition topicPartition) Remove tracked offsets state of a topic partition.void
updateEndAndCurrentOffsets
(org.apache.kafka.clients.consumer.ConsumerRecords<byte[], byte[]> records, org.apache.kafka.clients.consumer.Consumer<byte[], byte[]> kafkaConsumer) Update the end and current offsets of consumed partitions based on consumer metrics and given consumed records.
-
Constructor Details
-
TopicPartitionsOffsetsTracker
public TopicPartitionsOffsetsTracker()
-
-
Method Details
-
updateEndAndCurrentOffsets
public void updateEndAndCurrentOffsets(org.apache.kafka.clients.consumer.ConsumerRecords<byte[], byte[]> records, org.apache.kafka.clients.consumer.Consumer<byte[], byte[]> kafkaConsumer) Update the end and current offsets of consumed partitions based on consumer metrics and given consumed records. For each topic partition, end offset == consumed current offset + offset lag and current offset is determined to be the largest offset amongst the records passed in.- Parameters:
records
- consumed recordskafkaConsumer
- from which to extract metrics
-
removeTrackedOffsets
public void removeTrackedOffsets(org.apache.kafka.common.TopicPartition topicPartition) Remove tracked offsets state of a topic partition.- Parameters:
topicPartition
-
-
clearAllOffsetState
public void clearAllOffsetState()Clear all tracked offsets state -
getEndOffset
Get the end offset of a topic partition- Parameters:
topic
-partition
-- Returns:
- end offset of a topic partition if there is any.
-
getOffsetLag
Get consuming offset lag on a topic partition- Parameters:
topic
-partition
-- Returns:
- end offset of a topic partition if there is any.
-