-
Notifications
You must be signed in to change notification settings - Fork 136
feat: increase default number of channels when gRPC-GCP channel pool is enabled #1997
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
Changes from 13 commits
4b44b1a
34d7623
860462a
f2e2d8f
15e3155
7a3ed3c
1449429
5f516cb
afec666
1fe3d48
60cfa2a
e68b2f5
a334e09
27962ea
68e72d4
33682fc
faa74ed
3d81b1f
a88d4e3
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,12 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> { | |||||
| "https://www.googleapis.com/auth/spanner.admin", | ||||||
| "https://www.googleapis.com/auth/spanner.data"); | ||||||
| private static final int MAX_CHANNELS = 256; | ||||||
| private static final int DEFAULT_CHANNELS = 4; | ||||||
| // Set the default number of channels to GRPC_GCP_ENABLED_DEFAULT_CHANNELS when gRPC-GCP extension | ||||||
| // is enabled, | ||||||
| // to make sure there are sufficient channels available to move the sessions to a different | ||||||
| // channel if a network connection in a particular channel fails. | ||||||
| @VisibleForTesting static final int GRPC_GCP_ENABLED_DEFAULT_CHANNELS = 8; | ||||||
| private final TransportChannelProvider channelProvider; | ||||||
|
|
||||||
| @SuppressWarnings("rawtypes") | ||||||
|
|
@@ -669,8 +675,7 @@ public static class Builder | |||||
|
|
||||||
| private GrpcInterceptorProvider interceptorProvider; | ||||||
|
|
||||||
| /** By default, we create 4 channels per {@link SpannerOptions} */ | ||||||
| private int numChannels = 4; | ||||||
| private Integer numChannels; | ||||||
|
|
||||||
| private String transportChannelExecutorThreadNameFormat = "Cloud-Spanner-TransportChannel-%d"; | ||||||
|
|
||||||
|
|
@@ -1122,8 +1127,7 @@ public Builder setHost(String host) { | |||||
|
|
||||||
| /** Enables gRPC-GCP extension with the default settings. */ | ||||||
| public Builder enableGrpcGcpExtension() { | ||||||
| this.grpcGcpExtensionEnabled = true; | ||||||
| return this; | ||||||
| return this.enableGrpcGcpExtension(null); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -1133,6 +1137,9 @@ public Builder enableGrpcGcpExtension() { | |||||
| public Builder enableGrpcGcpExtension(GcpManagedChannelOptions options) { | ||||||
| this.grpcGcpExtensionEnabled = true; | ||||||
| this.grpcGcpOptions = options; | ||||||
| if (this.numChannels == null) { | ||||||
| this.numChannels = GRPC_GCP_ENABLED_DEFAULT_CHANNELS; | ||||||
| } | ||||||
|
||||||
| return this; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -1166,6 +1173,10 @@ public SpannerOptions build() { | |||||
| // As we are using plain text, we should never send any credentials. | ||||||
| this.setCredentials(NoCredentials.getInstance()); | ||||||
| } | ||||||
| if (this.numChannels == null) { | ||||||
| this.numChannels = DEFAULT_CHANNELS; | ||||||
|
||||||
| this.numChannels = DEFAULT_CHANNELS; | |
| this.numChannels = this.grpcGcpExtensionEnabled ? GRPC_GCP_ENABLED_DEFAULT_CHANNELS : DEFAULT_CHANNELS; |
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.
Thanks for the suggestion @olavloite. This makes it more readable than the previous one.
I have made the changes in the recent commit.
Uh oh!
There was an error while loading. Please reload this page.