Class KafkaTopicPartitionState<T,​KPH>

  • Type Parameters:
    KPH - The type of the Kafka partition descriptor, which varies across Kafka versions.
    Direct Known Subclasses:
    KafkaTopicPartitionStateWithWatermarkGenerator

    @Internal
    public class KafkaTopicPartitionState<T,​KPH>
    extends Object
    The state that the Flink Kafka Consumer holds for each Kafka partition. Includes the Kafka descriptor for partitions.

    This class describes the most basic state (only the offset), subclasses define more elaborate state, containing current watermarks and timestamp extractors.

    • Constructor Detail

      • KafkaTopicPartitionState

        public KafkaTopicPartitionState​(KafkaTopicPartition partition,
                                        KPH kafkaPartitionHandle)
    • Method Detail

      • getKafkaTopicPartition

        public final KafkaTopicPartition getKafkaTopicPartition()
        Gets Flink's descriptor for the Kafka Partition.
        Returns:
        The Flink partition descriptor.
      • getKafkaPartitionHandle

        public final KPH getKafkaPartitionHandle()
        Gets Kafka's descriptor for the Kafka Partition.
        Returns:
        The Kafka partition descriptor.
      • getTopic

        public final String getTopic()
      • getPartition

        public final int getPartition()
      • getOffset

        public final long getOffset()
        The current offset in the partition. This refers to the offset last element that we retrieved and emitted successfully. It is the offset that should be stored in a checkpoint.
      • setOffset

        public final void setOffset​(long offset)
      • isOffsetDefined

        public final boolean isOffsetDefined()
      • setCommittedOffset

        public final void setCommittedOffset​(long offset)
      • getCommittedOffset

        public final long getCommittedOffset()
      • extractTimestamp

        public long extractTimestamp​(T record,
                                     long kafkaEventTimestamp)
      • onEvent

        public void onEvent​(T event,
                            long timestamp)
      • onPeriodicEmit

        public void onPeriodicEmit()