Class LeaderProducedRecordContext
- java.lang.Object
-
- com.linkedin.davinci.kafka.consumer.LeaderProducedRecordContext
-
- All Implemented Interfaces:
Measurable
public class LeaderProducedRecordContext extends java.lang.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
completePersistedToDBFuture(java.lang.Exception e)
int
getConsumedKafkaClusterId()
long
getConsumedOffset()
int
getHeapSize()
byte[]
getKeyBytes()
MessageType
getMessageType()
java.util.concurrent.CompletableFuture<java.lang.Void>
getPersistedToDBFuture()
long
getProducedOffset()
long
getProducedTimestampMs()
java.lang.Object
getValueUnion()
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.static LeaderProducedRecordContext
newChunkDeleteRecord(byte[] keyBytes, Delete valueUnion)
static LeaderProducedRecordContext
newChunkPutRecord(byte[] keyBytes, Put valueUnion)
static LeaderProducedRecordContext
newControlMessageRecord(byte[] keyBytes, ControlMessage valueUnion)
static LeaderProducedRecordContext
newControlMessageRecord(int consumedKafkaClusterId, long consumedOffset, byte[] keyBytes, ControlMessage valueUnion)
static LeaderProducedRecordContext
newDeleteRecord(int consumedKafkaClusterId, long consumedOffset, byte[] keyBytes, Delete valueUnion)
static LeaderProducedRecordContext
newPutRecord(int consumedKafkaClusterId, long consumedOffset, byte[] keyBytes, Put valueUnion)
static LeaderProducedRecordContext
newPutRecordWithFuture(int consumedKafkaClusterId, long consumedOffset, byte[] keyBytes, Put valueUnion, java.util.concurrent.CompletableFuture<java.lang.Void> persistedToDBFuture)
void
setKeyBytes(byte[] keyBytes)
void
setProducedOffset(long producerOffset)
void
setProducedTimestampMs(long timeMs)
java.lang.String
toString()
-
-
-
Method Detail
-
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, 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()
-
getMessageType
public MessageType getMessageType()
-
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 classjava.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)
-
getHeapSize
public int getHeapSize()
- Specified by:
getHeapSize
in interfaceMeasurable
-
-