-
Notifications
You must be signed in to change notification settings - Fork 108
[client][da-vinci-client] Add seek to tails API in Seeking DVC client #2296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
majisourav99
wants to merge
17
commits into
linkedin:main
Choose a base branch
from
majisourav99:seeking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ac79db7
[client] Add seek to tails API in Seeking DVC client
majisourav99 68da113
[client] Add seek to tails API in Seeking DVC client
majisourav99 3956e53
[client] Add seek to tails API in Seeking DVC client
majisourav99 06dac59
[client] Add seek to tails API in Seeking DVC client
majisourav99 517f93a
[client] Add seek to tails API in Seeking DVC client
majisourav99 3337a54
fixed test
majisourav99 9ed5a86
fixed test
majisourav99 e197302
fixed test
majisourav99 d1a031f
fixed test
majisourav99 bb6daa9
fixed test
majisourav99 12fe73c
fixed test
majisourav99 8db1711
fixed test
majisourav99 7ae2835
fixed test
majisourav99 afab8ce
addressed comments
majisourav99 df709f1
addressed comments
majisourav99 c29260d
addressed comments
majisourav99 1dca6dd
addressed comments
majisourav99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,23 @@ | ||
| package com.linkedin.davinci; | ||
|
|
||
| import com.linkedin.davinci.client.DaVinciSeekCheckpointInfo; | ||
| import com.linkedin.davinci.config.StoreBackendConfig; | ||
| import com.linkedin.davinci.config.VeniceServerConfig; | ||
| import com.linkedin.venice.exceptions.VeniceException; | ||
| import com.linkedin.venice.meta.Store; | ||
| import com.linkedin.venice.meta.Version; | ||
| import com.linkedin.venice.meta.VersionStatus; | ||
| import com.linkedin.venice.pubsub.api.PubSubPosition; | ||
| import com.linkedin.venice.pubsub.api.PubSubSymbolicPosition; | ||
| import com.linkedin.venice.serialization.AvroStoreDeserializerCache; | ||
| import com.linkedin.venice.serialization.StoreDeserializerCache; | ||
| import com.linkedin.venice.utils.ComplementSet; | ||
| import com.linkedin.venice.utils.ConcurrentRef; | ||
| import com.linkedin.venice.utils.ReferenceCounted; | ||
| import com.linkedin.venice.utils.RegionUtils; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.Set; | ||
|
|
@@ -135,26 +137,13 @@ private void setDaVinciFutureVersion(VersionBackend version) { | |
| } | ||
|
|
||
| public CompletableFuture<Void> subscribe(ComplementSet<Integer> partitions) { | ||
| return subscribe(partitions, Optional.empty(), Collections.emptyMap(), null, Collections.emptyMap()); | ||
| return subscribe(partitions, Optional.empty(), null); | ||
| } | ||
|
|
||
| public CompletableFuture<Void> seekToTimestamps(Long allPartitionTimestamp, Optional<Version> storeVersion) { | ||
| return subscribe( | ||
| ComplementSet.universalSet(), | ||
| storeVersion, | ||
| new HashMap<>(), | ||
| allPartitionTimestamp, | ||
| Collections.emptyMap()); | ||
| } | ||
|
|
||
| public CompletableFuture<Void> seekToCheckPoints( | ||
| Map<Integer, PubSubPosition> checkpoints, | ||
| public CompletableFuture<Void> seekToCheckpoint( | ||
| DaVinciSeekCheckpointInfo checkpointInfo, | ||
| Optional<Version> storeVersion) { | ||
| return subscribe(ComplementSet.wrap(checkpoints.keySet()), storeVersion, Collections.emptyMap(), null, checkpoints); | ||
| } | ||
|
|
||
| public CompletableFuture<Void> seekToTimestamps(Map<Integer, Long> timestamps, Optional<Version> storeVersion) { | ||
| return subscribe(ComplementSet.wrap(timestamps.keySet()), storeVersion, timestamps, null, Collections.emptyMap()); | ||
| return subscribe(checkpointInfo.getPartitions(), storeVersion, checkpointInfo); | ||
| } | ||
|
|
||
| private Version getCurrentVersion() { | ||
|
|
@@ -168,9 +157,7 @@ private Version getLatestNonFaultyVersion() { | |
| public synchronized CompletableFuture<Void> subscribe( | ||
| ComplementSet<Integer> partitions, | ||
| Optional<Version> bootstrapVersion, | ||
| Map<Integer, Long> timestamps, | ||
| Long allPartitionsTimestamp, | ||
| Map<Integer, PubSubPosition> positionMap) { | ||
| DaVinciSeekCheckpointInfo checkpointInfo) { | ||
| if (daVinciCurrentVersion == null) { | ||
| setDaVinciCurrentVersion(new VersionBackend(backend, bootstrapVersion.orElseGet(() -> { | ||
| Version version = getCurrentVersion(); | ||
|
|
@@ -207,33 +194,44 @@ public synchronized CompletableFuture<Void> subscribe( | |
| if (daVinciFutureVersion == null) { | ||
| trySubscribeDaVinciFutureVersion(); | ||
| } else { | ||
| daVinciFutureVersion.subscribe(partitions, timestamps, allPartitionsTimestamp, positionMap) | ||
| .whenComplete((v, e) -> trySwapDaVinciCurrentVersion(e)); | ||
| daVinciFutureVersion.subscribe(partitions, null).whenComplete((v, e) -> trySwapDaVinciCurrentVersion(e)); | ||
| } | ||
| } | ||
|
|
||
| VersionBackend savedVersion = daVinciCurrentVersion; | ||
| return daVinciCurrentVersion.subscribe(partitions, timestamps, allPartitionsTimestamp, positionMap) | ||
| .exceptionally(e -> { | ||
| synchronized (this) { | ||
| addFaultyVersion(savedVersion, e); | ||
| // Don't propagate failure to subscribe() caller, if future version has become current and is ready to | ||
| // serve. | ||
| if (daVinciCurrentVersion != null && daVinciCurrentVersion.isReadyToServe(subscription)) { | ||
| return null; | ||
| } | ||
| } | ||
| throw (e instanceof CompletionException) ? (CompletionException) e : new CompletionException(e); | ||
| }) | ||
| .whenComplete((v, e) -> { | ||
| synchronized (this) { | ||
| if (e == null) { | ||
| LOGGER.info("Ready to serve partitions {} of {}", subscription, daVinciCurrentVersion); | ||
| } else { | ||
| LOGGER.warn("Failed to subscribe to partitions {} of {}", subscription, savedVersion, e); | ||
| } | ||
| } | ||
| }); | ||
| List<Integer> partitionList = daVinciCurrentVersion.getPartitions(partitions); | ||
| if (checkpointInfo != null && checkpointInfo.getAllPartitionsTimestamp() != null) { | ||
| Map<Integer, Long> timestamps = new HashMap<>(); | ||
| for (int partition: partitionList) { | ||
| timestamps.put(partition, checkpointInfo.getAllPartitionsTimestamp()); | ||
| } | ||
| checkpointInfo.setTimestampsMap(timestamps); | ||
| } else if (checkpointInfo != null && checkpointInfo.isSeekToTail()) { | ||
| Map<Integer, PubSubPosition> positionMap = new HashMap<>(); | ||
| for (int partition: partitionList) { | ||
| positionMap.put(partition, PubSubSymbolicPosition.LATEST); | ||
| } | ||
| checkpointInfo.setPositionMap(positionMap); | ||
| } | ||
| return daVinciCurrentVersion.subscribe(partitions, checkpointInfo).exceptionally(e -> { | ||
| synchronized (this) { | ||
| addFaultyVersion(savedVersion, e); | ||
| // Don't propagate failure to subscribe() caller, if future version has become current and is ready to | ||
| // serve. | ||
| if (daVinciCurrentVersion != null && daVinciCurrentVersion.isReadyToServe(subscription)) { | ||
| return null; | ||
| } | ||
| } | ||
| throw (e instanceof CompletionException) ? (CompletionException) e : new CompletionException(e); | ||
| }).whenComplete((v, e) -> { | ||
| synchronized (this) { | ||
| if (e == null) { | ||
| LOGGER.info("Ready to serve partitions {} of {}", subscription, daVinciCurrentVersion); | ||
| } else { | ||
| LOGGER.warn("Failed to subscribe to partitions {} of {}", subscription, savedVersion, e); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| public synchronized void unsubscribe(ComplementSet<Integer> partitions) { | ||
|
|
@@ -302,8 +300,7 @@ synchronized void trySubscribeDaVinciFutureVersion() { | |
| LOGGER.info("Subscribing to future version {}", targetVersion.kafkaTopicName()); | ||
| setDaVinciFutureVersion(new VersionBackend(backend, targetVersion, stats)); | ||
| // For future version subscription, we don't need to pass any timestamps or position map | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Can we update this comment please |
||
| daVinciFutureVersion.subscribe(subscription, Collections.emptyMap(), null, Collections.emptyMap()) | ||
| .whenComplete((v, e) -> trySwapDaVinciCurrentVersion(e)); | ||
| daVinciFutureVersion.subscribe(subscription, null).whenComplete((v, e) -> trySwapDaVinciCurrentVersion(e)); | ||
| } else { | ||
| LOGGER.info( | ||
| "Skipping subscribe to future version: {} in region: {} because the target version status is: {} and the target regions are: {}", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
.../da-vinci-client/src/main/java/com/linkedin/davinci/client/DaVinciSeekCheckpointInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package com.linkedin.davinci.client; | ||
|
|
||
| import com.linkedin.venice.exceptions.VeniceException; | ||
| import com.linkedin.venice.pubsub.api.PubSubPosition; | ||
| import com.linkedin.venice.utils.ComplementSet; | ||
| import java.util.Map; | ||
|
|
||
|
|
||
| public class DaVinciSeekCheckpointInfo { | ||
| private Long allPartitionsTimestamp; | ||
| private Map<Integer, PubSubPosition> postitionMap; | ||
| private Map<Integer, Long> timestampsMap; | ||
| private boolean seekToTail = false; | ||
|
|
||
| public DaVinciSeekCheckpointInfo( | ||
| Map<Integer, PubSubPosition> postitionMap, | ||
| Map<Integer, Long> timestampsMap, | ||
| Long allPartitionsTimestamp, | ||
| boolean seekToTail) { | ||
| this.allPartitionsTimestamp = allPartitionsTimestamp; | ||
| this.postitionMap = postitionMap; | ||
| this.timestampsMap = timestampsMap; | ||
| this.seekToTail = seekToTail; | ||
| int validCheckPointCount = 0; | ||
| if (allPartitionsTimestamp != null) { | ||
| validCheckPointCount++; | ||
| } | ||
| if (seekToTail) { | ||
| validCheckPointCount++; | ||
| } | ||
| if (timestampsMap != null) { | ||
| validCheckPointCount++; | ||
| } | ||
| if (postitionMap != null) { | ||
| validCheckPointCount++; | ||
| } | ||
| if (validCheckPointCount > 1) { | ||
| throw new VeniceException("Multiple checkpoint types are not supported"); | ||
| } | ||
| } | ||
|
|
||
| public Long getAllPartitionsTimestamp() { | ||
| return allPartitionsTimestamp; | ||
| } | ||
|
|
||
| public Map<Integer, PubSubPosition> getPostitionMap() { | ||
| return postitionMap; | ||
| } | ||
|
|
||
| public void setPositionMap(Map<Integer, PubSubPosition> postitionMap) { | ||
| this.postitionMap = postitionMap; | ||
| } | ||
|
|
||
| public void setTimestampsMap(Map<Integer, Long> timestampsMap) { | ||
| this.timestampsMap = timestampsMap; | ||
| } | ||
|
|
||
| public Map<Integer, Long> getTimestampsMap() { | ||
| return timestampsMap; | ||
| } | ||
|
|
||
| public boolean isSeekToTail() { | ||
| return seekToTail; | ||
| } | ||
|
|
||
| public ComplementSet<Integer> getPartitions() { | ||
| if (postitionMap != null) { | ||
| return ComplementSet.newSet(postitionMap.keySet()); | ||
| } else if (timestampsMap != null) { | ||
| return ComplementSet.newSet(timestampsMap.keySet()); | ||
| } else { | ||
| return ComplementSet.universalSet(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.