Class LeaderProducedRecordContext
java.lang.Object
com.linkedin.davinci.kafka.consumer.LeaderProducedRecordContext
- All Implemented Interfaces:
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
Modifier and TypeMethodDescriptionvoid
int
long
int
byte[]
long
long
boolean
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, CompletableFuture<Void> persistedToDBFuture) void
setKeyBytes
(byte[] keyBytes) void
setProducedOffset
(long producerOffset) void
setProducedTimestampMs
(long timeMs) toString()
-
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
-
newChunkDeleteRecord
-
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
-
getKeyBytes
public byte[] getKeyBytes() -
getValueUnion
-
getProducedOffset
public long getProducedOffset() -
setProducedTimestampMs
public void setProducedTimestampMs(long timeMs) -
getProducedTimestampMs
public long getProducedTimestampMs() -
getPersistedToDBFuture
-
completePersistedToDBFuture
-
toString
-
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
-