Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
Original file line number Diff line number Diff line change
Expand Up @@ -1418,8 +1418,8 @@ public RestoredTableResult restoreTable(RestoreTableRequest request)
}

/**
* <p>This method is obsolete. For the recommended proto-based approach, please see
* {@link com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient#restoreTableAsync(com.google.bigtable.admin.v2.RestoreTableRequest)}.
* This method is obsolete. For the recommended proto-based approach, please see {@link
* com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient#restoreTableAsync(com.google.bigtable.admin.v2.RestoreTableRequest)}.
*
* <p>Restores a backup to a new table with the specified configuration asynchronously.
*
Expand All @@ -1442,7 +1442,7 @@ public RestoredTableResult restoreTable(RestoreTableRequest request)
* },
* MoreExecutors.directExecutor()
* );
* </pre>
* }</pre>
*/
@ObsoleteApi("Use getBaseClient() to access the auto-generated proto-based methods instead.")
public ApiFuture<RestoredTableResult> restoreTableAsync(RestoreTableRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.cloud.bigtable.admin.v2.internal;

import com.google.api.core.InternalApi;
import com.google.cloud.bigtable.data.v2.models.TableId;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
Expand Down Expand Up @@ -53,6 +54,10 @@ public static String formatTableName(String projectId, String instanceId, String
return formatInstanceName(projectId, instanceId) + "/tables/" + tableId;
}

public static String formatTableName(String projectId, String instanceId, TableId tableId) {
return formatInstanceName(projectId, instanceId) + "/tables/" + tableId.getTableId();
}

public static String formatMaterializedViewName(
@Nonnull String projectId, @Nonnull String instanceId, @Nonnull String materializedViewId) {
return formatInstanceName(projectId, instanceId) + "/materializedViews/" + materializedViewId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ com.google.bigtable.admin.v2.AppProfile.SingleClusterRouting toProto() {
return proto;
}

@SuppressWarnings("EqualsGetClass")
@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -320,6 +321,7 @@ MultiClusterRoutingUseAny toProto() {
return proto;
}

@SuppressWarnings("EqualsGetClass")
@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -426,6 +428,7 @@ com.google.bigtable.admin.v2.AppProfile.StandardIsolation toProto() {
return proto;
}

@SuppressWarnings("EqualsGetClass")
@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -527,6 +530,7 @@ public DataBoostIsolationReadOnly toProto() {
return proto;
}

@SuppressWarnings("EqualsGetClass")
@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public EncryptionInfo getEncryptionInfo() {
return EncryptionInfo.fromProto(proto.getEncryptionInfo());
}

@SuppressWarnings("EqualsIncompatibleType")
@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public String getKmsKeyName() {
return null;
}

@SuppressWarnings("EqualsGetClass")
@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public com.google.bigtable.admin.v2.PartialUpdateClusterRequest toProto(String p
return this.builder.build();
}

@SuppressWarnings({"EqualsGetClass", "ObjectEqualsForPrimitives"})
@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.google.cloud.bigtable.admin.v2.models;

import com.google.api.core.InternalApi;
import com.google.bigtable.admin.v2.Instance.Type;
import com.google.cloud.bigtable.admin.v2.internal.NameUtil;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -74,7 +73,7 @@ private CreateInstanceRequest(@Nonnull String instanceId) {

builder.setInstanceId(instanceId);
builder.getInstanceBuilder().setDisplayName(instanceId);
builder.getInstanceBuilder().setType(Type.PRODUCTION);
builder.getInstanceBuilder().setType(com.google.bigtable.admin.v2.Instance.Type.PRODUCTION);
Comment thread
mutianf marked this conversation as resolved.
}

/**
Expand Down Expand Up @@ -156,7 +155,7 @@ public CreateInstanceRequest addCluster(
CreateClusterRequest clusterRequest =
CreateClusterRequest.of("ignored-instance-id", clusterId)
.setZone(zone)
.setServeNodes(serveNodes)
.setScalingMode(StaticClusterSize.of(serveNodes))
.setStorageType(storageType);
clusterRequests.add(clusterRequest);

Expand Down Expand Up @@ -212,7 +211,7 @@ public CreateInstanceRequest addCmekCluster(
CreateClusterRequest clusterRequest =
CreateClusterRequest.of("ignored-instance-id", clusterId)
.setZone(zone)
.setServeNodes(serveNodes)
.setScalingMode(StaticClusterSize.of(serveNodes))
.setStorageType(storageType)
.setKmsKeyName(kmsKeyName);
clusterRequests.add(clusterRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.api.core.InternalApi;
import com.google.bigtable.admin.v2.Instance;
import com.google.bigtable.admin.v2.Instance.Type;
import com.google.bigtable.admin.v2.PartialUpdateInstanceRequest;
import com.google.cloud.bigtable.admin.v2.internal.NameUtil;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -64,7 +63,7 @@ public UpdateInstanceRequest setDisplayName(@Nonnull String displayName) {
*/
@SuppressWarnings("WeakerAccess")
public UpdateInstanceRequest setProductionType() {
builder.getInstanceBuilder().setType(Type.PRODUCTION);
builder.getInstanceBuilder().setType(Instance.Type.PRODUCTION);
updateFieldMask(Instance.TYPE_FIELD_NUMBER);

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UpdateTableRequest)) return false;
UpdateTableRequest that = (UpdateTableRequest) o;
return Objects.equals(requestBuilder, that.requestBuilder);
if (requestBuilder == that.requestBuilder) {
return true;
}
if (requestBuilder == null || that.requestBuilder == null) {
return false;
}
return Objects.equals(requestBuilder.build(), that.requestBuilder.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ private AwaitConsistencyCallable createAwaitConsistencyCallable() {
.setInitialRetryDelay(Duration.ofSeconds(10))
.setRetryDelayMultiplier(1.0)
.setMaxRetryDelay(Duration.ofSeconds(10))
.setJittered(true)
// These rpc timeouts are ignored, instead the rpc timeouts defined for
// generateConsistencyToken and checkConsistency callables will be used.
.setInitialRpcTimeout(Duration.ZERO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public com.google.rpc.Status toProto() {
return proto;
}

@Override
public String toString() {
return proto.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public static String formatTableName(
return formatInstanceName(projectId, instanceId) + "/tables/" + tableId;
}

public static String formatTableName(
@Nonnull String projectId, @Nonnull String instanceId, @Nonnull TableId tableId) {
return formatInstanceName(projectId, instanceId) + "/tables/" + tableId.getTableId();
Comment thread
igorbernstein2 marked this conversation as resolved.
Outdated
}

public static String formatAuthorizedViewName(
@Nonnull String projectId,
@Nonnull String instanceId,
Expand All @@ -56,6 +61,14 @@ public static String formatAuthorizedViewName(
return formatTableName(projectId, instanceId, tableId) + "/authorizedViews/" + authorizedViewId;
}

public static String formatAuthorizedViewName(
Comment thread
igorbernstein2 marked this conversation as resolved.
@Nonnull String projectId,
@Nonnull String instanceId,
@Nonnull TableId tableId,
@Nonnull String authorizedViewId) {
return formatTableName(projectId, instanceId, tableId) + "/authorizedViews/" + authorizedViewId;
}

public static String formatMaterializedViewName(
@Nonnull String projectId, @Nonnull String instanceId, @Nonnull String materializedViewId) {
return formatInstanceName(projectId, instanceId) + "/materializedViews/" + materializedViewId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public class ClientPerConnectionErrorCount extends MetricWrapper<ClientSchema> {
.addAll(Buckets.generateGeometricSeq(1, 64))
.addAll(Buckets.generateGeometricSeq(125, 1_000_000L))
.build();

// This metric migrated from gce/gke schemas to bigtable_client
// So a lot of the metric labels overlap with the resource labels.
// we need special handling since the logic in MetricWrapper assumes that there is no
// overlap.
@SuppressWarnings("deprecation")
private static final Set<AttributeKey<?>> METRIC_LABELS =
ImmutableSet.of(
MetricLabels.BIGTABLE_PROJECT_ID_KEY,
Expand Down Expand Up @@ -96,6 +98,7 @@ private Recorder(Meter meter) {
}

public void record(ClientInfo clientInfo, long value) {
@SuppressWarnings("deprecation")
Attributes attributes =
getSchema()
.createResourceAttrs(clientInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public static AuthorizedViewId of(String tableId, String authorizedViewId) {
return new AutoValue_AuthorizedViewId(tableId, authorizedViewId);
}

public static AuthorizedViewId of(TableId tableId, String authorizedViewId) {
Preconditions.checkNotNull(tableId, "table id can't be null.");
Preconditions.checkNotNull(authorizedViewId, "authorized view id can't be null.");
return new AutoValue_AuthorizedViewId(tableId.getTableId(), authorizedViewId);
}

abstract String getTableId();

abstract String getAuthorizedViewId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,19 @@ static Builder builder() {
@InternalApi("Intended for use by the BigtableIO in apache/beam only.")
@AutoValue.Builder
abstract static class Builder {
abstract Builder setRowKey(@Nonnull ByteString rowKey);
abstract Builder setRowKey(ByteString rowKey);
Comment thread
mutianf marked this conversation as resolved.

abstract Builder setType(@Nonnull MutationType type);
abstract Builder setType(MutationType type);

abstract Builder setSourceClusterId(@Nonnull String sourceClusterId);
abstract Builder setSourceClusterId(String sourceClusterId);

abstract Builder setCommitTime(java.time.Instant commitTimestamp);

abstract Builder setTieBreaker(int tieBreaker);

abstract ImmutableList.Builder<Entry> entriesBuilder();

abstract Builder setToken(@Nonnull String token);
abstract Builder setToken(String token);

abstract Builder setEstimatedLowWatermarkTime(java.time.Instant estimatedLowWatermark);

Expand Down Expand Up @@ -205,7 +205,7 @@ Builder mergeToCell(@Nonnull String familyName, Value qualifier, Value timestamp
}

public RowMutation toRowMutation(@Nonnull String tableId) {
RowMutation rowMutation = RowMutation.create(tableId, getRowKey());
RowMutation rowMutation = RowMutation.create(TableId.of(tableId), getRowKey());
for (Entry entry : getEntries()) {
if (entry instanceof DeleteFamily) {
rowMutation.deleteFamily(((DeleteFamily) entry).getFamilyName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public Object getTransportCode() {
// Everything needed to build a retry request
@Nullable private List<Integer> originalIndexes;
@Nonnull private final Set<StatusCode.Code> retryableCodes;
@Nullable private final List<FailedMutation> permanentFailures;
@Nonnull private final List<FailedMutation> permanentFailures;
@Nonnull private final RetryAlgorithm<MutateRowsRequest> retryAlgorithm;
@Nonnull private TimedAttemptSettings attemptSettings;

Expand Down Expand Up @@ -148,7 +148,8 @@ public List<MutateRowsResponse> apply(Throwable throwable) {
this.callContext = Preconditions.checkNotNull(callContext, "callContext");
this.retryableCodes = Preconditions.checkNotNull(retryableCodes, "retryableCodes");
this.retryAlgorithm = retryAlgorithm;
this.attemptSettings = retryAlgorithm.createFirstAttempt();
// TODO: pass in the callContext so that the retry setting can be overridden per call
this.attemptSettings = retryAlgorithm.createFirstAttempt(null);

permanentFailures = Lists.newArrayList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public final class BigtableTransportChannelProvider implements TransportChannelP
private BigtableTransportChannelProvider(
InstantiatingGrpcChannelProvider instantiatingGrpcChannelProvider,
ChannelPrimer channelPrimer,
ChannelPoolMetricsTracer channelPoolMetricsTracer,
ScheduledExecutorService backgroundExecutor) {
@Nullable ChannelPoolMetricsTracer channelPoolMetricsTracer,
@Nullable ScheduledExecutorService backgroundExecutor) {
delegate = Preconditions.checkNotNull(instantiatingGrpcChannelProvider);
this.channelPrimer = channelPrimer;
this.channelPoolMetricsTracer = channelPoolMetricsTracer;
Expand All @@ -59,6 +59,7 @@ public boolean shouldAutoClose() {
return delegate.shouldAutoClose();
}

@SuppressWarnings("deprecation")
@Override
public boolean needsExecutor() {
return delegate.needsExecutor();
Expand Down Expand Up @@ -164,7 +165,7 @@ public TransportChannel getTransportChannel() throws IOException {
btPoolSettings, channelFactory, channelPrimer, backgroundExecutor);

if (channelPoolMetricsTracer != null) {
channelPoolMetricsTracer.registerChannelInsightsProvider(btChannelPool::getChannelInfos);
channelPoolMetricsTracer.registerChannelInsightsProvider(btChannelPool);
channelPoolMetricsTracer.registerLoadBalancingStrategy(
btPoolSettings.getLoadBalancingStrategy());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import com.google.cloud.bigtable.admin.v2.models.MaterializedView;
import com.google.cloud.bigtable.admin.v2.models.PartialListClustersException;
import com.google.cloud.bigtable.admin.v2.models.PartialListInstancesException;
import com.google.cloud.bigtable.admin.v2.models.StaticClusterSize;
import com.google.cloud.bigtable.admin.v2.models.StorageType;
import com.google.cloud.bigtable.admin.v2.models.UpdateAppProfileRequest;
import com.google.cloud.bigtable.admin.v2.models.UpdateInstanceRequest;
Expand All @@ -75,6 +76,7 @@
import com.google.protobuf.FieldMask;
import io.grpc.Status;
import io.grpc.Status.Code;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
Expand All @@ -94,12 +96,12 @@
import org.mockito.quality.Strictness;
import org.mockito.stubbing.Answer;

@RunWith(JUnit4.class)
/**
* Tests for {@link BigtableInstanceAdminClient}. This test class uses Mockito so it has been
* explicitly excluded from Native Image testing by not following the naming convention of (IT* and
* *ClientTest).
*/
@RunWith(JUnit4.class)
public class BigtableInstanceAdminClientTests {
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.WARN);

Expand Down Expand Up @@ -623,7 +625,7 @@ public void testCreateCluster() {
adminClient.createCluster(
CreateClusterRequest.of(INSTANCE_ID, CLUSTER_ID)
.setZone("us-east1-c")
.setServeNodes(3)
.setScalingMode(StaticClusterSize.of(3))
.setStorageType(StorageType.SSD));
// Verify
assertThat(actualResult).isEqualTo(Cluster.fromProto(expectedResponse));
Expand Down Expand Up @@ -1522,7 +1524,7 @@ public void testGetIamPolicy() {
.isEqualTo(
Policy.newBuilder()
.addIdentity(Role.of("bigtable.user"), Identity.user("someone@example.com"))
.setEtag(BaseEncoding.base64().encode("my-etag".getBytes()))
.setEtag(BaseEncoding.base64().encode("my-etag".getBytes(StandardCharsets.UTF_8)))
.build());
}

Expand Down Expand Up @@ -1567,7 +1569,7 @@ public void testSetIamPolicy() {
.isEqualTo(
Policy.newBuilder()
.addIdentity(Role.of("bigtable.user"), Identity.user("someone@example.com"))
.setEtag(BaseEncoding.base64().encode("my-etag".getBytes()))
.setEtag(BaseEncoding.base64().encode("my-etag".getBytes(StandardCharsets.UTF_8)))
.build());
}

Expand Down
Loading
Loading