From b68d628de86acdc7aea3bdc7c15a7bb8f399fc24 Mon Sep 17 00:00:00 2001 From: Jin Seop Kim Date: Wed, 15 Apr 2026 14:35:08 -0400 Subject: [PATCH 1/5] refactor: decouple ConsistencyRequest from TableAdminRequestContext This commit updates the internal plumbing for `ConsistencyRequest` and `AwaitConsistencyCallable` to support fully qualified table names without breaking the existing public API for the legacy `BigtableTableAdminClient`. b/502616786 --- .../admin/v2/models/ConsistencyRequest.java | 45 +++++++++++++++++-- .../v2/stub/AwaitConsistencyCallable.java | 34 ++++++++++---- .../stub/EnhancedBigtableTableAdminStub.java | 10 ++++- 3 files changed, 77 insertions(+), 12 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java index f338776503..b463669603 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java @@ -43,9 +43,11 @@ public abstract class ConsistencyRequest { @Nullable public abstract String getConsistencyToken(); + protected abstract boolean isFullyQualified(); + public static ConsistencyRequest forReplication(String tableId) { return new AutoValue_ConsistencyRequest( - tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, null); + tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, null, false); } /** @@ -59,17 +61,32 @@ public static ConsistencyRequest forReplication(String tableId, String consisten Preconditions.checkNotNull(consistencyToken, "consistencyToken must not be null"); return new AutoValue_ConsistencyRequest( - tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, consistencyToken); + tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, consistencyToken, false); } public static ConsistencyRequest forDataBoost(String tableId) { return new AutoValue_ConsistencyRequest( - tableId, CheckConsistencyRequest.ModeCase.DATA_BOOST_READ_LOCAL_WRITES, null); + tableId, CheckConsistencyRequest.ModeCase.DATA_BOOST_READ_LOCAL_WRITES, null, false); + } + + @InternalApi + public static ConsistencyRequest forReplicationFromTableName(String tableName) { + return new AutoValue_ConsistencyRequest( + tableName, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, null, true); + } + + @InternalApi + public static ConsistencyRequest forReplicationFromTableName(String tableName, String consistencyToken) { + Preconditions.checkNotNull(consistencyToken, "consistencyToken must not be null"); + + return new AutoValue_ConsistencyRequest( + tableName, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, consistencyToken, true); } @InternalApi public CheckConsistencyRequest toCheckConsistencyProto( TableAdminRequestContext requestContext, String token) { + Preconditions.checkState(!isFullyQualified(), "Use toCheckConsistencyProto(String token) for fully qualified table names."); CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder(); TableName tableName = TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId()); @@ -83,13 +100,35 @@ public CheckConsistencyRequest toCheckConsistencyProto( return builder.setName(tableName.toString()).setConsistencyToken(token).build(); } + @InternalApi + public CheckConsistencyRequest toCheckConsistencyProto(String token) { + Preconditions.checkState(isFullyQualified(), "Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table names."); + CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder(); + + if (getMode().equals(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES)) { + builder.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build()); + } else { + builder.setDataBoostReadLocalWrites(DataBoostReadLocalWrites.newBuilder().build()); + } + + return builder.setName(getTableId()).setConsistencyToken(token).build(); + } + @InternalApi public GenerateConsistencyTokenRequest toGenerateTokenProto( TableAdminRequestContext requestContext) { + Preconditions.checkState(!isFullyQualified(), "Use toGenerateTokenProto() for fully qualified table names."); GenerateConsistencyTokenRequest.Builder builder = GenerateConsistencyTokenRequest.newBuilder(); TableName tableName = TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId()); return builder.setName(tableName.toString()).build(); } + + @InternalApi + public GenerateConsistencyTokenRequest toGenerateTokenProto() { + Preconditions.checkState(isFullyQualified(), "Use toGenerateTokenProto(TableAdminRequestContext) for non-qualified table names."); + GenerateConsistencyTokenRequest.Builder builder = GenerateConsistencyTokenRequest.newBuilder(); + return builder.setName(getTableId()).build(); + } } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallable.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallable.java index b4e42e2354..a8ccdd9704 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallable.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallable.java @@ -42,6 +42,7 @@ import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; +import javax.annotation.Nullable; /** * Callable that waits until either replication or Data Boost has caught up to the point it was @@ -56,7 +57,7 @@ class AwaitConsistencyCallable extends UnaryCallable { private final UnaryCallable checkCallable; private final RetryingExecutor executor; - private final TableAdminRequestContext requestContext; + @Nullable private final TableAdminRequestContext requestContext; static AwaitConsistencyCallable create( UnaryCallable @@ -64,7 +65,7 @@ static AwaitConsistencyCallable create( UnaryCallable checkCallable, ClientContext clientContext, RetrySettings pollingSettings, - TableAdminRequestContext requestContext) { + @Nullable TableAdminRequestContext requestContext) { RetryAlgorithm retryAlgorithm = new RetryAlgorithm<>( @@ -78,13 +79,22 @@ static AwaitConsistencyCallable create( generateCallable, checkCallable, retryingExecutor, requestContext); } + static AwaitConsistencyCallable create( + UnaryCallable + generateCallable, + UnaryCallable checkCallable, + ClientContext clientContext, + RetrySettings pollingSettings) { + return create(generateCallable, checkCallable, clientContext, pollingSettings, null); + } + @VisibleForTesting AwaitConsistencyCallable( UnaryCallable generateCallable, UnaryCallable checkCallable, RetryingExecutor executor, - TableAdminRequestContext requestContext) { + @Nullable TableAdminRequestContext requestContext) { this.generateCallable = generateCallable; this.checkCallable = checkCallable; this.executor = executor; @@ -98,13 +108,19 @@ public ApiFuture futureCall( // If the token is already provided, skip generation and poll directly. if (consistencyRequest.getConsistencyToken() != null) { CheckConsistencyRequest request = - consistencyRequest.toCheckConsistencyProto( - requestContext, consistencyRequest.getConsistencyToken()); + requestContext == null + ? consistencyRequest.toCheckConsistencyProto(consistencyRequest.getConsistencyToken()) + : consistencyRequest.toCheckConsistencyProto( + requestContext, consistencyRequest.getConsistencyToken()); return pollToken(request, apiCallContext); } ApiFuture tokenFuture = - generateToken(consistencyRequest.toGenerateTokenProto(requestContext), apiCallContext); + generateToken( + requestContext == null + ? consistencyRequest.toGenerateTokenProto() + : consistencyRequest.toGenerateTokenProto(requestContext), + apiCallContext); return ApiFutures.transformAsync( tokenFuture, @@ -112,8 +128,10 @@ public ApiFuture futureCall( @Override public ApiFuture apply(GenerateConsistencyTokenResponse input) { CheckConsistencyRequest request = - consistencyRequest.toCheckConsistencyProto( - requestContext, input.getConsistencyToken()); + requestContext == null + ? consistencyRequest.toCheckConsistencyProto(input.getConsistencyToken()) + : consistencyRequest.toCheckConsistencyProto( + requestContext, input.getConsistencyToken()); return pollToken(request, apiCallContext); } }, diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java index e68cafca54..79da312d37 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java @@ -54,6 +54,7 @@ public class EnhancedBigtableTableAdminStub extends GrpcBigtableTableAdminStub { private final BigtableTableAdminStubSettings settings; private final ClientContext clientContext; + @javax.annotation.Nullable private final TableAdminRequestContext requestContext; @Deprecated private final AwaitReplicationCallable awaitReplicationCallable; @@ -62,6 +63,13 @@ public class EnhancedBigtableTableAdminStub extends GrpcBigtableTableAdminStub { private final OperationCallable optimizeRestoredTableOperationBaseCallable; + public static EnhancedBigtableTableAdminStub createEnhanced( + BigtableTableAdminStubSettings settings) + throws IOException { + return new EnhancedBigtableTableAdminStub( + settings, ClientContext.create(settings), null); + } + public static EnhancedBigtableTableAdminStub createEnhanced( BigtableTableAdminStubSettings settings, TableAdminRequestContext requestContext) throws IOException { @@ -72,7 +80,7 @@ public static EnhancedBigtableTableAdminStub createEnhanced( private EnhancedBigtableTableAdminStub( BigtableTableAdminStubSettings settings, ClientContext clientContext, - TableAdminRequestContext requestContext) + @javax.annotation.Nullable TableAdminRequestContext requestContext) throws IOException { super(settings, clientContext); From 6e397230385e0286a644e7ae530d0b09be5caa80 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Wed, 15 Apr 2026 18:39:39 +0000 Subject: [PATCH 2/5] chore: generate libraries at Wed Apr 15 18:37:03 UTC 2026 --- .../admin/v2/models/ConsistencyRequest.java | 29 ++++++++++++++----- .../stub/EnhancedBigtableTableAdminStub.java | 9 ++---- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java index b463669603..7ed8c2d6bb 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java @@ -61,7 +61,10 @@ public static ConsistencyRequest forReplication(String tableId, String consisten Preconditions.checkNotNull(consistencyToken, "consistencyToken must not be null"); return new AutoValue_ConsistencyRequest( - tableId, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, consistencyToken, false); + tableId, + CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, + consistencyToken, + false); } public static ConsistencyRequest forDataBoost(String tableId) { @@ -76,17 +79,23 @@ public static ConsistencyRequest forReplicationFromTableName(String tableName) { } @InternalApi - public static ConsistencyRequest forReplicationFromTableName(String tableName, String consistencyToken) { + public static ConsistencyRequest forReplicationFromTableName( + String tableName, String consistencyToken) { Preconditions.checkNotNull(consistencyToken, "consistencyToken must not be null"); return new AutoValue_ConsistencyRequest( - tableName, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, consistencyToken, true); + tableName, + CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, + consistencyToken, + true); } @InternalApi public CheckConsistencyRequest toCheckConsistencyProto( TableAdminRequestContext requestContext, String token) { - Preconditions.checkState(!isFullyQualified(), "Use toCheckConsistencyProto(String token) for fully qualified table names."); + Preconditions.checkState( + !isFullyQualified(), + "Use toCheckConsistencyProto(String token) for fully qualified table names."); CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder(); TableName tableName = TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId()); @@ -102,7 +111,10 @@ public CheckConsistencyRequest toCheckConsistencyProto( @InternalApi public CheckConsistencyRequest toCheckConsistencyProto(String token) { - Preconditions.checkState(isFullyQualified(), "Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table names."); + Preconditions.checkState( + isFullyQualified(), + "Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table" + + " names."); CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder(); if (getMode().equals(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES)) { @@ -117,7 +129,8 @@ public CheckConsistencyRequest toCheckConsistencyProto(String token) { @InternalApi public GenerateConsistencyTokenRequest toGenerateTokenProto( TableAdminRequestContext requestContext) { - Preconditions.checkState(!isFullyQualified(), "Use toGenerateTokenProto() for fully qualified table names."); + Preconditions.checkState( + !isFullyQualified(), "Use toGenerateTokenProto() for fully qualified table names."); GenerateConsistencyTokenRequest.Builder builder = GenerateConsistencyTokenRequest.newBuilder(); TableName tableName = TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId()); @@ -127,7 +140,9 @@ public GenerateConsistencyTokenRequest toGenerateTokenProto( @InternalApi public GenerateConsistencyTokenRequest toGenerateTokenProto() { - Preconditions.checkState(isFullyQualified(), "Use toGenerateTokenProto(TableAdminRequestContext) for non-qualified table names."); + Preconditions.checkState( + isFullyQualified(), + "Use toGenerateTokenProto(TableAdminRequestContext) for non-qualified table names."); GenerateConsistencyTokenRequest.Builder builder = GenerateConsistencyTokenRequest.newBuilder(); return builder.setName(getTableId()).build(); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java index 79da312d37..3333529b3b 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java @@ -54,8 +54,7 @@ public class EnhancedBigtableTableAdminStub extends GrpcBigtableTableAdminStub { private final BigtableTableAdminStubSettings settings; private final ClientContext clientContext; - @javax.annotation.Nullable - private final TableAdminRequestContext requestContext; + @javax.annotation.Nullable private final TableAdminRequestContext requestContext; @Deprecated private final AwaitReplicationCallable awaitReplicationCallable; @@ -64,10 +63,8 @@ public class EnhancedBigtableTableAdminStub extends GrpcBigtableTableAdminStub { optimizeRestoredTableOperationBaseCallable; public static EnhancedBigtableTableAdminStub createEnhanced( - BigtableTableAdminStubSettings settings) - throws IOException { - return new EnhancedBigtableTableAdminStub( - settings, ClientContext.create(settings), null); + BigtableTableAdminStubSettings settings) throws IOException { + return new EnhancedBigtableTableAdminStub(settings, ClientContext.create(settings), null); } public static EnhancedBigtableTableAdminStub createEnhanced( From 59addc0ff7307773bbe8515f5d28623fd46bf17d Mon Sep 17 00:00:00 2001 From: Jin Seop Kim Date: Tue, 21 Apr 2026 15:02:37 -0400 Subject: [PATCH 3/5] PR feedback --- .../admin/v2/models/ConsistencyRequest.java | 53 +++++++++++-------- .../stub/EnhancedBigtableTableAdminStub.java | 9 ++++ .../v2/models/ConsistencyRequestTest.java | 39 ++++++++++++++ 3 files changed, 80 insertions(+), 21 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java index 7ed8c2d6bb..ed3a14bd01 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java @@ -90,15 +90,8 @@ public static ConsistencyRequest forReplicationFromTableName( true); } - @InternalApi - public CheckConsistencyRequest toCheckConsistencyProto( - TableAdminRequestContext requestContext, String token) { - Preconditions.checkState( - !isFullyQualified(), - "Use toCheckConsistencyProto(String token) for fully qualified table names."); + private CheckConsistencyRequest.Builder buildBaseRequest(String name, String token) { CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder(); - TableName tableName = - TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId()); if (getMode().equals(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES)) { builder.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build()); @@ -106,26 +99,40 @@ public CheckConsistencyRequest toCheckConsistencyProto( builder.setDataBoostReadLocalWrites(DataBoostReadLocalWrites.newBuilder().build()); } - return builder.setName(tableName.toString()).setConsistencyToken(token).build(); + return builder.setName(name).setConsistencyToken(token); } + /** + * Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest + * was initialized with a short table ID, relying on the TableAdminRequestContext to construct + * the fully qualified table name. + */ @InternalApi - public CheckConsistencyRequest toCheckConsistencyProto(String token) { - Preconditions.checkState( - isFullyQualified(), - "Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table" - + " names."); - CheckConsistencyRequest.Builder builder = CheckConsistencyRequest.newBuilder(); + public CheckConsistencyRequest toCheckConsistencyProto( + TableAdminRequestContext requestContext, String token) { + Preconditions.checkState(!isFullyQualified(), "Use toCheckConsistencyProto(String token) for fully qualified table names."); + TableName tableName = + TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId()); - if (getMode().equals(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES)) { - builder.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build()); - } else { - builder.setDataBoostReadLocalWrites(DataBoostReadLocalWrites.newBuilder().build()); - } + return buildBaseRequest(tableName.toString(), token).build(); + } - return builder.setName(getTableId()).setConsistencyToken(token).build(); + /** + * Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest + * was initialized with a fully qualified table name, eliminating the need for a request context. + */ + @InternalApi + public CheckConsistencyRequest toCheckConsistencyProto(String token) { + Preconditions.checkState(isFullyQualified(), "Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table names."); + + return buildBaseRequest(getTableId(), token).build(); } + /** + * Creates a GenerateConsistencyTokenRequest proto. This variant is used when the ConsistencyRequest + * was initialized with a short table ID, relying on the TableAdminRequestContext to construct + * the fully qualified table name. + */ @InternalApi public GenerateConsistencyTokenRequest toGenerateTokenProto( TableAdminRequestContext requestContext) { @@ -138,6 +145,10 @@ public GenerateConsistencyTokenRequest toGenerateTokenProto( return builder.setName(tableName.toString()).build(); } + /** + * Creates a GenerateConsistencyTokenRequest proto. This variant is used when the ConsistencyRequest + * was initialized with a fully qualified table name, eliminating the need for a request context. + */ @InternalApi public GenerateConsistencyTokenRequest toGenerateTokenProto() { Preconditions.checkState( diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java index 3333529b3b..68b0c0e087 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java @@ -62,6 +62,15 @@ public class EnhancedBigtableTableAdminStub extends GrpcBigtableTableAdminStub { private final OperationCallable optimizeRestoredTableOperationBaseCallable; + /** + * Creates an instance of {@link EnhancedBigtableTableAdminStub} using the provided settings. + * This variant is used by the V2 client stack which relies on fully qualified table names + * and therefore does not require a {@link TableAdminRequestContext}. + * + * @param settings The settings used to configure the stub. + * @return A new instance of {@code EnhancedBigtableTableAdminStub}. + * @throws IOException If there are errors creating the underlying client context. + */ public static EnhancedBigtableTableAdminStub createEnhanced( BigtableTableAdminStubSettings settings) throws IOException { return new EnhancedBigtableTableAdminStub(settings, ClientContext.create(settings), null); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java index c3b99a4e68..9f4d02c1f2 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java @@ -97,4 +97,43 @@ public void testToCheckConsistencyProtoWithToken() { assertThat(checkConsistencyRequest.getModeCase()) .isEqualTo(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES); } + + @Test + public void testToCheckConsistencyProtoFromTableName() { + String fullTableName = NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID); + ConsistencyRequest consistencyRequest = ConsistencyRequest.forReplicationFromTableName(fullTableName); + + CheckConsistencyRequest checkConsistencyRequest = + consistencyRequest.toCheckConsistencyProto(CONSISTENCY_TOKEN); + + assertThat(checkConsistencyRequest.getName()).isEqualTo(fullTableName); + assertThat(checkConsistencyRequest.getConsistencyToken()).isEqualTo(CONSISTENCY_TOKEN); + assertThat(checkConsistencyRequest.getModeCase()) + .isEqualTo(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES); + } + + @Test + public void testToCheckConsistencyProtoFromTableNameWithToken() { + String fullTableName = NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID); + ConsistencyRequest consistencyRequest = + ConsistencyRequest.forReplicationFromTableName(fullTableName, CONSISTENCY_TOKEN); + + CheckConsistencyRequest checkConsistencyRequest = + consistencyRequest.toCheckConsistencyProto(CONSISTENCY_TOKEN); + + assertThat(checkConsistencyRequest.getName()).isEqualTo(fullTableName); + assertThat(checkConsistencyRequest.getConsistencyToken()).isEqualTo(CONSISTENCY_TOKEN); + assertThat(checkConsistencyRequest.getModeCase()) + .isEqualTo(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES); + } + + @Test + public void testToGenerateTokenProtoFromTableName() { + String fullTableName = NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID); + ConsistencyRequest consistencyRequest = ConsistencyRequest.forReplicationFromTableName(fullTableName); + + GenerateConsistencyTokenRequest generateRequest = consistencyRequest.toGenerateTokenProto(); + + assertThat(generateRequest.getName()).isEqualTo(fullTableName); + } } From 35e797a8f0ff9228e94f71357860b5abcfeb4722 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Tue, 21 Apr 2026 19:08:49 +0000 Subject: [PATCH 4/5] chore: generate libraries at Tue Apr 21 19:06:09 UTC 2026 --- .github/scripts/update_generation_config.sh | 19 +++++++----- .github/workflows/renovate_config_check.yaml | 7 ++--- .kokoro/presubmit/graalvm-native-a.cfg | 2 +- .kokoro/presubmit/graalvm-native-b.cfg | 2 +- .kokoro/presubmit/graalvm-native-c.cfg | 2 +- .../admin/v2/models/ConsistencyRequest.java | 30 +++++++++++-------- .../stub/EnhancedBigtableTableAdminStub.java | 6 ++-- .../v2/models/ConsistencyRequestTest.java | 6 ++-- 8 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.github/scripts/update_generation_config.sh b/.github/scripts/update_generation_config.sh index 74d0e6cc41..f448fafd7d 100644 --- a/.github/scripts/update_generation_config.sh +++ b/.github/scripts/update_generation_config.sh @@ -48,13 +48,14 @@ function update_config() { } # Update an action to a new version in GitHub action. +# the second argument must have the git tag (including "v"). function update_action() { local key_word=$1 local new_value=$2 local file=$3 echo "Update ${key_word} to ${new_value} in ${file}" # use a different delimiter because the key_word contains "/". - sed -i -e "s|${key_word}@v.*$|${key_word}@v${new_value}|" "${file}" + sed -i -e "s|${key_word}@[^ ]*$|${key_word}@${new_value}|" "${file}" } # The parameters of this script is: @@ -143,12 +144,16 @@ rm -rf tmp-googleapis update_config "googleapis_commitish" "${latest_commit}" "${generation_config}" # Update gapic-generator-java version to the latest -latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java") -update_config "gapic_generator_version" "${latest_version}" "${generation_config}" - -# Update composite action version to latest gapic-generator-java version -update_action "googleapis/sdk-platform-java/.github/scripts" \ - "${latest_version}" \ +latest_gapic_generator_version=$(get_latest_released_version "com.google.api" "gapic-generator-java") +update_config "gapic_generator_version" "${latest_gapic_generator_version}" "${generation_config}" + +# Update the GitHub Actions reference to the latest. +# After the google-cloud-java monorepo migration of sdk-platform-java, +# we cannot rely on the gapic-generator-java version tag. Let's use +# the gapic-libraries-bom version +latest_gapic_libraries_bom_version=$(get_latest_released_version "com.google.cloud" "gapic-libraries-bom") +update_action "googleapis/google-cloud-java/sdk-platform-java/.github/scripts" \ + "v${latest_gapic_libraries_bom_version}" \ "${workflow}" # Update libraries-bom version to the latest diff --git a/.github/workflows/renovate_config_check.yaml b/.github/workflows/renovate_config_check.yaml index 47b9e87c98..8c922936b9 100644 --- a/.github/workflows/renovate_config_check.yaml +++ b/.github/workflows/renovate_config_check.yaml @@ -4,6 +4,7 @@ on: pull_request: paths: - 'renovate.json' + - '.github/workflows/renovate_config_check.yaml' jobs: renovate_bot_config_validation: @@ -18,8 +19,6 @@ jobs: with: node-version: '22' - - name: Install Renovate and Config Validator + - name: Run Renovate Config Validator run: | - npm install -g npm@latest - npm install --global renovate - renovate-config-validator + npx --package renovate@43.136.0 renovate-config-validator diff --git a/.kokoro/presubmit/graalvm-native-a.cfg b/.kokoro/presubmit/graalvm-native-a.cfg index 73535bd553..af9f68ad4f 100644 --- a/.kokoro/presubmit/graalvm-native-a.cfg +++ b/.kokoro/presubmit/graalvm-native-a.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.59.0" # {x-version-update:google-cloud-shared-dependencies:current} + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.61.0" # {x-version-update:google-cloud-shared-dependencies:current} } env_vars: { diff --git a/.kokoro/presubmit/graalvm-native-b.cfg b/.kokoro/presubmit/graalvm-native-b.cfg index 744786545b..576031a719 100644 --- a/.kokoro/presubmit/graalvm-native-b.cfg +++ b/.kokoro/presubmit/graalvm-native-b.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.59.0" # {x-version-update:google-cloud-shared-dependencies:current} + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.61.0" # {x-version-update:google-cloud-shared-dependencies:current} } env_vars: { diff --git a/.kokoro/presubmit/graalvm-native-c.cfg b/.kokoro/presubmit/graalvm-native-c.cfg index 3bdfd16682..1d86c06d22 100644 --- a/.kokoro/presubmit/graalvm-native-c.cfg +++ b/.kokoro/presubmit/graalvm-native-c.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.59.0" # {x-version-update:google-cloud-shared-dependencies:current} + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.61.0" # {x-version-update:google-cloud-shared-dependencies:current} } env_vars: { diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java index ed3a14bd01..16e30acc96 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java @@ -103,14 +103,16 @@ private CheckConsistencyRequest.Builder buildBaseRequest(String name, String tok } /** - * Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest - * was initialized with a short table ID, relying on the TableAdminRequestContext to construct - * the fully qualified table name. + * Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest was + * initialized with a short table ID, relying on the TableAdminRequestContext to construct the + * fully qualified table name. */ @InternalApi public CheckConsistencyRequest toCheckConsistencyProto( TableAdminRequestContext requestContext, String token) { - Preconditions.checkState(!isFullyQualified(), "Use toCheckConsistencyProto(String token) for fully qualified table names."); + Preconditions.checkState( + !isFullyQualified(), + "Use toCheckConsistencyProto(String token) for fully qualified table names."); TableName tableName = TableName.of(requestContext.getProjectId(), requestContext.getInstanceId(), getTableId()); @@ -118,20 +120,23 @@ public CheckConsistencyRequest toCheckConsistencyProto( } /** - * Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest - * was initialized with a fully qualified table name, eliminating the need for a request context. + * Creates a CheckConsistencyRequest proto. This variant is used when the ConsistencyRequest was + * initialized with a fully qualified table name, eliminating the need for a request context. */ @InternalApi public CheckConsistencyRequest toCheckConsistencyProto(String token) { - Preconditions.checkState(isFullyQualified(), "Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table names."); + Preconditions.checkState( + isFullyQualified(), + "Use toCheckConsistencyProto(TableAdminRequestContext, String) for non-qualified table" + + " names."); return buildBaseRequest(getTableId(), token).build(); } /** - * Creates a GenerateConsistencyTokenRequest proto. This variant is used when the ConsistencyRequest - * was initialized with a short table ID, relying on the TableAdminRequestContext to construct - * the fully qualified table name. + * Creates a GenerateConsistencyTokenRequest proto. This variant is used when the + * ConsistencyRequest was initialized with a short table ID, relying on the + * TableAdminRequestContext to construct the fully qualified table name. */ @InternalApi public GenerateConsistencyTokenRequest toGenerateTokenProto( @@ -146,8 +151,9 @@ public GenerateConsistencyTokenRequest toGenerateTokenProto( } /** - * Creates a GenerateConsistencyTokenRequest proto. This variant is used when the ConsistencyRequest - * was initialized with a fully qualified table name, eliminating the need for a request context. + * Creates a GenerateConsistencyTokenRequest proto. This variant is used when the + * ConsistencyRequest was initialized with a fully qualified table name, eliminating the need for + * a request context. */ @InternalApi public GenerateConsistencyTokenRequest toGenerateTokenProto() { diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java index 68b0c0e087..38fb42e293 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java @@ -63,9 +63,9 @@ public class EnhancedBigtableTableAdminStub extends GrpcBigtableTableAdminStub { optimizeRestoredTableOperationBaseCallable; /** - * Creates an instance of {@link EnhancedBigtableTableAdminStub} using the provided settings. - * This variant is used by the V2 client stack which relies on fully qualified table names - * and therefore does not require a {@link TableAdminRequestContext}. + * Creates an instance of {@link EnhancedBigtableTableAdminStub} using the provided settings. This + * variant is used by the V2 client stack which relies on fully qualified table names and + * therefore does not require a {@link TableAdminRequestContext}. * * @param settings The settings used to configure the stub. * @return A new instance of {@code EnhancedBigtableTableAdminStub}. diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java index 9f4d02c1f2..9cfdb28170 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java @@ -101,7 +101,8 @@ public void testToCheckConsistencyProtoWithToken() { @Test public void testToCheckConsistencyProtoFromTableName() { String fullTableName = NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID); - ConsistencyRequest consistencyRequest = ConsistencyRequest.forReplicationFromTableName(fullTableName); + ConsistencyRequest consistencyRequest = + ConsistencyRequest.forReplicationFromTableName(fullTableName); CheckConsistencyRequest checkConsistencyRequest = consistencyRequest.toCheckConsistencyProto(CONSISTENCY_TOKEN); @@ -130,7 +131,8 @@ public void testToCheckConsistencyProtoFromTableNameWithToken() { @Test public void testToGenerateTokenProtoFromTableName() { String fullTableName = NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID); - ConsistencyRequest consistencyRequest = ConsistencyRequest.forReplicationFromTableName(fullTableName); + ConsistencyRequest consistencyRequest = + ConsistencyRequest.forReplicationFromTableName(fullTableName); GenerateConsistencyTokenRequest generateRequest = consistencyRequest.toGenerateTokenProto(); From bb2a0a9b9be5d3dfdf68dc9daa97404cf7ae67a2 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Tue, 21 Apr 2026 19:14:29 +0000 Subject: [PATCH 5/5] chore: generate libraries at Tue Apr 21 19:11:56 UTC 2026 --- .github/scripts/update_generation_config.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/scripts/update_generation_config.sh b/.github/scripts/update_generation_config.sh index c7502f6a90..f448fafd7d 100644 --- a/.github/scripts/update_generation_config.sh +++ b/.github/scripts/update_generation_config.sh @@ -144,12 +144,16 @@ rm -rf tmp-googleapis update_config "googleapis_commitish" "${latest_commit}" "${generation_config}" # Update gapic-generator-java version to the latest -latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java") -update_config "gapic_generator_version" "${latest_version}" "${generation_config}" - -# Update composite action version to latest gapic-generator-java version +latest_gapic_generator_version=$(get_latest_released_version "com.google.api" "gapic-generator-java") +update_config "gapic_generator_version" "${latest_gapic_generator_version}" "${generation_config}" + +# Update the GitHub Actions reference to the latest. +# After the google-cloud-java monorepo migration of sdk-platform-java, +# we cannot rely on the gapic-generator-java version tag. Let's use +# the gapic-libraries-bom version +latest_gapic_libraries_bom_version=$(get_latest_released_version "com.google.cloud" "gapic-libraries-bom") update_action "googleapis/google-cloud-java/sdk-platform-java/.github/scripts" \ - "${latest_version}" \ + "v${latest_gapic_libraries_bom_version}" \ "${workflow}" # Update libraries-bom version to the latest