Skip to content

Commit 7fa95b4

Browse files
committed
fix(spanner): use cloudpath channel provider for admin stubs
1 parent 41d94da commit 7fa95b4

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ public GapicSpannerRpc(final SpannerOptions options) {
399399
options.getChannelEndpointCacheFactory(),
400400
endpointChannelConfigurator)
401401
: baseChannelProvider;
402+
TransportChannelProvider adminChannelProvider =
403+
useGcpFallback
404+
? createChannelProviderBuilder(
405+
options, headerProviderWithUserAgent, /* isEnableDirectAccess= */ false)
406+
.build()
407+
: channelProvider;
402408

403409
spannerWatchdog =
404410
Executors.newSingleThreadScheduledExecutor(
@@ -497,7 +503,7 @@ public GapicSpannerRpc(final SpannerOptions options) {
497503
pdmlSettings.build(), clientContext);
498504
this.instanceAdminStubSettings =
499505
options.getInstanceAdminStubSettings().toBuilder()
500-
.setTransportChannelProvider(channelProvider)
506+
.setTransportChannelProvider(adminChannelProvider)
501507
.setCredentialsProvider(credentialsProvider)
502508
.setStreamWatchdogProvider(watchdogProvider)
503509
.setTracerFactory(
@@ -508,7 +514,7 @@ public GapicSpannerRpc(final SpannerOptions options) {
508514

509515
this.databaseAdminStubSettings =
510516
options.getDatabaseAdminStubSettings().toBuilder()
511-
.setTransportChannelProvider(channelProvider)
517+
.setTransportChannelProvider(adminChannelProvider)
512518
.setCredentialsProvider(credentialsProvider)
513519
.setStreamWatchdogProvider(watchdogProvider)
514520
.setTracerFactory(
@@ -660,6 +666,9 @@ private void setupGcpFallback(
660666
InstantiatingGrpcChannelProvider.Builder cloudPathProviderBuilder =
661667
createBaseChannelProviderBuilder(
662668
options, headerProviderWithUserAgent, /* isEnableDirectAccess= */ false);
669+
if (options.isGrpcGcpExtensionEnabled()) {
670+
cloudPathProviderBuilder.setPoolSize(1);
671+
}
663672

664673
InstantiatingGrpcChannelProvider cloudPathProvider = cloudPathProviderBuilder.build();
665674
ManagedChannelBuilder cloudPathBuilder;

java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ private SpannerOptions createSpannerOptions() {
14341434
}
14351435

14361436
@Test
1437-
public void testDirectPathFallbackCreatesOneGrpcGcpLayerPerPath() {
1437+
public void testDirectPathFallbackUsesCloudPathForAdminClients() {
14381438
SpannerOptions.useEnvironment(new SpannerOptions.SpannerEnvironment() {});
14391439
GapicSpannerRpc rpc = null;
14401440
try {
@@ -1445,8 +1445,8 @@ public void testDirectPathFallbackCreatesOneGrpcGcpLayerPerPath() {
14451445
GrpcGcpObjectCounts before = countGrpcGcpObjectsFromChannelz();
14461446
rpc = new GapicSpannerRpc(options);
14471447
GrpcGcpObjectCounts counts = countGrpcGcpObjectsFromChannelz().minus(before);
1448-
assertEquals(counts.debugString(), 6, counts.gcpManagedChannels);
1449-
assertEquals(counts.debugString(), 48, counts.channelRefs);
1448+
assertEquals(counts.debugString(), 4, counts.gcpManagedChannels);
1449+
assertEquals(counts.debugString(), 32, counts.channelRefs);
14501450
} finally {
14511451
if (rpc != null) {
14521452
rpc.shutdown();

0 commit comments

Comments
 (0)