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

Commit 78dad41

Browse files
committed
restore files
1 parent a817081 commit 78dad41

3 files changed

Lines changed: 17 additions & 156 deletions

File tree

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

Lines changed: 5 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ public abstract class ConsistencyRequest {
4343
@Nullable
4444
public abstract String getConsistencyToken();
4545

46-
protected abstract boolean isFullyQualified();
47-
4846
public static ConsistencyRequest forReplication(String tableId) {
4947
return new AutoValue_ConsistencyRequest(
50-
tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, null, false);
48+
tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, null);
5149
}
5250

5351
/**
@@ -61,127 +59,37 @@ public static ConsistencyRequest forReplication(String tableId, String consisten
6159
Preconditions.checkNotNull(consistencyToken, "consistencyToken must not be null");
6260

6361
return new AutoValue_ConsistencyRequest(
64-
tableId,
65-
CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES,
66-
consistencyToken,
67-
false);
62+
tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, consistencyToken);
6863
}
6964

7065
public static ConsistencyRequest forDataBoost(String tableId) {
7166
return new AutoValue_ConsistencyRequest(
72-
tableId, CheckConsistencyRequest.ModeCase.DATA_BOOST_READ_LOCAL_WRITES, null, false);
73-
}
74-
75-
@InternalApi
76-
public static ConsistencyRequest forReplicationFromTableName(String tableName) {
77-
Preconditions.checkArgument(
78-
TableName.isParsableFrom(tableName), "tableName must be a fully qualified table name");
79-
return new AutoValue_ConsistencyRequest(
80-
tableName, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, null, true);
67+
tableId, CheckConsistencyRequest.ModeCase.DATA_BOOST_READ_LOCAL_WRITES, null);
8168
}
8269

83-
@InternalApi
84-
public static ConsistencyRequest forReplicationFromTableName(
85-
String tableName, String consistencyToken) {
86-
Preconditions.checkArgument(
87-
TableName.isParsableFrom(tableName), "tableName must be a fully qualified table name");
88-
Preconditions.checkNotNull(consistencyToken, "consistencyToken must not be null");
89-
90-
return new AutoValue_ConsistencyRequest(
91-
tableName,
92-
CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES,
93-
consistencyToken,
94-
true);
95-
}
96-
97-
private CheckConsistencyRequest.Builder buildBaseRequest(String name, String token) {
98-
CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder();
99-
100-
if (getMode().equals(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES)) {
101-
builder.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build());
102-
} else {
103-
builder.setDataBoostReadLocalWrites(DataBoostReadLocalWrites.newBuilder().build());
104-
}
105-
106-
return builder.setName(name).setConsistencyToken(token);
107-
}
108-
109-
/**
110-
* Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest was
111-
* initialized with a short table ID, relying on the TableAdminRequestContext to construct the
112-
* fully qualified table name.
113-
*/
11470
@InternalApi
11571
public CheckConsistencyRequest toCheckConsistencyProto(
11672
TableAdminRequestContext requestContext, String token) {
117-
Preconditions.checkState(
118-
!isFullyQualified(),
119-
"Use toCheckConsistencyProto(String token) for fully qualified table names.");
73+
CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder();
12074
TableName tableName =
12175
TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId());
12276

123-
return buildBaseRequest(tableName.toString(), token).build();
124-
}
125-
126-
/**
127-
* Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest was
128-
* initialized with a fully qualified table name, eliminating the need for a request context.
129-
*/
130-
@InternalApi
131-
public CheckConsistencyRequest toCheckConsistencyProto(String token) {
132-
Preconditions.checkState(
133-
isFullyQualified(),
134-
"Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table"
135-
+ " names.");
136-
137-
return buildBaseRequest(getTableId(), token).build();
138-
}
139-
140-
/**
141-
* Creates a GenerateConsistencyTokenRequest proto. This variant is used when the
142-
* ConsistencyRequest was initialized with a short table ID, relying on the
143-
* TableAdminRequestContext to construct the fully qualified table name.
144-
*/
145-
@InternalApi
146-
public CheckConsistencyRequest toCheckConsistencyProto(String token) {
147-
Preconditions.checkState(
148-
isFullyQualified(),
149-
"Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table"
150-
+ " names.");
151-
CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder();
152-
15377
if (getMode().equals(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES)) {
15478
builder.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build());
15579
} else {
15680
builder.setDataBoostReadLocalWrites(DataBoostReadLocalWrites.newBuilder().build());
15781
}
15882

