Class TopicPartitionsOffsetsTracker
- java.lang.Object
-
- com.linkedin.venice.pubsub.adapter.kafka.TopicPartitionsOffsetsTracker
-
public class TopicPartitionsOffsetsTracker extends java.lang.Object
This class tracks consumed topic partitions' offsets
-
-
Constructor Summary
Constructors Constructor Description TopicPartitionsOffsetsTracker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAllOffsetState()
Clear all tracked offsets statelong
getEndOffset(java.lang.String topic, int partition)
Get the end offset of a topic partitionlong
getOffsetLag(java.lang.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.
-
-
-
Method Detail
-
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
public long getEndOffset(java.lang.String topic, int partition)
Get the end offset of a topic partition- Parameters:
topic
-partition
-- Returns:
- end offset of a topic partition if there is any.
-
getOffsetLag
public long getOffsetLag(java.lang.String topic, int partition)
Get consuming offset lag on a topic partition- Parameters:
topic
-partition
-- Returns:
- end offset of a topic partition if there is any.
-
-