Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: remove client-core dependency from bigtable-hbase-2.x #3620

Merged
merged 7 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions bigtable-hbase-2.x-parent/bigtable-hbase-2.x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ limitations under the License.
<version>2.2.1-SNAPSHOT</version> <!-- {x-version-update:bigtable-client-parent:current} -->
</dependency>

<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-client-core</artifactId>
<version>${bigtable-client-core.version}</version>
</dependency>

<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-metrics-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import com.google.cloud.bigtable.admin.v2.models.CreateTableRequest;
import com.google.cloud.bigtable.admin.v2.models.RestoreTableRequest;
import com.google.cloud.bigtable.admin.v2.models.Table;
import com.google.cloud.bigtable.grpc.BigtableClusterName;
import com.google.cloud.bigtable.grpc.BigtableInstanceName;
import com.google.cloud.bigtable.hbase.BigtableOptionsFactory;
import com.google.cloud.bigtable.hbase.util.Logger;
import com.google.cloud.bigtable.hbase.util.ModifyTableBuilder;
Expand Down Expand Up @@ -86,7 +84,7 @@ public abstract class BigtableAsyncAdmin implements AsyncAdmin {
private final BigtableHBaseSettings settings;
private final CommonConnection asyncConnection;
private final String bigtableInstanceName;
private BigtableClusterName bigtableSnapshotClusterName;
private String snapshotClusterId;
private final int ttlSeconds;

public BigtableAsyncAdmin(CommonConnection asyncConnection) throws IOException {
Expand All @@ -98,15 +96,10 @@ public BigtableAsyncAdmin(CommonConnection asyncConnection) throws IOException {
this.asyncConnection = asyncConnection;

Configuration configuration = asyncConnection.getConfiguration();
String clusterId =

snapshotClusterId =
configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null);
igorbernstein2 marked this conversation as resolved.
Show resolved Hide resolved
if (clusterId != null) {
BigtableInstanceName bigtableInstanceName =
new BigtableInstanceName(
asyncConnection.getBigtableSettings().getProjectId(),
asyncConnection.getBigtableSettings().getInstanceId());
bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId);
}

this.ttlSeconds =
configuration.getInt(
BigtableOptionsFactory.BIGTABLE_SNAPSHOT_DEFAULT_TTL_SECS_KEY,
Expand Down Expand Up @@ -335,8 +328,7 @@ public CompletableFuture<TableDescriptor> getDescriptor(TableName tableName) {
@Override
public CompletableFuture<Void> deleteSnapshot(String snapshotId) {
return toCompletableFuture(
bigtableTableAdminClient.deleteBackupAsync(
getBackupClusterName().getClusterId(), snapshotId));
bigtableTableAdminClient.deleteBackupAsync(getBackupClusterId(), snapshotId));
}

@Override
Expand Down Expand Up @@ -464,7 +456,7 @@ public CompletableFuture<Void> snapshot(String snapshotId, TableName tableName)

return toCompletableFuture(
bigtableTableAdminClient.createBackupAsync(
CreateBackupRequest.of(getBackupClusterName().getClusterId(), snapshotId)
CreateBackupRequest.of(getBackupClusterId(), snapshotId)
.setExpireTime(expireTime)
.setSourceTableId(tableName.getNameAsString())))
.thenAccept(backup -> {});
Expand All @@ -474,7 +466,7 @@ public CompletableFuture<Void> snapshot(String snapshotId, TableName tableName)
public CompletableFuture<Void> cloneSnapshot(String snapshotId, TableName tableName) {
return toCompletableFuture(
bigtableTableAdminClient.restoreTableAsync(
RestoreTableRequest.of(getBackupClusterName().getClusterId(), snapshotId)
RestoreTableRequest.of(getBackupClusterId(), snapshotId)
.setTableId(tableName.getNameAsString())))
.thenAccept(backup -> {});
}
Expand All @@ -487,7 +479,7 @@ public CompletableFuture<Void> cloneSnapshot(

@Override
public CompletableFuture<List<SnapshotDescription>> listSnapshots() {
return CompletableFuture.supplyAsync(() -> getBackupClusterName().getClusterId())
return CompletableFuture.supplyAsync(this::getBackupClusterId)
.thenCompose(
c ->
toCompletableFuture(bigtableTableAdminClient.listBackupsAsync(c))
Expand Down Expand Up @@ -517,8 +509,8 @@ private static <T> List<T> filter(Collection<T> r, Predicate<T> predicate) {
return r.stream().filter(predicate).collect(Collectors.toList());
}

private synchronized BigtableClusterName getBackupClusterName() {
if (this.bigtableSnapshotClusterName == null) {
private synchronized String getBackupClusterId() {
if (this.snapshotClusterId == null) {
List<Cluster> clusters =
asyncConnection
.getBigtableApi()
Expand All @@ -531,14 +523,9 @@ private synchronized BigtableClusterName getBackupClusterName() {
asyncConnection.getBigtableSettings().getProjectId(),
asyncConnection.getBigtableSettings().getInstanceId(),
clusters.size()));
String clusterName =
NameUtil.formatClusterName(
asyncConnection.getBigtableSettings().getProjectId(),
asyncConnection.getBigtableSettings().getInstanceId(),
clusters.get(0).getId());
bigtableSnapshotClusterName = new BigtableClusterName(clusterName);
snapshotClusterId = clusters.get(0).getId();
}
return bigtableSnapshotClusterName;
return snapshotClusterId;
}

@Override
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.v2.SampleRowKeysRequest;
import com.google.cloud.bigtable.config.BigtableOptions;
import com.google.cloud.bigtable.data.v2.internal.NameUtil;
import com.google.cloud.bigtable.data.v2.models.KeyOffset;
import com.google.cloud.bigtable.hbase.adapters.Adapters;
Expand Down Expand Up @@ -109,10 +108,6 @@ public BigtableApi getBigtableApi() {
return bigtableApi;
}

public BigtableOptions getOptions() {
throw new UnsupportedOperationException("veneer client does not support BigtableOptions");
}

@Override
public BigtableHBaseSettings getBigtableSettings() {
return this.settings;
Expand Down