Class PartitionConsumptionState
java.lang.Object
com.linkedin.davinci.kafka.consumer.PartitionConsumptionState
This class is used to maintain internal state for consumption of each partition.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This immutable class holds a association between a key and value and the source offset of the consumed message. -
Constructor Summary
ConstructorDescriptionPartitionConsumptionState
(String replicaId, int partition, OffsetRecord offsetRecord, boolean hybrid) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIncPushVersionToPendingReportList
(String incPushVersion) void
void
boolean
void
void
long
long
byte[]
long
long
getLatestIgnoredUpstreamRTOffset
(String kafkaUrl) long
long
long
long
getLatestProcessedUpstreamRTOffset
(String kafkaUrl) long
long
long
getLatestRTOffsetTriedToProduceToVTMap
(String kafkaUrl) long
getLeaderConsumedUpstreamRTOffset
(String kafkaUrl) final LeaderFollowerStateType
long
getLeaderOffset
(String kafkaURL, PubSubTopicRepository pubSubTopicRepository) The caller of this API should be interested in which offset currently leader should consume from now.int
long
boolean
long
getTransientRecord
(byte[] key) int
Lazy<VeniceWriter<byte[],
byte[], byte[]>> boolean
void
incrementProcessedRecordSizeSinceLastSync
(int recordSize) void
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
final boolean
isHybrid()
boolean
boolean
boolean
isNearlineMetricsRecordingValid
(long producerTimeStampInMs) check to ignore calculating latency from pubsub broker to ready to serve for messages that are getting caught up from previous pushes.boolean
boolean
boolean
void
void
maybeUpdateExpectedChecksum
(byte[] key, Put put) Keep updating the checksum for key/value pair received from kafka PUT message.mayRemoveTransientRecord
(int kafkaClusterId, long kafkaConsumedOffset, byte[] key) This operation is performed atomically to delete the record only when the provided sourceOffset matches.void
This persists to the offsetRecord associated to this partitionConsumptionState that the ready to serve check has passed.void
void
void
void
setConsumeRemotely
(boolean isConsumingRemotely) void
setDataRecoveryCompleted
(boolean dataRecoveryCompleted) void
setDeferredWrite
(boolean deferredWrite) void
setEndOfPushTimestamp
(long endOfPushTimestamp) void
setLastLeaderCompleteStateUpdateInMs
(long lastLeaderCompleteStateUpdateInMs) void
setLastLeaderPersistFuture
(Future<Void> future) void
setLastQueuedRecordPersistedFuture
(CompletableFuture<Void> lastQueuedRecordPersistedFuture) void
setLastVTProduceCallFuture
(CompletableFuture<Void> lastVTProduceCallFuture) void
setLatestMessageConsumedTimestampInMs
(long consumedTimestampInMs) void
setLatestPolledMessageTimestampInMs
(long timestampInMs) void
setLeaderCompleteState
(LeaderCompleteState leaderCompleteState) void
void
setLeaderGUID
(GUID leaderGUID) void
setLeaderHostId
(String hostId) void
setSkipKafkaMessage
(boolean skipKafkaMessage) void
setStartOfPushTimestamp
(long startOfPushTimestamp) void
setTopicSwitch
(TopicSwitchWrapper topicSwitch) Update the in-memory state for TopicSwitch whenever encounter a new TopicSwitch message or after a restart.void
setTransientRecord
(int kafkaClusterId, long kafkaConsumedOffset, byte[] key, byte[] value, int valueOffset, int valueLen, int valueSchemaId, org.apache.avro.generic.GenericRecord replicationMetadataRecord) void
setTransientRecord
(int kafkaClusterId, long kafkaConsumedOffset, byte[] key, int valueSchemaId, org.apache.avro.generic.GenericRecord replicationMetadataRecord) void
setVeniceWriterLazyRef
(Lazy<VeniceWriter<byte[], byte[], byte[]>> veniceWriterLazyRef) boolean
toString()
void
void
updateLatestIgnoredUpstreamRTOffset
(String kafkaUrl, long offset) void
updateLatestProcessedLocalVersionTopicOffset
(long offset) void
updateLatestProcessedUpstreamRTOffset
(String kafkaUrl, long offset) void
updateLatestProcessedUpstreamVersionTopicOffset
(long offset) void
updateLatestRTOffsetTriedToProduceToVTMap
(String kafkaUrl, long offset) void
updateLeaderConsumedUpstreamRTOffset
(String kafkaUrl, long offset)
-
Constructor Details
-
PartitionConsumptionState
public PartitionConsumptionState(String replicaId, int partition, OffsetRecord offsetRecord, boolean hybrid)
-
-
Method Details
-
getPartition
public int getPartition() -
getLastVTProduceCallFuture
-
setLastVTProduceCallFuture
-
getOffsetRecord
-
setDeferredWrite
public void setDeferredWrite(boolean deferredWrite) -
isDeferredWrite
public boolean isDeferredWrite() -
isStarted
public boolean isStarted() -
isEndOfPushReceived
public final boolean isEndOfPushReceived() -
isWaitingForReplicationLag
public boolean isWaitingForReplicationLag() -
lagHasCaughtUp
public void lagHasCaughtUp() -
hasLagCaughtUp
public boolean hasLagCaughtUp() -
isNearlineMetricsRecordingValid
public boolean isNearlineMetricsRecordingValid(long producerTimeStampInMs) check to ignore calculating latency from pubsub broker to ready to serve for messages that are getting caught up from previous pushes.- Parameters:
producerTimeStampInMs
- timestamp of the message
-
isCompletionReported
public boolean isCompletionReported() -
completionReported
public void completionReported() -
isSubscribed
public boolean isSubscribed() -
unsubscribe
public void unsubscribe() -
isLatchReleased
public boolean isLatchReleased() -
releaseLatch
public void releaseLatch() -
errorReported
public void errorReported() -
isErrorReported
public boolean isErrorReported() -
isComplete
public boolean isComplete() -
isHybrid
public final boolean isHybrid() -
isBatchOnly
public boolean isBatchOnly() -
toString
-
getProcessedRecordSizeSinceLastSync
public long getProcessedRecordSizeSinceLastSync() -
incrementProcessedRecordSizeSinceLastSync
public void incrementProcessedRecordSizeSinceLastSync(int recordSize) -
resetProcessedRecordSizeSinceLastSync
public void resetProcessedRecordSizeSinceLastSync() -
setLeaderFollowerState
-
getLeaderFollowerState
-
setLastLeaderPersistFuture
-
getLastLeaderPersistFuture
-
getLastQueuedRecordPersistedFuture
-
setLastQueuedRecordPersistedFuture
public void setLastQueuedRecordPersistedFuture(CompletableFuture<Void> lastQueuedRecordPersistedFuture) -
setTopicSwitch
Update the in-memory state for TopicSwitch whenever encounter a new TopicSwitch message or after a restart. -
getTopicSwitch
-
setConsumeRemotely
public void setConsumeRemotely(boolean isConsumingRemotely) -
consumeRemotely
public boolean consumeRemotely() -
initializeExpectedChecksum
public void initializeExpectedChecksum() -
finalizeExpectedChecksum
public void finalizeExpectedChecksum() -
getVeniceWriterLazyRef
-
setVeniceWriterLazyRef
-
maybeUpdateExpectedChecksum
Keep updating the checksum for key/value pair received from kafka PUT message. If the checksum instance is not configured viainitializeExpectedChecksum()
then do nothing. This api will keep the caller's code clean.- Parameters:
key
-put
-
-
resetExpectedChecksum
public void resetExpectedChecksum() -
getExpectedChecksum
public byte[] getExpectedChecksum() -
getLatestMessageConsumedTimestampInMs
public long getLatestMessageConsumedTimestampInMs() -
setLatestMessageConsumedTimestampInMs
public void setLatestMessageConsumedTimestampInMs(long consumedTimestampInMs) -
getLatestPolledMessageTimestampInMs
public long getLatestPolledMessageTimestampInMs() -
setLatestPolledMessageTimestampInMs
public void setLatestPolledMessageTimestampInMs(long timestampInMs) -
getConsumptionStartTimeInMs
public long getConsumptionStartTimeInMs() -
setTransientRecord
public void setTransientRecord(int kafkaClusterId, long kafkaConsumedOffset, byte[] key, int valueSchemaId, org.apache.avro.generic.GenericRecord replicationMetadataRecord) -
setTransientRecord
public void setTransientRecord(int kafkaClusterId, long kafkaConsumedOffset, byte[] key, byte[] value, int valueOffset, int valueLen, int valueSchemaId, org.apache.avro.generic.GenericRecord replicationMetadataRecord) -
getTransientRecord
-
mayRemoveTransientRecord
public PartitionConsumptionState.TransientRecord mayRemoveTransientRecord(int kafkaClusterId, long kafkaConsumedOffset, byte[] key) This operation is performed atomically to delete the record only when the provided sourceOffset matches.- Parameters:
kafkaClusterId
-kafkaConsumedOffset
-key
-- Returns:
-
getSourceTopicPartition
-
getTransientRecordMapSize
public int getTransientRecordMapSize() -
skipKafkaMessage
public boolean skipKafkaMessage() -
setSkipKafkaMessage
public void setSkipKafkaMessage(boolean skipKafkaMessage) -
recordReadyToServeInOffsetRecord
public void recordReadyToServeInOffsetRecord()This persists to the offsetRecord associated to this partitionConsumptionState that the ready to serve check has passed. This will be persisted to disk once the offsetRecord is checkpointed, and subsequent restarts will consult this information when determining if the node should come online or not to serve traffic -
getReadyToServeInOffsetRecord
public boolean getReadyToServeInOffsetRecord() -
updateLeaderConsumedUpstreamRTOffset
-
getLeaderConsumedUpstreamRTOffset
-
updateLatestProcessedUpstreamRTOffset
-
updateLatestRTOffsetTriedToProduceToVTMap
-
getLatestRTOffsetTriedToProduceToVTMap
-
updateLatestIgnoredUpstreamRTOffset
-
getLatestIgnoredUpstreamRTOffset
-
getLatestProcessedUpstreamRTOffsetWithIgnoredMessages
-
getLatestProcessedUpstreamRTOffset
-
getLatestProcessedUpstreamRTOffsetWithNoDefault
-
getLeaderOffset
The caller of this API should be interested in which offset currently leader should consume from now. 1. If currently leader should consume from real-time topic, return upstream RT offset; 2. if currently leader should consume from version topic, return either remote VT offset or local VT offset, depending on whether the remote consumption flag is on. -
setStartOfPushTimestamp
public void setStartOfPushTimestamp(long startOfPushTimestamp) -
getStartOfPushTimestamp
public long getStartOfPushTimestamp() -
setEndOfPushTimestamp
public void setEndOfPushTimestamp(long endOfPushTimestamp) -
getEndOfPushTimestamp
public long getEndOfPushTimestamp() -
updateLatestProcessedLocalVersionTopicOffset
public void updateLatestProcessedLocalVersionTopicOffset(long offset) -
getLatestProcessedLocalVersionTopicOffset
public long getLatestProcessedLocalVersionTopicOffset() -
updateLatestProcessedUpstreamVersionTopicOffset
public void updateLatestProcessedUpstreamVersionTopicOffset(long offset) -
getLatestProcessedUpstreamVersionTopicOffset
public long getLatestProcessedUpstreamVersionTopicOffset() -
setDataRecoveryCompleted
public void setDataRecoveryCompleted(boolean dataRecoveryCompleted) -
isDataRecoveryCompleted
public boolean isDataRecoveryCompleted() -
getLatestProcessedUpstreamRTOffsetMap
-
getLeaderGUID
-
setLeaderGUID
-
getLeaderHostId
-
setLeaderHostId
-
isLeaderCompleted
public boolean isLeaderCompleted() -
getLeaderCompleteState
-
setLeaderCompleteState
-
getLastLeaderCompleteStateUpdateInMs
public long getLastLeaderCompleteStateUpdateInMs() -
setLastLeaderCompleteStateUpdateInMs
public void setLastLeaderCompleteStateUpdateInMs(long lastLeaderCompleteStateUpdateInMs) -
getReplicaId
-
addIncPushVersionToPendingReportList
-
getPendingReportIncPushVersionList
-
clearPendingReportIncPushVersionList
public void clearPendingReportIncPushVersionList()
-