Package com.linkedin.davinci.validation
Class PartitionTracker
java.lang.Object
com.linkedin.davinci.validation.PartitionTracker
This class maintains state about all the upstream producers for a given partition.
It keeps track of the last segment, last sequence number and incrementally computed
checksum for each producer (identified by a producer GUID).
This class is thread safe. Locking is at the granularity of producers. Multiple threads can process records from the same partition concurrently.
This class also encapsulates the capability to clear expired state, in the functions which take in the maxAgeInMs parameter:
- clearExpiredStateAndUpdateOffsetRecord(TopicType, OffsetRecord, long)
- setPartitionState(TopicType, OffsetRecord, long)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkMissingMessage
(PartitionTracker.TopicType type, PubSubMessage<KafkaKey, KafkaMessageEnvelope, Long> consumerRecord, Optional<PartitionTracker.DIVErrorMetricCallback> errorMetricCallback, long kafkaLogCompactionDelayInMs) void
cloneProducerStates
(PartitionTracker destProducerTracker) int
void
removeProducerState
(PartitionTracker.TopicType type, GUID guid, OffsetRecord offsetRecord) void
setPartitionState
(PartitionTracker.TopicType type, OffsetRecord offsetRecord, long maxAgeInMs) void
setProducerState
(OffsetRecord offsetRecord, PartitionTracker.TopicType type, GUID guid, ProducerPartitionState state) final String
toString()
void
updateOffsetRecord
(PartitionTracker.TopicType type, OffsetRecord offsetRecord) void
validateMessage
(PartitionTracker.TopicType type, PubSubMessage<KafkaKey, KafkaMessageEnvelope, Long> consumerRecord, boolean endOfPushReceived, Lazy<Boolean> tolerateMissingMsgs) Ensures the integrity of the data by maintaining state about all the data produced by a specific upstream producer:
-
Field Details
-
VERSION_TOPIC
-
-
Constructor Details
-
PartitionTracker
-
-
Method Details
-
getPartition
public int getPartition() -
toString
-
setPartitionState
public void setPartitionState(PartitionTracker.TopicType type, OffsetRecord offsetRecord, long maxAgeInMs) -
cloneProducerStates
-
setProducerState
public void setProducerState(OffsetRecord offsetRecord, PartitionTracker.TopicType type, GUID guid, ProducerPartitionState state) -
updateOffsetRecord
-
validateMessage
public void validateMessage(PartitionTracker.TopicType type, PubSubMessage<KafkaKey, KafkaMessageEnvelope, throws DataValidationExceptionLong> consumerRecord, boolean endOfPushReceived, Lazy<Boolean> tolerateMissingMsgs) Ensures the integrity of the data by maintaining state about all the data produced by a specific upstream producer:1. Segment, which should be equal or greater to the previous segment. 2. Sequence number, which should be exactly one greater than the previous sequence number. 3. Checksum, which is computed incrementally until the end of a segment.
- Parameters:
consumerRecord
- the incoming Kafka message.- Throws:
DataValidationException
- if the DIV check failed.
-
checkMissingMessage
public void checkMissingMessage(PartitionTracker.TopicType type, PubSubMessage<KafkaKey, KafkaMessageEnvelope, throws DataValidationExceptionLong> consumerRecord, Optional<PartitionTracker.DIVErrorMetricCallback> errorMetricCallback, long kafkaLogCompactionDelayInMs) - Throws:
DataValidationException
-
removeProducerState
public void removeProducerState(PartitionTracker.TopicType type, GUID guid, OffsetRecord offsetRecord)
-