From 6ef36cb4fb4b31c63ade4ea35a6944a3cd6122ea Mon Sep 17 00:00:00 2001 From: surbhigarg92 Date: Fri, 15 Nov 2024 15:11:12 +0530 Subject: [PATCH] Created new grpc wrapper --- .../cloud/spanner/spi/v1/GapicSpannerRpc.java | 6 ++-- .../spanner/v1/stub/GrpcSpannerStub.java | 5 --- .../v1/stub/GrpcSpannerStubWrapper.java | 33 +++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStubWrapper.java diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java index e3bc407b775..8ae7b0c8579 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java @@ -80,7 +80,7 @@ import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStub; import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStubSettings; import com.google.cloud.spanner.encryption.EncryptionConfigProtoMapper; -import com.google.cloud.spanner.v1.stub.GrpcSpannerStub; +import com.google.cloud.spanner.v1.stub.GrpcSpannerStubWrapper; import com.google.cloud.spanner.v1.stub.SpannerStub; import com.google.cloud.spanner.v1.stub.SpannerStubSettings; import com.google.common.annotations.VisibleForTesting; @@ -410,7 +410,7 @@ public GapicSpannerRpc(final SpannerOptions options) { /* isAdminClient = */ false, isEmulatorEnabled(options, emulatorHost))) .build(); ClientContext clientContext = ClientContext.create(spannerStubSettings); - this.spannerStub = GrpcSpannerStub.create(spannerStubSettings, clientContext); + this.spannerStub = GrpcSpannerStubWrapper.create(spannerStubSettings, clientContext); BuiltInMetricsConstant.DIRECT_PATH_ENABLED = ((GrpcTransportChannel) clientContext.getTransportChannel()).isDirectPath() && isAttemptDirectPathXds; @@ -461,7 +461,7 @@ public GapicSpannerRpc(final SpannerOptions options) { .getStreamWatchdogProvider() .withCheckInterval(pdmlSettings.getStreamWatchdogCheckInterval())); } - this.partitionedDmlStub = GrpcSpannerStub.create(pdmlSettings.build()); + this.partitionedDmlStub = GrpcSpannerStubWrapper.create(pdmlSettings.build()); this.instanceAdminStubSettings = options .getInstanceAdminStubSettings() diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java index 322e3130e83..6d7cc8d0bc3 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java @@ -247,11 +247,6 @@ public static final GrpcSpannerStub create(ClientContext clientContext) throws I return new GrpcSpannerStub(SpannerStubSettings.newBuilder().build(), clientContext); } - public static final GrpcSpannerStub create( - SpannerStubSettings settings, ClientContext clientContext) throws IOException { - return new GrpcSpannerStub(settings, clientContext); - } - public static final GrpcSpannerStub create( ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { return new GrpcSpannerStub( diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStubWrapper.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStubWrapper.java new file mode 100644 index 00000000000..3a3943576bf --- /dev/null +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStubWrapper.java @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.spanner.v1.stub; + +import com.google.api.gax.rpc.ClientContext; +import java.io.IOException; + +public class GrpcSpannerStubWrapper extends GrpcSpannerStub { + + public static final GrpcSpannerStubWrapper create( + SpannerStubSettings settings, ClientContext clientContext) throws IOException { + return new GrpcSpannerStubWrapper(settings, clientContext); + } + + protected GrpcSpannerStubWrapper(SpannerStubSettings settings, ClientContext clientContext) + throws IOException { + super(settings, clientContext); + } +}