Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit a3cf0a8

Browse files
committed
PR feedback 4
1 parent 33135ba commit a3cf0a8

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientV2.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ protected BigtableTableAdminClientV2(BaseBigtableTableAdminSettings settings) th
9494

9595
this.awaitConsistencyCallable =
9696
createAwaitConsistencyCallable(
97-
(BigtableTableAdminStubSettings) settings.getStubSettings(), lightweightContext);
97+
(BigtableTableAdminStubSettings) settings.getStubSettings(),
98+
settings.getStubSettings().getClock(),
99+
this.backgroundExecutor);
98100
this.optimizeRestoredTableOperationBaseCallable =
99101
createOptimizeRestoredTableOperationBaseCallable(lightweightContext);
100102
}
@@ -119,8 +121,9 @@ protected BigtableTableAdminClientV2(BigtableTableAdminStub stub) {
119121
}
120122

121123
private AwaitConsistencyCallable createAwaitConsistencyCallable(
122-
BigtableTableAdminStubSettings settings, com.google.api.gax.rpc.ClientContext clientContext)
123-
throws IOException {
124+
BigtableTableAdminStubSettings settings,
125+
com.google.api.core.ApiClock clock,
126+
java.util.concurrent.ScheduledExecutorService executor) {
124127
// TODO(igorbernstein2): expose polling settings
125128
RetrySettings pollingSettings =
126129
AWAIT_CONSISTENCY_POLLING_SETTINGS_BASE.toBuilder()
@@ -131,7 +134,8 @@ private AwaitConsistencyCallable createAwaitConsistencyCallable(
131134
return AwaitConsistencyCallable.create(
132135
getStub().generateConsistencyTokenCallable(),
133136
getStub().checkConsistencyCallable(),
134-
clientContext,
137+
clock,
138+
executor,
135139
pollingSettings);
136140
}
137141

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallable.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
package com.google.cloud.bigtable.admin.v2.stub;
1717

1818
import com.google.api.core.ApiAsyncFunction;
19+
import com.google.api.core.ApiClock;
1920
import com.google.api.core.ApiFunction;
2021
import com.google.api.core.ApiFuture;
2122
import com.google.api.core.ApiFutures;
23+
import com.google.api.core.InternalApi;
2224
import com.google.api.gax.retrying.ExponentialPollAlgorithm;
2325
import com.google.api.gax.retrying.NonCancellableFuture;
2426
import com.google.api.gax.retrying.ResultRetryAlgorithmWithContext;
@@ -30,7 +32,6 @@
3032
import com.google.api.gax.retrying.ScheduledRetryingExecutor;
3133
import com.google.api.gax.retrying.TimedAttemptSettings;
3234
import com.google.api.gax.rpc.ApiCallContext;
33-
import com.google.api.gax.rpc.ClientContext;
3435
import com.google.api.gax.rpc.UnaryCallable;
3536
import com.google.bigtable.admin.v2.CheckConsistencyRequest;
3637
import com.google.bigtable.admin.v2.CheckConsistencyResponse;
@@ -42,6 +43,7 @@
4243
import com.google.common.util.concurrent.MoreExecutors;
4344
import java.util.concurrent.Callable;
4445
import java.util.concurrent.CancellationException;
46+
import java.util.concurrent.ScheduledExecutorService;
4547
import javax.annotation.Nullable;
4648

4749
/**
@@ -51,6 +53,7 @@
5153
* <p>This callable wraps GenerateConsistencyToken and CheckConsistency RPCs. It will generate a
5254
* token then poll until isConsistent is true.
5355
*/
56+
@InternalApi
5457
public 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

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ private AwaitConsistencyCallable createAwaitConsistencyCallable() {
136136
return AwaitConsistencyCallable.create(
137137
generateConsistencyTokenCallable(),
138138
checkConsistencyCallable(),
139-
clientContext,
139+
clientContext.getClock(),
140+
clientContext.getExecutor(),
140141
pollingSettings,
141142
requestContext);
142143
}

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallableTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public void setUp() {
9797
AwaitConsistencyCallable.create(
9898
mockGenerateConsistencyTokenCallable,
9999
mockCheckConsistencyCallable,
100-
clientContext,
100+
clientContext.getClock(),
101+
clientContext.getExecutor(),
101102
retrySettings,
102103
REQUEST_CONTEXT);
103104
awaitReplicationCallable = AwaitReplicationCallable.create(awaitConsistencyCallable);

0 commit comments

Comments
 (0)