Class TimestampKafkaOffsetSpec

java.lang.Object
com.markosindustries.distroboy.kafka.TimestampKafkaOffsetSpec
All Implemented Interfaces:
KafkaOffsetSpec

public class TimestampKafkaOffsetSpec
extends java.lang.Object
implements KafkaOffsetSpec
Return offsets for each partition by looking up the given timestamp.
  • Constructor Summary

    Constructors
    Constructor Description
    TimestampKafkaOffsetSpec​(long timestampMs)
    Return offsets for each partition by looking up the given Kafka timestamp
    TimestampKafkaOffsetSpec​(java.time.Instant instant)
    Return offsets for each partition by looking up the given Instant as a Kafka timestamp
  • Method Summary

    Modifier and Type Method Description
    <K,​ V> java.util.Map<org.apache.kafka.common.TopicPartition,​java.lang.Long> getOffsets​(org.apache.kafka.clients.consumer.Consumer<K,​V> kafkaConsumer, java.util.Collection<org.apache.kafka.common.TopicPartition> topicPartitions)
    Load the offsets for a given set of topicPartitions

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TimestampKafkaOffsetSpec

      public TimestampKafkaOffsetSpec​(java.time.Instant instant)
      Return offsets for each partition by looking up the given Instant as a Kafka timestamp
      Parameters:
      instant - The time to retrieve offsets for from Kafka
    • TimestampKafkaOffsetSpec

      public TimestampKafkaOffsetSpec​(long timestampMs)
      Return offsets for each partition by looking up the given Kafka timestamp
      Parameters:
      timestampMs - The UTC timestamp to retrieve offsets for from Kafka (in milliseconds)
  • Method Details

    • getOffsets

      public <K,​ V> java.util.Map<org.apache.kafka.common.TopicPartition,​java.lang.Long> getOffsets​(org.apache.kafka.clients.consumer.Consumer<K,​V> kafkaConsumer, java.util.Collection<org.apache.kafka.common.TopicPartition> topicPartitions)
      Description copied from interface: KafkaOffsetSpec
      Load the offsets for a given set of topicPartitions
      Specified by:
      getOffsets in interface KafkaOffsetSpec
      Type Parameters:
      K - The type of keys the KafkaConsumer will deserialise
      V - The type of values the KafkaConsumer will deserialise
      Parameters:
      kafkaConsumer - A KafkaConsumer to communicate with Kafka via
      topicPartitions - The set of TopicPartitions to load offsets for
      Returns:
      A map from each TopicPartition specified to it's offset according to this Spec.