Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
public final class BigtableInstanceAdminClient implements AutoCloseable {
private final String projectId;
private final BigtableInstanceAdminStub stub;
private final BaseBigtableInstanceAdminClient baseClient;
private final BigtableInstanceAdminClientV2 baseClient;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, can we rename this to V2Client?


/** Constructs an instance of BigtableInstanceAdminClient with the given project ID. */
public static BigtableInstanceAdminClient create(@Nonnull String projectId) throws IOException {
Expand All @@ -148,7 +148,7 @@ private BigtableInstanceAdminClient(
@Nonnull String projectId, @Nonnull BigtableInstanceAdminStub stub) {
this.projectId = projectId;
this.stub = stub;
this.baseClient = BaseBigtableInstanceAdminClient.create(stub);
this.baseClient = new BigtableInstanceAdminClientV2(stub);
}

/** Gets the project ID this client is associated with. */
Expand All @@ -157,10 +157,10 @@ public String getProjectId() {
}

/**
* Returns the modern autogenerated client. This provides access to the newest features and
* proto-based methods.
* Returns the modern V2 client. This provides access to the newest features and proto-based
* methods.
*/
public BaseBigtableInstanceAdminClient getBaseClient() {
public BigtableInstanceAdminClientV2 getBaseClient() {
return baseClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest;
import com.google.cloud.bigtable.admin.v2.models.UpdateSchemaBundleRequest;
import com.google.cloud.bigtable.admin.v2.models.UpdateTableRequest;
import com.google.cloud.bigtable.admin.v2.stub.AwaitConsistencyCallableV2;
import com.google.cloud.bigtable.admin.v2.stub.EnhancedBigtableTableAdminStub;
import com.google.cloud.bigtable.data.v2.internal.TableAdminRequestContext;
import com.google.common.base.Preconditions;
Expand All @@ -89,6 +90,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nonnull;

/**
Expand Down Expand Up @@ -169,7 +171,7 @@ public final class BigtableTableAdminClient implements AutoCloseable {
private final EnhancedBigtableTableAdminStub stub;
private final String projectId;
private final String instanceId;
private final BaseBigtableTableAdminClient baseClient;
private BigtableTableAdminClientV2 baseClient;

/** Constructs an instance of BigtableTableAdminClient with the given project and instance IDs. */
public static BigtableTableAdminClient create(
Expand Down Expand Up @@ -209,7 +211,6 @@ private BigtableTableAdminClient(
this.projectId = projectId;
this.instanceId = instanceId;
this.stub = stub;
this.baseClient = BaseBigtableTableAdminClient.create(stub);
}

/** Gets the project ID of the instance whose tables this client manages. */
Expand All @@ -223,10 +224,28 @@ public String getInstanceId() {
}

/**
* Returns the modern autogenerated client. This provides access to the newest features and
* proto-based methods.
* Returns the modern V2 client. This provides access to the newest features and proto-based
* methods.
*/
public BaseBigtableTableAdminClient getBaseClient() {
public synchronized BigtableTableAdminClientV2 getBaseClient() {
if (baseClient == null) {
ScheduledExecutorService backgroundExecutor =
stub.getSettings().getBackgroundExecutorProvider().getExecutor();
boolean shouldAutoClose =
stub.getSettings().getBackgroundExecutorProvider().shouldAutoClose();

AwaitConsistencyCallableV2 awaitConsistencyCallable =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait this is a bit weird, why do we need to create the callable seperately instead of letting the V2 client create the callable?

BigtableTableAdminClientV2.createAwaitConsistencyCallable(
stub, stub.getSettings(), stub.getClientContext().getClock(), backgroundExecutor);

baseClient =
new BigtableTableAdminClientV2(
stub,
backgroundExecutor,
shouldAutoClose,
awaitConsistencyCallable,
stub.awaitOptimizeRestoredTableCallable());
}
return baseClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected BigtableTableAdminClientV2(
this.optimizeRestoredTableOperationBaseCallable = optimizeRestoredTableOperationBaseCallable;
}

private static AwaitConsistencyCallableV2 createAwaitConsistencyCallable(
static AwaitConsistencyCallableV2 createAwaitConsistencyCallable(
GrpcBigtableTableAdminStub stub,
BigtableTableAdminStubSettings settings,
ApiClock clock,
Comment thread
jinseopkim0 marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,12 @@ public UnaryCallable<ConsistencyRequest, Void> awaitConsistencyCallable() {
awaitOptimizeRestoredTableCallable() {
return optimizeRestoredTableOperationBaseCallable;
}

public BigtableTableAdminStubSettings getSettings() {
return settings;
}

public ClientContext getClientContext() {
return clientContext;
}
Comment thread
jinseopkim0 marked this conversation as resolved.
}
Loading