Class LeaderProducedRecordContext


  • public class LeaderProducedRecordContext
    extends java.lang.Object
    This class holds all the necessary context information which is passed from kafka consumer thread -> kafka producer callback thread -> drainer thread. All constructors are private by intention. This object should be created through the static utility function based on usecase. Internally these utility function fills up the consumedOffset, messageType, keyBytes, valueUnion. consumer thread and drainer thread creates this object by calling the appropriate static utility function based on message type. kafka producer callback thread fills up the producedOffset. drainer thread completes the persistedToDBFuture.
    • Method Detail

      • newPutRecord

        public static LeaderProducedRecordContext newPutRecord​(int consumedKafkaClusterId,
                                                               long consumedOffset,
                                                               byte[] keyBytes,
                                                               Put valueUnion)
      • newPutRecordWithFuture

        public static LeaderProducedRecordContext newPutRecordWithFuture​(int consumedKafkaClusterId,
                                                                         long consumedOffset,
                                                                         byte[] keyBytes,
                                                                         Put valueUnion,
                                                                         java.util.concurrent.CompletableFuture<java.lang.Void> persistedToDBFuture)
      • newDeleteRecord

        public static LeaderProducedRecordContext newDeleteRecord​(int consumedKafkaClusterId,
                                                                  long consumedOffset,
                                                                  byte[] keyBytes,
                                                                  Delete valueUnion)
      • setKeyBytes

        public void setKeyBytes​(byte[] keyBytes)
      • setProducedOffset

        public void setProducedOffset​(long producerOffset)
      • getConsumedKafkaClusterId

        public int getConsumedKafkaClusterId()
      • getConsumedOffset

        public long getConsumedOffset()
      • getKeyBytes

        public byte[] getKeyBytes()
      • getValueUnion

        public java.lang.Object getValueUnion()
      • getProducedOffset

        public long getProducedOffset()
      • setProducedTimestampMs

        public void setProducedTimestampMs​(long timeMs)
      • getProducedTimestampMs

        public long getProducedTimestampMs()
      • getPersistedToDBFuture

        public java.util.concurrent.CompletableFuture<java.lang.Void> getPersistedToDBFuture()
      • completePersistedToDBFuture

        public void completePersistedToDBFuture​(java.lang.Exception e)
      • toString

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

        public boolean hasCorrespondingUpstreamMessage()
        Some bookkeeping operations are intended to be performed only on messages produced by the leader which have a directly corresponding upstream message, and should be skipped for messages that are generated by the leader in the absence of a directly corresponding upstream. This function helps disambiguate these cases.
        Returns:
        true if the message produced by the leader has a directly corresponding upstream message false if the message does not (e.g. happens in cases of leader-generated chunks or TopicSwitch)