|
60 | 60 | import com.google.cloud.spanner.admin.instance.v1.stub.GrpcInstanceAdminStub; |
61 | 61 | import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStub; |
62 | 62 | import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStubSettings; |
63 | | -import com.google.cloud.spanner.spi.v1.SpannerRpc.Option; |
64 | 63 | import com.google.cloud.spanner.v1.stub.GrpcSpannerStub; |
65 | 64 | import com.google.cloud.spanner.v1.stub.SpannerStub; |
66 | 65 | import com.google.cloud.spanner.v1.stub.SpannerStubSettings; |
|
171 | 170 | /** Implementation of Cloud Spanner remote calls using Gapic libraries. */ |
172 | 171 | @InternalApi |
173 | 172 | public class GapicSpannerRpc implements SpannerRpc { |
| 173 | + |
174 | 174 | /** |
175 | 175 | * {@link ExecutorProvider} that keeps track of the executors that are created and shuts these |
176 | 176 | * down when the {@link SpannerRpc} is closed. |
177 | 177 | */ |
178 | 178 | private static final class ManagedInstantiatingExecutorProvider implements ExecutorProvider { |
| 179 | + |
179 | 180 | // 4 Gapic clients * 4 channels per client. |
180 | 181 | private static final int DEFAULT_MIN_THREAD_COUNT = 16; |
181 | 182 | private final List<ScheduledExecutorService> executors = new LinkedList<>(); |
@@ -317,7 +318,11 @@ public GapicSpannerRpc(final SpannerOptions options) { |
317 | 318 | .setMaxInboundMessageSize(MAX_MESSAGE_SIZE) |
318 | 319 | .setMaxInboundMetadataSize(MAX_METADATA_SIZE) |
319 | 320 | .setPoolSize(options.getNumChannels()) |
320 | | - .setExecutor(executorProvider.getExecutor()) |
| 321 | + |
| 322 | + // Before updating this method to setExecutor, please verify with a code owner on |
| 323 | + // the lowest version of gax-grpc that needs to be supported. Currently v1.47.17, |
| 324 | + // which doesn't support the setExecutor variant. |
| 325 | + .setExecutorProvider(executorProvider) |
321 | 326 |
|
322 | 327 | // Set a keepalive time of 120 seconds to help long running |
323 | 328 | // commit GRPC calls succeed |
@@ -480,6 +485,7 @@ private static void checkEmulatorConnection( |
480 | 485 |
|
481 | 486 | private static final class OperationFutureRetryAlgorithm<ResultT, MetadataT> |
482 | 487 | implements ResultRetryAlgorithm<OperationFuture<ResultT, MetadataT>> { |
| 488 | + |
483 | 489 | private static final ImmutableList<StatusCode.Code> RETRYABLE_CODES = |
484 | 490 | ImmutableList.of(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE); |
485 | 491 |
|
@@ -519,6 +525,7 @@ public boolean shouldRetry( |
519 | 525 |
|
520 | 526 | private final class OperationFutureCallable<RequestT, ResponseT, MetadataT extends Message> |
521 | 527 | implements Callable<OperationFuture<ResponseT, MetadataT>> { |
| 528 | + |
522 | 529 | final OperationCallable<RequestT, ResponseT, MetadataT> operationCallable; |
523 | 530 | final RequestT initialRequest; |
524 | 531 | final MethodDescriptor<RequestT, Operation> method; |
@@ -575,6 +582,7 @@ public OperationFuture<ResponseT, MetadataT> call() throws Exception { |
575 | 582 | } |
576 | 583 |
|
577 | 584 | private interface OperationsLister { |
| 585 | + |
578 | 586 | Paginated<Operation> listOperations(String nextPageToken); |
579 | 587 | } |
580 | 588 |
|
@@ -610,6 +618,7 @@ private Operation mostRecentOperation( |
610 | 618 | } |
611 | 619 |
|
612 | 620 | private static final class TimestampComparator implements Comparator<Timestamp> { |
| 621 | + |
613 | 622 | private static final TimestampComparator INSTANCE = new TimestampComparator(); |
614 | 623 |
|
615 | 624 | @Override |
@@ -1458,6 +1467,7 @@ public boolean isClosed() { |
1458 | 1467 | * the {@link ResultStreamConsumer}. |
1459 | 1468 | */ |
1460 | 1469 | private static class SpannerResponseObserver implements ResponseObserver<PartialResultSet> { |
| 1470 | + |
1461 | 1471 | private StreamController controller; |
1462 | 1472 | private final ResultStreamConsumer consumer; |
1463 | 1473 |
|
|
0 commit comments