Class OffsetFetcher

java.lang.Object
org.apache.kafka.clients.consumer.internals.OffsetFetcher

public class OffsetFetcher extends Object
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 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 by Metadata.updateVersion()), then we should check that all the assignments have a valid position.