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
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkMissingMessage
(PartitionTracker.TopicType type, DefaultPubSubMessage consumerRecord, Optional<PartitionTracker.DIVErrorMetricCallback> errorMetricCallback, long kafkaLogCompactionDelayInMs) void
cloneProducerStates
(PartitionTracker destProducerTracker, String brokerUrl) Clone both vtSegment and rtSegment to the destination PartitionTracker.long
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
updateLatestConsumedVtOffset
(long offset) void
updateOffsetRecord
(PartitionTracker.TopicType type, OffsetRecord offsetRecord) void
validateMessage
(PartitionTracker.TopicType type, DefaultPubSubMessage 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() -
getLatestConsumedVtOffset
public long getLatestConsumedVtOffset() -
updateLatestConsumedVtOffset
public void updateLatestConsumedVtOffset(long offset) -
toString
-
setPartitionState
public void setPartitionState(PartitionTracker.TopicType type, OffsetRecord offsetRecord, long maxAgeInMs) -
getPartitionStates
-
cloneProducerStates
Clone both vtSegment and rtSegment to the destination PartitionTracker. May be called concurrently. -
setProducerState
public void setProducerState(OffsetRecord offsetRecord, PartitionTracker.TopicType type, GUID guid, ProducerPartitionState state) -
updateOffsetRecord
-
validateMessage
public void validateMessage(PartitionTracker.TopicType type, DefaultPubSubMessage consumerRecord, boolean endOfPushReceived, Lazy<Boolean> tolerateMissingMsgs) throws DataValidationException 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, DefaultPubSubMessage consumerRecord, Optional<PartitionTracker.DIVErrorMetricCallback> errorMetricCallback, long kafkaLogCompactionDelayInMs) throws DataValidationException - Throws:
DataValidationException
-
removeProducerState
public void removeProducerState(PartitionTracker.TopicType type, GUID guid, OffsetRecord offsetRecord)
-