1616package com .google .cloud .bigtable .admin .v2 .stub ;
1717
1818import com .google .api .core .ApiAsyncFunction ;
19+ import com .google .api .core .ApiClock ;
1920import com .google .api .core .ApiFunction ;
2021import com .google .api .core .ApiFuture ;
2122import com .google .api .core .ApiFutures ;
23+ import com .google .api .core .InternalApi ;
2224import com .google .api .gax .retrying .ExponentialPollAlgorithm ;
2325import com .google .api .gax .retrying .NonCancellableFuture ;
2426import com .google .api .gax .retrying .ResultRetryAlgorithmWithContext ;
3032import com .google .api .gax .retrying .ScheduledRetryingExecutor ;
3133import com .google .api .gax .retrying .TimedAttemptSettings ;
3234import com .google .api .gax .rpc .ApiCallContext ;
33- import com .google .api .gax .rpc .ClientContext ;
3435import com .google .api .gax .rpc .UnaryCallable ;
3536import com .google .bigtable .admin .v2 .CheckConsistencyRequest ;
3637import com .google .bigtable .admin .v2 .CheckConsistencyResponse ;
4243import com .google .common .util .concurrent .MoreExecutors ;
4344import java .util .concurrent .Callable ;
4445import java .util .concurrent .CancellationException ;
46+ import java .util .concurrent .ScheduledExecutorService ;
4547import javax .annotation .Nullable ;
4648
4749/**
5153 * <p>This callable wraps GenerateConsistencyToken and CheckConsistency RPCs. It will generate a
5254 * token then poll until isConsistent is true.
5355 */
56+ @ InternalApi
5457public class AwaitConsistencyCallable extends UnaryCallable <ConsistencyRequest , Void > {
5558 private final UnaryCallable <GenerateConsistencyTokenRequest , GenerateConsistencyTokenResponse >
5659 generateCallable ;
@@ -59,33 +62,36 @@ public class AwaitConsistencyCallable extends UnaryCallable<ConsistencyRequest,
5962
6063 @ Nullable private final TableAdminRequestContext requestContext ;
6164
65+ @ InternalApi
6266 public static AwaitConsistencyCallable create (
6367 UnaryCallable <GenerateConsistencyTokenRequest , GenerateConsistencyTokenResponse >
6468 generateCallable ,
6569 UnaryCallable <CheckConsistencyRequest , CheckConsistencyResponse > checkCallable ,
66- ClientContext clientContext ,
70+ ApiClock clock ,
71+ ScheduledExecutorService executor ,
6772 RetrySettings pollingSettings ,
6873 @ Nullable TableAdminRequestContext requestContext ) {
6974
7075 RetryAlgorithm <CheckConsistencyResponse > retryAlgorithm =
7176 new RetryAlgorithm <>(
72- new PollResultAlgorithm (),
73- new ExponentialPollAlgorithm (pollingSettings , clientContext .getClock ()));
77+ new PollResultAlgorithm (), new ExponentialPollAlgorithm (pollingSettings , clock ));
7478
7579 RetryingExecutor <CheckConsistencyResponse > retryingExecutor =
76- new ScheduledRetryingExecutor <>(retryAlgorithm , clientContext . getExecutor () );
80+ new ScheduledRetryingExecutor <>(retryAlgorithm , executor );
7781
7882 return new AwaitConsistencyCallable (
7983 generateCallable , checkCallable , retryingExecutor , requestContext );
8084 }
8185
86+ @ InternalApi
8287 public static AwaitConsistencyCallable create (
8388 UnaryCallable <GenerateConsistencyTokenRequest , GenerateConsistencyTokenResponse >
8489 generateCallable ,
8590 UnaryCallable <CheckConsistencyRequest , CheckConsistencyResponse > checkCallable ,
86- ClientContext clientContext ,
91+ ApiClock clock ,
92+ ScheduledExecutorService executor ,
8793 RetrySettings pollingSettings ) {
88- return create (generateCallable , checkCallable , clientContext , pollingSettings , null );
94+ return create (generateCallable , checkCallable , clock , executor , pollingSettings , null );
8995 }
9096
9197 @ VisibleForTesting
0 commit comments