159-
return builder.setName(getTableId()).setConsistencyToken(token).build();
83+
return builder.setName(tableName.toString()).setConsistencyToken(token).build();
16084
}
16185

16286
@InternalApi
16387
public GenerateConsistencyTokenRequest toGenerateTokenProto(
16488
TableAdminRequestContext requestContext) {
165-
Preconditions.checkState(
166-
!isFullyQualified(), "Use toGenerateTokenProto() for fully qualified table names.");
16789
GenerateConsistencyTokenRequest.Builder builder = GenerateConsistencyTokenRequest.newBuilder();
16890
TableName tableName =
16991
TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId());
17092

17193
return builder.setName(tableName.toString()).build();
17294
}
173-
174-
/**
175-
* Creates a GenerateConsistencyTokenRequest proto. This variant is used when the
176-
* ConsistencyRequest was initialized with a fully qualified table name, eliminating the need for
177-
* a request context.
178-
*/
179-
@InternalApi
180-
public GenerateConsistencyTokenRequest toGenerateTokenProto() {
181-
Preconditions.checkState(
182-
isFullyQualified(),
183-
"Use toGenerateTokenProto(TableAdminRequestContext) for non-qualified table names.");
184-
GenerateConsistencyTokenRequest.Builder builder = GenerateConsistencyTokenRequest.newBuilder();
185-
return builder.setName(getTableId()).build();
186-
}
18795
}

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

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.google.common.util.concurrent.MoreExecutors;
4343
import java.util.concurrent.Callable;
4444
import java.util.concurrent.CancellationException;
45-
import javax.annotation.Nullable;
4645

