Class OffsetAndTimestamp

java.lang.Object
org.apache.kafka.clients.consumer.OffsetAndTimestamp

@Public public final class OffsetAndTimestamp extends Object
A container class for offset and timestamp.
  • Constructor Details

    • OffsetAndTimestamp

      public OffsetAndTimestamp(long offset, long timestamp)
      Constructs a new OffsetAndTimestamp with the given offset and timestamp.
      Parameters:
      offset - The offset
      timestamp - The timestamp
      Throws:
      IllegalArgumentException - If the offset or timestamp is negative
    • OffsetAndTimestamp

      public OffsetAndTimestamp(long offset, long timestamp, Optional<Integer> leaderEpoch)
      Constructs a new OffsetAndTimestamp with the given offset, timestamp, and leader epoch.
      Parameters:
      offset - The offset
      timestamp - The timestamp
      leaderEpoch - The leader epoch
      Throws:
      IllegalArgumentException - If the offset or timestamp is negative
  • Method Details

    • timestamp

      public long timestamp()
      Returns the timestamp.
      Returns:
      The timestamp
    • offset

      public long offset()
      Returns the offset.
      Returns:
      The offset
    • leaderEpoch

      public Optional<Integer> leaderEpoch()
      Get the leader epoch corresponding to the offset that was found (if one exists). This can be provided to seek() to ensure that the log hasn't been truncated prior to fetching.
      Returns:
      The leader epoch or empty if it is not known
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object