From fe6dc796db6aa4c28832457ca54e6952a4b51c7e Mon Sep 17 00:00:00 2001 From: Thiago Nunes Date: Tue, 15 Sep 2020 14:38:42 +1000 Subject: [PATCH] fix: uses old version of gax-grpc method (#426) Internally, we are using version 1.47.1 of the gax-grpc library, which does not provide a method currently being used (setExecutor). In here we use a method that is available in 1.47.1 and achieves the same goal (setExecutorProvider). --- .../cloud/spanner/spi/v1/GapicSpannerRpc.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 152c8f0b34..50af8b0667 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 @@ -60,7 +60,6 @@ import com.google.cloud.spanner.admin.instance.v1.stub.GrpcInstanceAdminStub; 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.spi.v1.SpannerRpc.Option; import com.google.cloud.spanner.v1.stub.GrpcSpannerStub; import com.google.cloud.spanner.v1.stub.SpannerStub; import com.google.cloud.spanner.v1.stub.SpannerStubSettings; @@ -171,11 +170,13 @@ /** Implementation of Cloud Spanner remote calls using Gapic libraries. */ @InternalApi public class GapicSpannerRpc implements SpannerRpc { + /** * {@link ExecutorProvider} that keeps track of the executors that are created and shuts these * down when the {@link SpannerRpc} is closed. */ private static final class ManagedInstantiatingExecutorProvider implements ExecutorProvider { + // 4 Gapic clients * 4 channels per client. private static final int DEFAULT_MIN_THREAD_COUNT = 16; private final List executors = new LinkedList<>(); @@ -317,7 +318,11 @@ public GapicSpannerRpc(final SpannerOptions options) { .setMaxInboundMessageSize(MAX_MESSAGE_SIZE) .setMaxInboundMetadataSize(MAX_METADATA_SIZE) .setPoolSize(options.getNumChannels()) - .setExecutor(executorProvider.getExecutor()) + + // Before updating this method to setExecutor, please verify with a code owner on + // the lowest version of gax-grpc that needs to be supported. Currently v1.47.17, + // which doesn't support the setExecutor variant. + .setExecutorProvider(executorProvider) // Set a keepalive time of 120 seconds to help long running // commit GRPC calls succeed @@ -480,6 +485,7 @@ private static void checkEmulatorConnection( private static final class OperationFutureRetryAlgorithm implements ResultRetryAlgorithm> { + private static final ImmutableList RETRYABLE_CODES = ImmutableList.of(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE); @@ -519,6 +525,7 @@ public boolean shouldRetry( private final class OperationFutureCallable implements Callable> { + final OperationCallable operationCallable; final RequestT initialRequest; final MethodDescriptor method; @@ -575,6 +582,7 @@ public OperationFuture call() throws Exception { } private interface OperationsLister { + Paginated listOperations(String nextPageToken); } @@ -610,6 +618,7 @@ private Operation mostRecentOperation( } private static final class TimestampComparator implements Comparator { + private static final TimestampComparator INSTANCE = new TimestampComparator(); @Override @@ -1458,6 +1467,7 @@ public boolean isClosed() { * the {@link ResultStreamConsumer}. */ private static class SpannerResponseObserver implements ResponseObserver { + private StreamController controller; private final ResultStreamConsumer consumer;