Class KafkaSourceEnumerator.PartitionOffsetsRetrieverImpl
- java.lang.Object
-
- org.apache.flink.connector.kafka.source.enumerator.KafkaSourceEnumerator.PartitionOffsetsRetrieverImpl
-
- All Implemented Interfaces:
AutoCloseable,OffsetsInitializer.PartitionOffsetsRetriever
- Enclosing class:
- KafkaSourceEnumerator
@VisibleForTesting public static class KafkaSourceEnumerator.PartitionOffsetsRetrieverImpl extends Object implements OffsetsInitializer.PartitionOffsetsRetriever, AutoCloseable
The implementation for offsets retriever with a consumer and an admin client.
-
-
Constructor Summary
Constructors Constructor Description PartitionOffsetsRetrieverImpl(org.apache.kafka.clients.admin.AdminClient adminClient, String groupId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<org.apache.kafka.common.TopicPartition,Long>beginningOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions)List beginning offsets for the specified partitions.voidclose()Map<org.apache.kafka.common.TopicPartition,Long>committedOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions)The group id should be the set forKafkaSourcebefore invoking this method.Map<org.apache.kafka.common.TopicPartition,Long>endOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions)List end offsets for the specified partitions.Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp>offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> timestampsToSearch)List offsets matching a timestamp for the specified partitions.
-
-
-
Constructor Detail
-
PartitionOffsetsRetrieverImpl
public PartitionOffsetsRetrieverImpl(org.apache.kafka.clients.admin.AdminClient adminClient, String groupId)
-
-
Method Detail
-
committedOffsets
public Map<org.apache.kafka.common.TopicPartition,Long> committedOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions)
Description copied from interface:OffsetsInitializer.PartitionOffsetsRetrieverThe group id should be the set forKafkaSourcebefore invoking this method. Otherwise anIllegalStateExceptionwill be thrown.- Specified by:
committedOffsetsin interfaceOffsetsInitializer.PartitionOffsetsRetriever- See Also:
KafkaAdminClient.listConsumerGroupOffsets(String, ListConsumerGroupOffsetsOptions)
-
endOffsets
public Map<org.apache.kafka.common.TopicPartition,Long> endOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions)
Description copied from interface:OffsetsInitializer.PartitionOffsetsRetrieverList end offsets for the specified partitions.- Specified by:
endOffsetsin interfaceOffsetsInitializer.PartitionOffsetsRetriever
-
beginningOffsets
public Map<org.apache.kafka.common.TopicPartition,Long> beginningOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions)
Description copied from interface:OffsetsInitializer.PartitionOffsetsRetrieverList beginning offsets for the specified partitions.- Specified by:
beginningOffsetsin interfaceOffsetsInitializer.PartitionOffsetsRetriever
-
offsetsForTimes
public Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp> offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> timestampsToSearch)
Description copied from interface:OffsetsInitializer.PartitionOffsetsRetrieverList offsets matching a timestamp for the specified partitions.- Specified by:
offsetsForTimesin interfaceOffsetsInitializer.PartitionOffsetsRetriever
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
-