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 interfacestatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPartitionTracker(String topicName, int partition, PubSubPositionDeserializer pubSubPositionDeserializer) -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckMissingMessage(PartitionTracker.TopicType type, DefaultPubSubMessage consumerRecord, Optional<PartitionTracker.DIVErrorMetricCallback> errorMetricCallback, long kafkaLogCompactionDelayInMs) voidvoidcloneRtProducerStates(PartitionTracker destProducerTracker, String brokerUrl) Clone the rtSegments to the destination PartitionTracker.voidcloneVtProducerStates(PartitionTracker destProducerTracker) Clone the vtSegments and LCVP to the destination PartitionTracker.intvoidremoveProducerState(PartitionTracker.TopicType type, GUID guid, OffsetRecord offsetRecord) voidsetPartitionState(PartitionTracker.TopicType type, OffsetRecord offsetRecord, long maxAgeInMs) voidsetPartitionState(PartitionTracker.TopicType type, Map<CharSequence, ProducerPartitionState> producerPartitionStateMap, long minimumRequiredRecordProducerTimestamp) voidsetProducerState(OffsetRecord offsetRecord, PartitionTracker.TopicType type, GUID guid, ProducerPartitionState state) final StringtoString()voidupdateLatestConsumedVtPosition(PubSubPosition vtPosition) voidupdateOffsetRecord(PartitionTracker.TopicType type, OffsetRecord offsetRecord) voidvalidateMessage(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
public PartitionTracker(String topicName, int partition, PubSubPositionDeserializer pubSubPositionDeserializer)
-
-
Method Details
-
getPartition
public int getPartition() -
getLatestConsumedVtPosition
-
updateLatestConsumedVtPosition
-
toString
-
clearSegments
-
setPartitionState
public void setPartitionState(PartitionTracker.TopicType type, OffsetRecord offsetRecord, long maxAgeInMs) -
setPartitionState
public void setPartitionState(PartitionTracker.TopicType type, Map<CharSequence, ProducerPartitionState> producerPartitionStateMap, long minimumRequiredRecordProducerTimestamp) -
getPartitionStates
-
cloneVtProducerStates
Clone the vtSegments and LCVP to the destination PartitionTracker. May be called concurrently. -
cloneRtProducerStates
Clone the rtSegments to the destination PartitionTracker. Filter by brokerUrl. 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)
-