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
feat: Add experimental DirectPath support #396
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 |
---|---|---|
|
@@ -223,6 +223,9 @@ private void awaitTermination() throws InterruptedException { | |
private static final int DEFAULT_PERIOD_SECONDS = 10; | ||
private static final int GRPC_KEEPALIVE_SECONDS = 2 * 60; | ||
|
||
// TODO(weiranf): Remove this temporary endpoint once DirectPath goes to public beta. | ||
private static final String DIRECT_PATH_ENDPOINT = "aa423245250f2bbf.sandbox.googleapis.com:443"; | ||
|
||
private final ManagedInstantiatingExecutorProvider executorProvider; | ||
private boolean rpcIsClosed; | ||
private final SpannerStub spannerStub; | ||
|
@@ -300,31 +303,37 @@ public GapicSpannerRpc(final SpannerOptions options) { | |
.build()); | ||
// First check if SpannerOptions provides a TransportChannerProvider. Create one | ||
// with information gathered from SpannerOptions if none is provided | ||
InstantiatingGrpcChannelProvider.Builder defaultChannelProviderBuilder = | ||
InstantiatingGrpcChannelProvider.newBuilder() | ||
.setChannelConfigurator(options.getChannelConfigurator()) | ||
.setEndpoint(options.getEndpoint()) | ||
.setMaxInboundMessageSize(MAX_MESSAGE_SIZE) | ||
.setMaxInboundMetadataSize(MAX_METADATA_SIZE) | ||
.setPoolSize(options.getNumChannels()) | ||
.setExecutor(executorProvider.getExecutor()) | ||
|
||
// Set a keepalive time of 120 seconds to help long running | ||
// commit GRPC calls succeed | ||
.setKeepAliveTime(Duration.ofSeconds(GRPC_KEEPALIVE_SECONDS)) | ||
|
||
// Then check if SpannerOptions provides an InterceptorProvider. Create a default | ||
// SpannerInterceptorProvider if none is provided | ||
.setInterceptorProvider( | ||
SpannerInterceptorProvider.create( | ||
MoreObjects.firstNonNull( | ||
options.getInterceptorProvider(), | ||
SpannerInterceptorProvider.createDefault())) | ||
.withEncoding(compressorName)) | ||
.setHeaderProvider(mergedHeaderProvider); | ||
|
||
// TODO(weiranf): Set to true by default once DirectPath goes to public beta. | ||
if (shouldAttemptDirectPath()) { | ||
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. I think that currently we are mostly enabling features / configurations through environment variables (which should be standardised through all of our clients) or through the I imagine we could add an option like Wdyt? 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. Hi Thiago, thanks for the comment! So our original idea is, the DirectPath is a network side feature, it should be agnostic to the end users. Currently we add this 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. That makes sense, thanks for the response. A couple of questions on the approach:
Thanks! 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. Good questions! To answer them: This sandbox endpoint is only used for our testing purposes (as right now DirectPath-ipv4 is only available in certain cell in prod) Once we've done enough tests and DirectPath is fully ready, Spanner will make its default endpoint to be capable of handling DirectPath traffic. So by that time, we will use the same endpoint no matter the client is using DirectPath or Not. |
||
defaultChannelProviderBuilder.setEndpoint(DIRECT_PATH_ENDPOINT).setAttemptDirectPath(true); | ||
} | ||
|
||
TransportChannelProvider channelProvider = | ||
MoreObjects.firstNonNull( | ||
options.getChannelProvider(), | ||
InstantiatingGrpcChannelProvider.newBuilder() | ||
.setChannelConfigurator(options.getChannelConfigurator()) | ||
.setEndpoint(options.getEndpoint()) | ||
.setMaxInboundMessageSize(MAX_MESSAGE_SIZE) | ||
.setMaxInboundMetadataSize(MAX_METADATA_SIZE) | ||
.setPoolSize(options.getNumChannels()) | ||
.setExecutor(executorProvider.getExecutor()) | ||
|
||
// Set a keepalive time of 120 seconds to help long running | ||
// commit GRPC calls succeed | ||
.setKeepAliveTime(Duration.ofSeconds(GRPC_KEEPALIVE_SECONDS)) | ||
|
||
// Then check if SpannerOptions provides an InterceptorProvider. Create a default | ||
// SpannerInterceptorProvider if none is provided | ||
.setInterceptorProvider( | ||
SpannerInterceptorProvider.create( | ||
MoreObjects.firstNonNull( | ||
options.getInterceptorProvider(), | ||
SpannerInterceptorProvider.createDefault())) | ||
.withEncoding(compressorName)) | ||
.setHeaderProvider(mergedHeaderProvider) | ||
.build()); | ||
options.getChannelProvider(), defaultChannelProviderBuilder.build()); | ||
|
||
CredentialsProvider credentialsProvider = | ||
GrpcTransportOptions.setUpCredentialsProvider(options); | ||
|
@@ -415,6 +424,11 @@ public GapicSpannerRpc(final SpannerOptions options) { | |
} | ||
} | ||
|
||
// TODO(weiranf): Remove this once DirectPath goes to public beta. | ||
private static boolean shouldAttemptDirectPath() { | ||
return Boolean.getBoolean("spanner.attempt_directpath"); | ||
} | ||
|
||
private static void checkEmulatorConnection( | ||
SpannerOptions options, | ||
TransportChannelProvider channelProvider, | ||
|
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.
I only see this being set to
false
. Do we need this configuration?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.
Hi Jeff, I added this configuration just for our internal test to be able to use
-DskipUTs=true
. Currently we are usingmvn verify -am -pl google-cloud-spanner -B -Penable-integration-tests,spanner-directpath-it -DskipUTs=true -D... ...
for our internal E2E DP tests, and meanwhile I don't want to change the behavior for other tests. Do you think this is the right way for approaching this purpose?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.
I might add a note somewhere so we don't inadvertently break this.
We might also want to add something like this to our shared setup.