Skip to content

Commit 413a2fd

Browse files
authored
deps: remove client-core dependency from bigtable-hbase-2.x (#3620)
1 parent 68488eb commit 413a2fd

File tree

3 files changed

+12
-37
lines changed

3 files changed

+12
-37
lines changed

bigtable-hbase-2.x-parent/bigtable-hbase-2.x/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ limitations under the License.
6363
<version>2.2.1-SNAPSHOT</version> <!-- {x-version-update:bigtable-client-parent:current} -->
6464
</dependency>
6565

66-
<dependency>
67-
<groupId>com.google.cloud.bigtable</groupId>
68-
<artifactId>bigtable-client-core</artifactId>
69-
<version>${bigtable-client-core.version}</version>
70-
</dependency>
71-
7266
<dependency>
7367
<groupId>com.google.cloud.bigtable</groupId>
7468
<artifactId>bigtable-metrics-api</artifactId>

bigtable-hbase-2.x-parent/bigtable-hbase-2.x/src/main/java/com/google/cloud/bigtable/hbase2_x/BigtableAsyncAdmin.java

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import com.google.cloud.bigtable.admin.v2.models.CreateTableRequest;
2626
import com.google.cloud.bigtable.admin.v2.models.RestoreTableRequest;
2727
import com.google.cloud.bigtable.admin.v2.models.Table;
28-
import com.google.cloud.bigtable.grpc.BigtableClusterName;
29-
import com.google.cloud.bigtable.grpc.BigtableInstanceName;
3028
import com.google.cloud.bigtable.hbase.BigtableOptionsFactory;
3129
import com.google.cloud.bigtable.hbase.util.Logger;
3230
import com.google.cloud.bigtable.hbase.util.ModifyTableBuilder;
@@ -86,7 +84,7 @@ public abstract class BigtableAsyncAdmin implements AsyncAdmin {
8684
private final BigtableHBaseSettings settings;
8785
private final CommonConnection asyncConnection;
8886
private final String bigtableInstanceName;
89-
private BigtableClusterName bigtableSnapshotClusterName;
87+
private String snapshotClusterId;
9088
private final int ttlSeconds;
9189

9290
public BigtableAsyncAdmin(CommonConnection asyncConnection) throws IOException {
@@ -98,15 +96,9 @@ public BigtableAsyncAdmin(CommonConnection asyncConnection) throws IOException {
9896
this.asyncConnection = asyncConnection;
9997

10098
Configuration configuration = asyncConnection.getConfiguration();
101-
String clusterId =
102-
configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null);
103-
if (clusterId != null) {
104-
BigtableInstanceName bigtableInstanceName =
105-
new BigtableInstanceName(
106-
asyncConnection.getBigtableSettings().getProjectId(),
107-
asyncConnection.getBigtableSettings().getInstanceId());
108-
bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId);
109-
}
99+
100+
snapshotClusterId = configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY);
101+
110102
this.ttlSeconds =
111103
configuration.getInt(
112104
BigtableOptionsFactory.BIGTABLE_SNAPSHOT_DEFAULT_TTL_SECS_KEY,
@@ -335,8 +327,7 @@ public CompletableFuture<TableDescriptor> getDescriptor(TableName tableName) {
335327
@Override
336328
public CompletableFuture<Void> deleteSnapshot(String snapshotId) {
337329
return toCompletableFuture(
338-
bigtableTableAdminClient.deleteBackupAsync(
339-
getBackupClusterName().getClusterId(), snapshotId));
330+
bigtableTableAdminClient.deleteBackupAsync(getBackupClusterId(), snapshotId));
340331
}
341332

342333
@Override
@@ -464,7 +455,7 @@ public CompletableFuture<Void> snapshot(String snapshotId, TableName tableName)
464455

465456
return toCompletableFuture(
466457
bigtableTableAdminClient.createBackupAsync(
467-
CreateBackupRequest.of(getBackupClusterName().getClusterId(), snapshotId)
458+
CreateBackupRequest.of(getBackupClusterId(), snapshotId)
468459
.setExpireTime(expireTime)
469460
.setSourceTableId(tableName.getNameAsString())))
470461
.thenAccept(backup -> {});
@@ -474,7 +465,7 @@ public CompletableFuture<Void> snapshot(String snapshotId, TableName tableName)
474465
public CompletableFuture<Void> cloneSnapshot(String snapshotId, TableName tableName) {
475466
return toCompletableFuture(
476467
bigtableTableAdminClient.restoreTableAsync(
477-
RestoreTableRequest.of(getBackupClusterName().getClusterId(), snapshotId)
468+
RestoreTableRequest.of(getBackupClusterId(), snapshotId)
478469
.setTableId(tableName.getNameAsString())))
479470
.thenAccept(backup -> {});
480471
}
@@ -487,7 +478,7 @@ public CompletableFuture<Void> cloneSnapshot(
487478

488479
@Override
489480
public CompletableFuture<List<SnapshotDescription>> listSnapshots() {
490-
return CompletableFuture.supplyAsync(() -> getBackupClusterName().getClusterId())
481+
return CompletableFuture.supplyAsync(this::getBackupClusterId)
491482
.thenCompose(
492483
c ->
493484
toCompletableFuture(bigtableTableAdminClient.listBackupsAsync(c))
@@ -517,8 +508,8 @@ private static <T> List<T> filter(Collection<T> r, Predicate<T> predicate) {
517508
return r.stream().filter(predicate).collect(Collectors.toList());
518509
}
519510

520-
private synchronized BigtableClusterName getBackupClusterName() {
521-
if (this.bigtableSnapshotClusterName == null) {
511+
private synchronized String getBackupClusterId() {
512+
if (this.snapshotClusterId == null) {
522513
List<Cluster> clusters =
523514
asyncConnection
524515
.getBigtableApi()
@@ -531,14 +522,9 @@ private synchronized BigtableClusterName getBackupClusterName() {
531522
asyncConnection.getBigtableSettings().getProjectId(),
532523
asyncConnection.getBigtableSettings().getInstanceId(),
533524
clusters.size()));
534-
String clusterName =
535-
NameUtil.formatClusterName(
536-
asyncConnection.getBigtableSettings().getProjectId(),
537-
asyncConnection.getBigtableSettings().getInstanceId(),
538-
clusters.get(0).getId());
539-
bigtableSnapshotClusterName = new BigtableClusterName(clusterName);
525+
snapshotClusterId = clusters.get(0).getId();
540526
}
541-
return bigtableSnapshotClusterName;
527+
return snapshotClusterId;
542528
}
543529

544530
@Override

bigtable-hbase-2.x-parent/bigtable-hbase-2.x/src/main/java/org/apache/hadoop/hbase/client/BigtableAsyncConnection.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.google.api.core.InternalApi;
1919
import com.google.bigtable.v2.SampleRowKeysRequest;
20-
import com.google.cloud.bigtable.config.BigtableOptions;
2120
import com.google.cloud.bigtable.data.v2.internal.NameUtil;
2221
import com.google.cloud.bigtable.data.v2.models.KeyOffset;
2322
import com.google.cloud.bigtable.hbase.adapters.Adapters;
@@ -109,10 +108,6 @@ public BigtableApi getBigtableApi() {
109108
return bigtableApi;
110109
}
111110

112-
public BigtableOptions getOptions() {
113-
throw new UnsupportedOperationException("veneer client does not support BigtableOptions");
114-
}
115-
116111
@Override
117112
public BigtableHBaseSettings getBigtableSettings() {
118113
return this.settings;

0 commit comments

Comments
 (0)