allenpradeep commented on a change in pull request #13990:
URL: https://github.com/apache/beam/pull/13990#discussion_r577270669



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java
##########
@@ -150,14 +189,34 @@ private static SpannerAccessor 
createAndConnect(SpannerConfig spannerConfig) {
     ValueProvider<String> host = spannerConfig.getHost();
     if (host != null) {
       builder.setHost(host.get());
+      instantiatingGrpcChannelProvider.setEndpoint(getEndpoint(host.get()));
     }
     ValueProvider<String> emulatorHost = spannerConfig.getEmulatorHost();
     if (emulatorHost != null) {
       builder.setEmulatorHost(emulatorHost.get());
       builder.setCredentials(NoCredentials.getInstance());
+    } else {

Review comment:
       This is to enable a fail fast if the emulator is not running, but the 
user has set the emulator host environment variable.
   
   As per 
[function-checkEmulatorConnection](https://github.com/googleapis/java-spanner/blob/master/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java#L497-L539)
 [line 
502](https://github.com/googleapis/java-spanner/blob/master/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java#L502),
 the fail fast link works only if the channelprovider is set to null. This 
workaround only sets the channel provider only when we are not going to connect 
to emulator.
   
   cc @thiagotnunes




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to