Class ApacheKafkaOffsetPosition

  • All Implemented Interfaces:
    PubSubPosition

    public class ApacheKafkaOffsetPosition
    extends java.lang.Object
    implements PubSubPosition
    Offset position for Apache Kafka topics
    • Constructor Detail

      • ApacheKafkaOffsetPosition

        public ApacheKafkaOffsetPosition​(long offset)
      • ApacheKafkaOffsetPosition

        public ApacheKafkaOffsetPosition​(java.nio.ByteBuffer buffer)
                                  throws java.io.IOException
        Parameters:
        buffer - the buffer to read from. The ByteBuffer expected to contain avro serialized long
        Throws:
        java.io.IOException - if the buffer is not a valid avro serialized long
    • Method Detail

      • comparePosition

        public int comparePosition​(PubSubPosition other)
        Specified by:
        comparePosition in interface PubSubPosition
        Parameters:
        other - the other position to compare to
        Returns:
        returns 0 if the positions are equal, -1 if this position is less than the other position, and 1 if this position is greater than the other position
      • diff

        public long diff​(PubSubPosition other)
        Specified by:
        diff in interface PubSubPosition
        Returns:
        the difference between this position and the other position
        Throws:
        java.lang.IllegalArgumentException - if position is null or positions are not comparable
      • getOffset

        public long getOffset()
      • toString

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

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface PubSubPosition
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface PubSubPosition
        Overrides:
        hashCode in class java.lang.Object
      • getPositionWireFormat

        public PubSubPositionWireFormat getPositionWireFormat()
        Position wrapper is used to wrap the position type and the position value. This is used to serialize and deserialize the position object when sending and receiving it over the wire.
        Specified by:
        getPositionWireFormat in interface PubSubPosition
        Returns:
        the position wrapper