4746
/**
4847
* Callable that waits until either replication or Data Boost has caught up to the point it was
@@ -51,21 +50,21 @@
5150
* <p>This callable wraps GenerateConsistencyToken and CheckConsistency RPCs. It will generate a
5251
* token then poll until isConsistent is true.
5352
*/
54-
public class AwaitConsistencyCallable extends UnaryCallable<ConsistencyRequest, Void> {
53+
class AwaitConsistencyCallable extends UnaryCallable<ConsistencyRequest, Void> {
5554
private final UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse>
5655
generateCallable;
5756
private final UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable;
5857
private final RetryingExecutor<CheckConsistencyResponse> executor;
5958

60-
@Nullable private final TableAdminRequestContext requestContext;
59+
private final TableAdminRequestContext requestContext;
6160

62-
public static AwaitConsistencyCallable create(
61+
static AwaitConsistencyCallable create(
6362
UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse>
6463
generateCallable,
6564
UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable,
6665
ClientContext clientContext,
6766
RetrySettings pollingSettings,
68-
@Nullable TableAdminRequestContext requestContext) {
67+
TableAdminRequestContext requestContext) {
6968

7069
RetryAlgorithm<CheckConsistencyResponse> retryAlgorithm =
7170
new RetryAlgorithm<>(
@@ -79,22 +78,13 @@ public static AwaitConsistencyCallable create(
7978
generateCallable, checkCallable, retryingExecutor, requestContext);
8079
}
8180

82-
static AwaitConsistencyCallable create(
83-
UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse>
84-
generateCallable,
85-
UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable,
86-
ClientContext clientContext,
87-
RetrySettings pollingSettings) {
88-
return create(generateCallable, checkCallable, clientContext, pollingSettings, null);
89-
}
90-
9181
@VisibleForTesting
9282
AwaitConsistencyCallable(
9383
UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse>
9484
generateCallable,
9585
UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable,
9686
RetryingExecutor<CheckConsistencyResponse> executor,
97-
@Nullable TableAdminRequestContext requestContext) {
87+
TableAdminRequestContext requestContext) {
9888
this.generateCallable = generateCallable;
9989
this.checkCallable = checkCallable;
10090
this.executor = executor;
@@ -108,30 +98,22 @@ public ApiFuture<Void> futureCall(
10898
// If the token is already provided, skip generation and poll directly.
10999
if (consistencyRequest.getConsistencyToken() != null) {
110100
CheckConsistencyRequest request =
111-
requestContext == null
112-
? consistencyRequest.toCheckConsistencyProto(consistencyRequest.getConsistencyToken())
113-
: consistencyRequest.toCheckConsistencyProto(
114-
requestContext, consistencyRequest.getConsistencyToken());
101+
consistencyRequest.toCheckConsistencyProto(
102+
requestContext, consistencyRequest.getConsistencyToken());
115103
return pollToken(request, apiCallContext);
116104
}
117105

118106
ApiFuture<GenerateConsistencyTokenResponse> tokenFuture =
119-
generateToken(
120-
requestContext == null
121-
? consistencyRequest.toGenerateTokenProto()
122-
: consistencyRequest.toGenerateTokenProto(requestContext),
123-
apiCallContext);
107+
generateToken(consistencyRequest.toGenerateTokenProto(requestContext), apiCallContext);
124108

125109
return ApiFutures.transformAsync(
126110
tokenFuture,
127111
new ApiAsyncFunction<GenerateConsistencyTokenResponse, Void>() {
128112
@Override
129113
public ApiFuture<Void> apply(GenerateConsistencyTokenResponse input) {
130114
CheckConsistencyRequest request =
131-
requestContext == null
132-
? consistencyRequest.toCheckConsistencyProto(input.getConsistencyToken())
133-
: consistencyRequest.toCheckConsistencyProto(
134-
requestContext, input.getConsistencyToken());
115+
consistencyRequest.toCheckConsistencyProto(
116+
requestContext, input.getConsistencyToken());
135117
return pollToken(request, apiCallContext);
136118
}
137119
},

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

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,14 @@ public class EnhancedBigtableTableAdminStub extends GrpcBigtableTableAdminStub {
5454
private final BigtableTableAdminStubSettings settings;
5555
private final ClientContext clientContext;
5656

57-
@javax.annotation.Nullable private final TableAdminRequestContext requestContext;
57+
private final TableAdminRequestContext requestContext;
5858

5959
@Deprecated private final AwaitReplicationCallable awaitReplicationCallable;
6060

6161
private final AwaitConsistencyCallable awaitConsistencyCallable;
6262
private final OperationCallable<Void, Empty, OptimizeRestoredTableMetadata>
6363
optimizeRestoredTableOperationBaseCallable;
6464

65-
/**
66-
* Creates an instance of {@link EnhancedBigtableTableAdminStub} using the provided settings. This
67-
* variant is used by the V2 client stack which relies on fully qualified table names and
68-
* therefore does not require a {@link TableAdminRequestContext}.
69-
*
70-
* @param settings The settings used to configure the stub.
71-
* @return A new instance of {@code EnhancedBigtableTableAdminStub}.
72-
* @throws IOException If there are errors creating the underlying client context.
73-
*/
74-
public static EnhancedBigtableTableAdminStub createEnhanced(
75-
BigtableTableAdminStubSettings settings) throws IOException {
76-
return new EnhancedBigtableTableAdminStub(settings, ClientContext.create(settings), null);
77-
}
78-
79-
/**
80-
* Creates an instance of {@link EnhancedBigtableTableAdminStub} using the provided settings. This
81-
* variant is used by the legacy client stack which relies on short table IDs and requires a
82-
* {@link TableAdminRequestContext} to construct fully qualified table names.
83-
*
84-
* @param settings The settings used to configure the stub.
85-
* @param requestContext The context used to format short table IDs.
86-
* @return A new instance of {@code EnhancedBigtableTableAdminStub}.
87-
* @throws IOException If there are errors creating the underlying client context.
88-
*/
89-
public static EnhancedBigtableTableAdminStub createEnhanced(
90-
BigtableTableAdminStubSettings settings) throws IOException {
91-
return new EnhancedBigtableTableAdminStub(settings, ClientContext.create(settings), null);
92-
}
93-
9465
public static EnhancedBigtableTableAdminStub createEnhanced(
9566
BigtableTableAdminStubSettings settings, TableAdminRequestContext requestContext)
9667
throws IOException {
@@ -101,7 +72,7 @@ public static EnhancedBigtableTableAdminStub createEnhanced(
10172
private EnhancedBigtableTableAdminStub(
10273
BigtableTableAdminStubSettings settings,
10374
ClientContext clientContext,
104-
@javax.annotation.Nullable TableAdminRequestContext requestContext)
75+
TableAdminRequestContext requestContext)
10576
throws IOException {
10677
super(settings, clientContext);
10778

0 commit comments

Comments
 (0)