Class LeaderProducedRecordContext

java.lang.Object
com.linkedin.davinci.kafka.consumer.LeaderProducedRecordContext
All Implemented Interfaces:
Measurable

public class LeaderProducedRecordContext extends Object implements Measurable
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 Details

    • newControlMessageRecord

      public static LeaderProducedRecordContext newControlMessageRecord(int consumedKafkaClusterId, long consumedOffset, byte[] keyBytes, ControlMessage valueUnion)
    • newControlMessageRecord

      public static LeaderProducedRecordContext newControlMessageRecord(byte[] keyBytes, ControlMessage valueUnion)
    • newPutRecord

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

      public static LeaderProducedRecordContext newChunkPutRecord(byte[] keyBytes, Put valueUnion)
    • newChunkDeleteRecord

      public static LeaderProducedRecordContext newChunkDeleteRecord(byte[] keyBytes, Delete valueUnion)
    • newPutRecordWithFuture

      public static LeaderProducedRecordContext newPutRecordWithFuture(int consumedKafkaClusterId, long consumedOffset, byte[] keyBytes, Put valueUnion, CompletableFuture<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()
    • getMessageType

      public MessageType getMessageType()
    • getKeyBytes

      public byte[] getKeyBytes()
    • getValueUnion

      public Object getValueUnion()
    • getProducedOffset

      public long getProducedOffset()
    • setProducedTimestampMs

      public void setProducedTimestampMs(long timeMs)
    • getProducedTimestampMs

      public long getProducedTimestampMs()
    • getPersistedToDBFuture

      public CompletableFuture<Void> getPersistedToDBFuture()
    • completePersistedToDBFuture

      public void completePersistedToDBFuture(Exception e)
    • toString

      public String toString()
      Overrides:
      toString in class 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)
    • getHeapSize

      public int getHeapSize()
      Specified by:
      getHeapSize in interface Measurable