-
Notifications
You must be signed in to change notification settings - Fork 113
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: increase default number of channels when gRPC-GCP channel pool is enabled #1997
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4b44b1a
increase default number of channels when grpc-gcp channel pool is ena…
harshachinta 34d7623
Merge remote-tracking branch 'origin/main'
harshachinta 860462a
add java file header
harshachinta f2e2d8f
increase default number of channels when grpc-gcp channel pool is ena…
harshachinta 15e3155
fix lint issue
harshachinta 7a3ed3c
fix lint issue
harshachinta 1449429
code fixes
harshachinta 5f516cb
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Sp…
rajatbhatta afec666
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Sp…
rajatbhatta 1fe3d48
lint fixes
harshachinta 60cfa2a
Merge remote-tracking branch 'origin/main'
harshachinta e68b2f5
Modify comments for better code readability
harshachinta a334e09
lint fix
harshachinta 27962ea
add test to verify default num of channels when gRPC-GCP is not enabled
harshachinta 68e72d4
Add tests to verify number of channels and the instances created
harshachinta 33682fc
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] faa74ed
code refactoring for setting the default numChannels
harshachinta 3d81b1f
Merge remote-tracking branch 'origin/main'
harshachinta a88d4e3
lint fix
harshachinta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -89,6 +89,11 @@ 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; | ||||||
@VisibleForTesting 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 +674,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 +1126,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 +1136,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 +1172,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; | ||||||
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.num
Suggested change
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. Thanks for the suggestion @olavloite. This makes it more readable than the previous one. |
||||||
} | ||||||
|
||||||
return new SpannerOptions(this); | ||||||
} | ||||||
} | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove this and instead assign the default number of channels in the build method for both GCP enabled and disabled. (See also below)