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 SummaryNested ClassesModifier and TypeClassDescriptionstatic interfacestatic class
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionPartitionTracker(String topicName, int partition, PubSubPositionDeserializer pubSubPositionDeserializer) 
- 
Method SummaryModifier 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- 
PartitionTrackerpublic PartitionTracker(String topicName, int partition, PubSubPositionDeserializer pubSubPositionDeserializer) 
 
- 
- 
Method Details- 
getPartitionpublic int getPartition()
- 
getLatestConsumedVtPosition
- 
updateLatestConsumedVtPosition
- 
toString
- 
clearSegments
- 
setPartitionStatepublic void setPartitionState(PartitionTracker.TopicType type, OffsetRecord offsetRecord, long maxAgeInMs) 
- 
setPartitionStatepublic void setPartitionState(PartitionTracker.TopicType type, Map<CharSequence, ProducerPartitionState> producerPartitionStateMap, long minimumRequiredRecordProducerTimestamp) 
- 
getPartitionStates
- 
cloneVtProducerStatesClone the vtSegments and LCVP to the destination PartitionTracker. May be called concurrently.
- 
cloneRtProducerStatesClone the rtSegments to the destination PartitionTracker. Filter by brokerUrl. May be called concurrently.
- 
setProducerStatepublic void setProducerState(OffsetRecord offsetRecord, PartitionTracker.TopicType type, GUID guid, ProducerPartitionState state) 
- 
updateOffsetRecord
- 
validateMessagepublic 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.
 
- 
checkMissingMessagepublic void checkMissingMessage(PartitionTracker.TopicType type, DefaultPubSubMessage consumerRecord, Optional<PartitionTracker.DIVErrorMetricCallback> errorMetricCallback, long kafkaLogCompactionDelayInMs) throws DataValidationException - Throws:
- DataValidationException
 
- 
removeProducerStatepublic void removeProducerState(PartitionTracker.TopicType type, GUID guid, OffsetRecord offsetRecord) 
 
-