11package com .linkedin .davinci ;
22
3+ import com .linkedin .davinci .client .DaVinciSeekCheckpointInfo ;
34import com .linkedin .davinci .config .StoreBackendConfig ;
45import com .linkedin .davinci .config .VeniceServerConfig ;
56import com .linkedin .venice .exceptions .VeniceException ;
1415import com .linkedin .venice .utils .ConcurrentRef ;
1516import com .linkedin .venice .utils .ReferenceCounted ;
1617import com .linkedin .venice .utils .RegionUtils ;
17- import java .util .Collections ;
1818import java .util .HashMap ;
1919import java .util .HashSet ;
2020import java .util .List ;
@@ -137,44 +137,38 @@ private void setDaVinciFutureVersion(VersionBackend version) {
137137 }
138138
139139 public CompletableFuture <Void > subscribe (ComplementSet <Integer > partitions ) {
140- return subscribe (partitions , Optional .empty (), Collections . emptyMap (), null , Collections . emptyMap (), false );
140+ return subscribe (partitions , Optional .empty (), null );
141141 }
142142
143- public CompletableFuture <Void > seekToTimestamps (Long allPartitionTimestamp , Optional <Version > storeVersion ) {
144- return subscribe (
145- ComplementSet .universalSet (),
146- storeVersion ,
147- new HashMap <>(),
148- allPartitionTimestamp ,
149- Collections .emptyMap (),
150- false );
151- }
152-
153- public CompletableFuture <Void > seekToTail (Optional <Version > storeVersion ) {
154- return subscribe (ComplementSet .universalSet (), storeVersion , Collections .emptyMap (), null , new HashMap <>(), true );
155- }
143+ // public CompletableFuture<Void> seekToTimestamps(Long allPartitionTimestamp, Optional<Version> storeVersion) {
144+ // return subscribe(
145+ // ComplementSet.universalSet(),
146+ // storeVersion, null);
147+ // }
156148
157- public CompletableFuture <Void > seekToCheckPoints (
158- Map < Integer , PubSubPosition > checkpoints ,
149+ public CompletableFuture <Void > seekToCheckpoint (
150+ DaVinciSeekCheckpointInfo checkpointInfo ,
159151 Optional <Version > storeVersion ) {
160- return subscribe (
161- ComplementSet .wrap (checkpoints .keySet ()),
162- storeVersion ,
163- Collections .emptyMap (),
164- null ,
165- checkpoints ,
166- false );
152+ return subscribe (checkpointInfo .getPartitions (), storeVersion , checkpointInfo );
167153 }
168154
169- public CompletableFuture <Void > seekToTimestamps (Map <Integer , Long > timestamps , Optional <Version > storeVersion ) {
170- return subscribe (
171- ComplementSet .wrap (timestamps .keySet ()),
172- storeVersion ,
173- timestamps ,
174- null ,
175- Collections .emptyMap (),
176- false );
177- }
155+ // public CompletableFuture<Void> seekToTail(Optional<Version> storeVersion) {
156+ // return subscribe(ComplementSet.universalSet(), storeVersion, null);
157+ // }
158+
159+ // public CompletableFuture<Void> seekToCheckPoints(
160+ // Map<Integer, PubSubPosition> checkpoints,
161+ // Optional<Version> storeVersion) {
162+ // return subscribe(
163+ // ComplementSet.wrap(checkpoints.keySet()),
164+ // storeVersion, null);
165+ // }
166+
167+ // public CompletableFuture<Void> seekToTimestamps(Map<Integer, Long> timestamps, Optional<Version> storeVersion) {
168+ // return subscribe(
169+ // ComplementSet.wrap(timestamps.keySet()),
170+ // storeVersion, null);
171+ // }
178172
179173 private Version getCurrentVersion () {
180174 return backend .getVeniceCurrentVersion (storeName );
@@ -187,10 +181,7 @@ private Version getLatestNonFaultyVersion() {
187181 public synchronized CompletableFuture <Void > subscribe (
188182 ComplementSet <Integer > partitions ,
189183 Optional <Version > bootstrapVersion ,
190- Map <Integer , Long > timestamps ,
191- Long allPartitionsTimestamp ,
192- Map <Integer , PubSubPosition > positionMap ,
193- boolean seekToTails ) {
184+ DaVinciSeekCheckpointInfo checkpointInfo ) {
194185 if (daVinciCurrentVersion == null ) {
195186 setDaVinciCurrentVersion (new VersionBackend (backend , bootstrapVersion .orElseGet (() -> {
196187 Version version = getCurrentVersion ();
@@ -226,23 +217,26 @@ public synchronized CompletableFuture<Void> subscribe(
226217 if (daVinciFutureVersion == null ) {
227218 trySubscribeDaVinciFutureVersion ();
228219 } else {
229- daVinciFutureVersion .subscribe (partitions , timestamps , positionMap )
230- .whenComplete ((v , e ) -> trySwapDaVinciCurrentVersion (e ));
220+ daVinciFutureVersion .subscribe (partitions , null ).whenComplete ((v , e ) -> trySwapDaVinciCurrentVersion (e ));
231221 }
232222 }
233223
234224 VersionBackend savedVersion = daVinciCurrentVersion ;
235225 List <Integer > partitionList = daVinciCurrentVersion .getPartitions (partitions );
236- if (allPartitionsTimestamp != null ) {
226+ if (checkpointInfo .getAllPartitionsTimestamp () != null ) {
227+ Map <Integer , Long > timestamps = new HashMap <>();
237228 for (int partition : partitionList ) {
238- timestamps .put (partition , allPartitionsTimestamp );
229+ timestamps .put (partition , checkpointInfo . getAllPartitionsTimestamp () );
239230 }
240- } else if (seekToTails ) {
231+ checkpointInfo .setTimestampsMap (timestamps );
232+ } else if (checkpointInfo .isSeekToTail ()) {
233+ Map <Integer , PubSubPosition > positionMap = new HashMap <>();
241234 for (int partition : partitionList ) {
242235 positionMap .put (partition , PubSubSymbolicPosition .LATEST );
243236 }
237+ checkpointInfo .setPositionMap (positionMap );
244238 }
245- return daVinciCurrentVersion .subscribe (partitions , timestamps , positionMap ).exceptionally (e -> {
239+ return daVinciCurrentVersion .subscribe (partitions , checkpointInfo ).exceptionally (e -> {
246240 synchronized (this ) {
247241 addFaultyVersion (savedVersion , e );
248242 // Don't propagate failure to subscribe() caller, if future version has become current and is ready to
@@ -329,8 +323,7 @@ synchronized void trySubscribeDaVinciFutureVersion() {
329323 LOGGER .info ("Subscribing to future version {}" , targetVersion .kafkaTopicName ());
330324 setDaVinciFutureVersion (new VersionBackend (backend , targetVersion , stats ));
331325 // For future version subscription, we don't need to pass any timestamps or position map
332- daVinciFutureVersion .subscribe (subscription , Collections .emptyMap (), Collections .emptyMap ())
333- .whenComplete ((v , e ) -> trySwapDaVinciCurrentVersion (e ));
326+ daVinciFutureVersion .subscribe (subscription , null ).whenComplete ((v , e ) -> trySwapDaVinciCurrentVersion (e ));
334327 } else {
335328 LOGGER .info (
336329 "Skipping subscribe to future version: {} in region: {} because the target version status is: {} and the target regions are: {}" ,
0 commit comments