-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add directpath_enabled attribute #3380
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import com.google.api.gax.grpc.GrpcCallContext; | ||
import com.google.api.gax.grpc.GrpcCallSettings; | ||
import com.google.api.gax.grpc.GrpcStubCallableFactory; | ||
import com.google.api.gax.grpc.GrpcTransportChannel; | ||
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; | ||
import com.google.api.gax.longrunning.OperationFuture; | ||
import com.google.api.gax.retrying.ResultRetryAlgorithm; | ||
|
@@ -63,6 +64,7 @@ | |
import com.google.cloud.grpc.GrpcTransportOptions; | ||
import com.google.cloud.spanner.AdminRequestsPerMinuteExceededException; | ||
import com.google.cloud.spanner.BackupId; | ||
import com.google.cloud.spanner.BuiltInMetricsConstant; | ||
import com.google.cloud.spanner.ErrorCode; | ||
import com.google.cloud.spanner.Restore; | ||
import com.google.cloud.spanner.SpannerException; | ||
|
@@ -396,18 +398,22 @@ public GapicSpannerRpc(final SpannerOptions options) { | |
final String emulatorHost = System.getenv("SPANNER_EMULATOR_HOST"); | ||
|
||
try { | ||
this.spannerStub = | ||
GrpcSpannerStub.create( | ||
options | ||
.getSpannerStubSettings() | ||
.toBuilder() | ||
.setTransportChannelProvider(channelProvider) | ||
.setCredentialsProvider(credentialsProvider) | ||
.setStreamWatchdogProvider(watchdogProvider) | ||
.setTracerFactory( | ||
options.getApiTracerFactory( | ||
/* isAdminClient = */ false, isEmulatorEnabled(options, emulatorHost))) | ||
.build()); | ||
SpannerStubSettings spannerStubSettings = | ||
options | ||
.getSpannerStubSettings() | ||
.toBuilder() | ||
.setTransportChannelProvider(channelProvider) | ||
.setCredentialsProvider(credentialsProvider) | ||
.setStreamWatchdogProvider(watchdogProvider) | ||
.setTracerFactory( | ||
options.getApiTracerFactory( | ||
/* isAdminClient = */ false, isEmulatorEnabled(options, emulatorHost))) | ||
.build(); | ||
ClientContext clientContext = ClientContext.create(spannerStubSettings); | ||
this.spannerStub = GrpcSpannerStub.create(spannerStubSettings, clientContext); | ||
BuiltInMetricsConstant.DIRECT_PATH_ENABLED = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A user could create multiple Spanner instances. Then this code will be invoked multiple times. There is no guarantee that |
||
((GrpcTransportChannel) clientContext.getTransportChannel()).isDirectPath() | ||
&& isAttemptDirectPathXds; | ||
this.readRetrySettings = | ||
options.getSpannerStubSettings().streamingReadSettings().getRetrySettings(); | ||
this.readRetryableCodes = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,6 +247,11 @@ public static final GrpcSpannerStub create(ClientContext clientContext) throws I | |
return new GrpcSpannerStub(SpannerStubSettings.newBuilder().build(), clientContext); | ||
} | ||
|
||
public static final GrpcSpannerStub create( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a generated file, so you can't manually update it. (That is: you can update it, but the next round of code generation will overwrite your changes) |
||
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( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below: This calls a method in a generated file, and this method is manually added to that generated file. That will be overwritten the next time the code generation is run, so this won't work.