@PublicEvolving public interface OffsetsInitializer extends Serializable
KafkaPartitionSplit
.ReaderHandledOffsetsInitializer
,
SpecifiedOffsetsInitializer
,
TimestampOffsetsInitializer
Modifier and Type | Interface and Description |
---|---|
static interface |
OffsetsInitializer.PartitionOffsetsRetriever
An interface that provides necessary information to the
OffsetsInitializer to get the
initial offsets of the Kafka partitions. |
Modifier and Type | Method and Description |
---|---|
static OffsetsInitializer |
committedOffsets()
Get an
OffsetsInitializer which initializes the offsets to the committed offsets. |
static OffsetsInitializer |
committedOffsets(org.apache.kafka.clients.consumer.OffsetResetStrategy offsetResetStrategy)
Get an
OffsetsInitializer which initializes the offsets to the committed offsets. |
static OffsetsInitializer |
earliest()
Get an
OffsetsInitializer which initializes the offsets to the earliest available
offsets of each partition. |
org.apache.kafka.clients.consumer.OffsetResetStrategy |
getAutoOffsetResetStrategy()
Get the auto offset reset strategy in case the initialized offsets falls out of the range.
|
Map<org.apache.kafka.common.TopicPartition,Long> |
getPartitionOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions,
OffsetsInitializer.PartitionOffsetsRetriever partitionOffsetsRetriever)
Get the initial offsets for the given Kafka partitions.
|
static OffsetsInitializer |
latest()
Get an
OffsetsInitializer which initializes the offsets to the latest offsets of each
partition. |
static OffsetsInitializer |
offsets(Map<org.apache.kafka.common.TopicPartition,Long> offsets)
Get an
OffsetsInitializer which initializes the offsets to the specified offsets. |
static OffsetsInitializer |
offsets(Map<org.apache.kafka.common.TopicPartition,Long> offsets,
org.apache.kafka.clients.consumer.OffsetResetStrategy offsetResetStrategy)
Get an
OffsetsInitializer which initializes the offsets to the specified offsets. |
static OffsetsInitializer |
timestamp(long timestamp)
Get an
OffsetsInitializer which initializes the offsets in each partition so that the
initialized offset is the offset of the first record whose record timestamp is greater than
or equals the given timestamp (milliseconds). |
Map<org.apache.kafka.common.TopicPartition,Long> getPartitionOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions, OffsetsInitializer.PartitionOffsetsRetriever partitionOffsetsRetriever)
If the implementation returns a starting offset which causes OffsetsOutOfRangeException
from Kafka. The OffsetResetStrategy
provided by the
getAutoOffsetResetStrategy()
will be used to reset the offset.
partitions
- the Kafka partitions to get the starting offsets.partitionOffsetsRetriever
- a helper to retrieve information of the Kafka partitions.org.apache.kafka.clients.consumer.OffsetResetStrategy getAutoOffsetResetStrategy()
The OffsetStrategy is only used when the offset initializer is used to initialize the starting offsets and the starting offsets is out of range.
OffsetResetStrategy
to use if the initialized offsets are out of the
range.static OffsetsInitializer committedOffsets()
OffsetsInitializer
which initializes the offsets to the committed offsets. An
exception will be thrown at runtime if there is no committed offsets.static OffsetsInitializer committedOffsets(org.apache.kafka.clients.consumer.OffsetResetStrategy offsetResetStrategy)
OffsetsInitializer
which initializes the offsets to the committed offsets. Use
the given OffsetResetStrategy
to initialize the offsets if the committed offsets does
not exist.offsetResetStrategy
- the offset reset strategy to use when the committed offsets do not
exist.OffsetsInitializer
which initializes the offsets to the committed offsets.static OffsetsInitializer timestamp(long timestamp)
OffsetsInitializer
which initializes the offsets in each partition so that the
initialized offset is the offset of the first record whose record timestamp is greater than
or equals the given timestamp (milliseconds).timestamp
- the timestamp (milliseconds) to start the consumption.OffsetsInitializer
which initializes the offsets based on the given
timestamp.Admin.listOffsets(Map)
static OffsetsInitializer earliest()
OffsetsInitializer
which initializes the offsets to the earliest available
offsets of each partition.OffsetsInitializer
which initializes the offsets to the earliest available
offsets.static OffsetsInitializer latest()
OffsetsInitializer
which initializes the offsets to the latest offsets of each
partition.OffsetsInitializer
which initializes the offsets to the latest offsets.static OffsetsInitializer offsets(Map<org.apache.kafka.common.TopicPartition,Long> offsets)
OffsetsInitializer
which initializes the offsets to the specified offsets.offsets
- the specified offsets for each partition.OffsetsInitializer
which initializes the offsets to the specified offsets.static OffsetsInitializer offsets(Map<org.apache.kafka.common.TopicPartition,Long> offsets, org.apache.kafka.clients.consumer.OffsetResetStrategy offsetResetStrategy)
OffsetsInitializer
which initializes the offsets to the specified offsets. Use
the given OffsetResetStrategy
to initialize the offsets in case the specified offset
is out of range.offsets
- the specified offsets for each partition.offsetResetStrategy
- the OffsetResetStrategy
to use when the specified offset
is out of range.OffsetsInitializer
which initializes the offsets to the specified offsets.Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.