Class OffsetFetcher
java.lang.Object
org.apache.kafka.clients.consumer.internals.OffsetFetcher
OffsetFetcher is responsible for fetching the offsets for
a given set of topic and partition pairs and for validation and resetting of positions,
as needed.-
Constructor Summary
ConstructorsConstructorDescriptionOffsetFetcher(org.apache.kafka.common.utils.LogContext logContext, ConsumerNetworkClient client, ConsumerMetadata metadata, SubscriptionState subscriptions, org.apache.kafka.common.utils.Time time, long retryBackoffMs, long requestTimeoutMs, org.apache.kafka.common.IsolationLevel isolationLevel, org.apache.kafka.clients.ApiVersions apiVersions) -
Method Summary
Modifier and TypeMethodDescriptionbeginningOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions, org.apache.kafka.common.utils.Timer timer) endOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions, org.apache.kafka.common.utils.Timer timer) Map<org.apache.kafka.common.TopicPartition, OffsetAndTimestamp> offsetsForTimes(Map<org.apache.kafka.common.TopicPartition, Long> timestampsToSearch, org.apache.kafka.common.utils.Timer timer) voidReset offsets for all assigned partitions that require it.voidValidate offsets for all assigned partitions for which a leader change has been detected.voidIf we have seen new metadata (as tracked byMetadata.updateVersion()), then we should check that all the assignments have a valid position.
-
Constructor Details
-
OffsetFetcher
public OffsetFetcher(org.apache.kafka.common.utils.LogContext logContext, ConsumerNetworkClient client, ConsumerMetadata metadata, SubscriptionState subscriptions, org.apache.kafka.common.utils.Time time, long retryBackoffMs, long requestTimeoutMs, org.apache.kafka.common.IsolationLevel isolationLevel, org.apache.kafka.clients.ApiVersions apiVersions)
-
-
Method Details
-
resetPositionsIfNeeded
public void resetPositionsIfNeeded()Reset offsets for all assigned partitions that require it.- Throws:
NoOffsetForPartitionException- If no offset reset strategy is defined and one or more partitions aren't awaiting a seekToBeginning() or seekToEnd().
-
validatePositionsIfNeeded
public void validatePositionsIfNeeded()Validate offsets for all assigned partitions for which a leader change has been detected. -
offsetsForTimes
public Map<org.apache.kafka.common.TopicPartition,OffsetAndTimestamp> offsetsForTimes(Map<org.apache.kafka.common.TopicPartition, Long> timestampsToSearch, org.apache.kafka.common.utils.Timer timer) -
beginningOffsets
public Map<org.apache.kafka.common.TopicPartition,Long> beginningOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions, org.apache.kafka.common.utils.Timer timer) -
endOffsets
public Map<org.apache.kafka.common.TopicPartition,Long> endOffsets(Collection<org.apache.kafka.common.TopicPartition> partitions, org.apache.kafka.common.utils.Timer timer) -
validatePositionsOnMetadataChange
public void validatePositionsOnMetadataChange()If we have seen new metadata (as tracked byMetadata.updateVersion()), then we should check that all the assignments have a valid position.
-