Package com.linkedin.davinci.consumer
Class VeniceAfterImageConsumerImpl<K,V>
java.lang.Object
com.linkedin.davinci.consumer.VeniceChangelogConsumerImpl<K,V>
com.linkedin.davinci.consumer.VeniceAfterImageConsumerImpl<K,V>
- All Implemented Interfaces:
VeniceChangelogConsumer<K,,V> AutoCloseable
-
Nested Class Summary
Nested classes/interfaces inherited from class com.linkedin.davinci.consumer.VeniceChangelogConsumerImpl
VeniceChangelogConsumerImpl.HeartbeatReporterThread -
Field Summary
Fields inherited from class com.linkedin.davinci.consumer.VeniceChangelogConsumerImpl
changeCaptureStats, changelogClientConfig, chunkAssembler, clientRegionName, compressorFactory, consumedHeartbeatTimestampsForSeek, consumerOffsetCommitEnabled, consumerOffsetCommitIntervalMs, consumerOffsetCommitTimeout, consumerSequenceIdGeneratorMap, consumerSequenceIdStartingValue, heartbeatReporterThread, heartbeatTimestampsForLagMonitoring, isSubscribed, keyDeserializer, onGoingVersionSwapSignal, partitionToBootstrapState, partitionToSubscribeTime, pubSubConsumer, pubSubMessageDeserializer, pubSubTopicNameToCompressorMap, pubSubTopicRepository, seekExecutorService, startTimestamp, storeDeserializerCache, storeName, storeRepository, subscriptionLock, time, totalRegionCount, versionSwapByControlMessage, versionSwapMessageState, versionSwapTimeoutInMs -
Constructor Summary
ConstructorsModifierConstructorDescriptionVeniceAfterImageConsumerImpl(ChangelogClientConfig changelogClientConfig, PubSubConsumerAdapter consumer, PubSubMessageDeserializer pubSubMessageDeserializer, VeniceChangelogConsumerClientFactory veniceChangelogConsumerClientFactory) protectedVeniceAfterImageConsumerImpl(ChangelogClientConfig changelogClientConfig, PubSubConsumerAdapter consumer, Lazy<PubSubConsumerAdapter> seekConsumer, PubSubMessageDeserializer pubSubMessageDeserializer, VeniceChangelogConsumerClientFactory veniceChangelogConsumerClientFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidadjustSeekCheckPointsBasedOnHeartbeats(Map<Integer, VeniceChangeCoordinate> checkpoints, Map<Integer, Long> heartbeatTimestamps, PubSubConsumerAdapter consumerAdapter, List<PubSubTopicPartition> topicPartitionList) voidclose()Releases the internal resources.protected voidUsed byVersionSwapDataChangeListenerto propagate version swap exceptions to prevent silent thread termination.protected CompletableFuture<Void>internalFindNewVersionCheckpoints(String oldVersionTopic, String newVersionTopic, long generationId, Set<Integer> partitions) Similar tointernalSeekToEndOfPush(java.util.Set<java.lang.Integer>, com.linkedin.venice.pubsub.api.PubSubTopic, boolean)exception in addition to finding the EOP of each partition we will also be looking for the first relevant version swap.protected CompletableFuture<Void>internalSeek(Set<Integer> partitions, PubSubTopic targetTopic, com.linkedin.davinci.consumer.VeniceChangelogConsumerImpl.SeekPositionResolver positionResolver, boolean isInclusive) protected CompletableFuture<Void>internalSeekToEndOfPush(Set<Integer> partitions, PubSubTopic targetTopic, boolean trackHeartbeats) poll(long timeoutInMs) Polling function to get any available messages from the underlying system for all partitions subscribed.protected voidConsumers can start consuming throughVeniceChangelogConsumerImpl.subscribe(java.util.Set<java.lang.Integer>)or any of the seek methods, and the version swap listener is the only version swap mechanism when version swap by control message is disabled.seekToEndOfPush(Set<Integer> partitions) Seek to the end of the last push for a given set of partitions.voidbooleanMethods inherited from class com.linkedin.davinci.consumer.VeniceChangelogConsumerImpl
commitOffsets, convertPubSubMessageToChangeEvent, executeSeekTask, getChangeCaptureStats, getCurrentServingVersionTopic, getHeartbeatReporterThread, getLastHeartbeatPerPartition, getNextConsumerSequenceId, getPartitionCount, getPartitionListToSubscribe, getSubscribeTime, getTopicAssignment, getVersionCompressor, handleControlMessage, handleVersionSwapMessageInVT, internalPoll, internalPoll, internalSeekToTimestamps, internalSeekToTimestamps, internalSubscribe, internalUnsubscribe, isCaughtUp, pause, pause, resolveSeekPositionWithRetry, resume, resume, seekToBeginningOfPush, seekToBeginningOfPush, seekToCheckpoint, seekToEndOfPush, seekToTail, seekToTail, seekToTimestamp, seekToTimestamps, setVersionSwapListener, subscribe, subscribeAll, switchToNewTopic, synchronousSeek, synchronousSeekToCheckpoint, synchronousSeekToCheckpoint, throwIfReadsDisabled, unsubscribe, unsubscribeAll
-
Constructor Details
-
VeniceAfterImageConsumerImpl
public VeniceAfterImageConsumerImpl(ChangelogClientConfig changelogClientConfig, PubSubConsumerAdapter consumer, PubSubMessageDeserializer pubSubMessageDeserializer, VeniceChangelogConsumerClientFactory veniceChangelogConsumerClientFactory) -
VeniceAfterImageConsumerImpl
protected VeniceAfterImageConsumerImpl(ChangelogClientConfig changelogClientConfig, PubSubConsumerAdapter consumer, Lazy<PubSubConsumerAdapter> seekConsumer, PubSubMessageDeserializer pubSubMessageDeserializer, VeniceChangelogConsumerClientFactory veniceChangelogConsumerClientFactory)
-
-
Method Details
-
poll
Description copied from interface:VeniceChangelogConsumerPolling function to get any available messages from the underlying system for all partitions subscribed.- Specified by:
pollin interfaceVeniceChangelogConsumer<K,V> - Overrides:
pollin classVeniceChangelogConsumerImpl<K,V> - Parameters:
timeoutInMs- The maximum time to block/wait in between two polling requests (must not be greater thanLong.MAX_VALUEmilliseconds)- Returns:
- a collection of messages since the last fetch for the subscribed list of topic partitions
-
prepareForConsumption
protected void prepareForConsumption()Consumers can start consuming throughVeniceChangelogConsumerImpl.subscribe(java.util.Set<java.lang.Integer>)or any of the seek methods, and the version swap listener is the only version swap mechanism when version swap by control message is disabled. The shared startup hook validates reads and subscribes the store before registering this listener at most once per consumer.- Overrides:
prepareForConsumptionin classVeniceChangelogConsumerImpl<K,V>
-
adjustSeekCheckPointsBasedOnHeartbeats
protected static void adjustSeekCheckPointsBasedOnHeartbeats(Map<Integer, VeniceChangeCoordinate> checkpoints, Map<Integer, Long> heartbeatTimestamps, PubSubConsumerAdapter consumerAdapter, List<PubSubTopicPartition> topicPartitionList) -
internalFindNewVersionCheckpoints
protected CompletableFuture<Void> internalFindNewVersionCheckpoints(String oldVersionTopic, String newVersionTopic, long generationId, Set<Integer> partitions) Similar tointernalSeekToEndOfPush(java.util.Set<java.lang.Integer>, com.linkedin.venice.pubsub.api.PubSubTopic, boolean)exception in addition to finding the EOP of each partition we will also be looking for the first relevant version swap. This can also be optimized later for a faster find.- Overrides:
internalFindNewVersionCheckpointsin classVeniceChangelogConsumerImpl<K,V>
-
internalSeekToEndOfPush
protected CompletableFuture<Void> internalSeekToEndOfPush(Set<Integer> partitions, PubSubTopic targetTopic, boolean trackHeartbeats) -
seekToEndOfPush
Description copied from interface:VeniceChangelogConsumerSeek to the end of the last push for a given set of partitions. This instructs the consumer to begin consuming events which are transmitted to Venice following the last batch push.- Specified by:
seekToEndOfPushin interfaceVeniceChangelogConsumer<K,V> - Overrides:
seekToEndOfPushin classVeniceChangelogConsumerImpl<K,V> - Parameters:
partitions- the set of partitions to seek with- Returns:
- a future which completes when the operation has succeeded for all partitions.
-
subscribed
public boolean subscribed() -
internalSeek
protected CompletableFuture<Void> internalSeek(Set<Integer> partitions, PubSubTopic targetTopic, com.linkedin.davinci.consumer.VeniceChangelogConsumerImpl.SeekPositionResolver positionResolver, boolean isInclusive) - Overrides:
internalSeekin classVeniceChangelogConsumerImpl<K,V>
-
setStoreRepository
- Overrides:
setStoreRepositoryin classVeniceChangelogConsumerImpl<K,V>
-
close
public void close()Description copied from interface:VeniceChangelogConsumerReleases the internal resources. This consumer instance cannot be restarted or sought after close. Create a new consumer fromVeniceChangelogConsumerClientFactoryto resume consumption.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceVeniceChangelogConsumer<K,V> - Overrides:
closein classVeniceChangelogConsumerImpl<K,V>
-
handleVersionSwapFailure
Used byVersionSwapDataChangeListenerto propagate version swap exceptions to prevent silent thread termination.
-