-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore(spanner): introduce commitRpcTimeout to connection properties #13801
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
base: main
Are you sure you want to change the base?
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 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,6 +43,7 @@ | |||||||||||||||||||||||||||||||||||||
| import static com.google.cloud.spanner.connection.ConnectionProperties.ENDPOINT; | ||||||||||||||||||||||||||||||||||||||
| import static com.google.cloud.spanner.connection.ConnectionProperties.GRPC_INTERCEPTOR_PROVIDER; | ||||||||||||||||||||||||||||||||||||||
| import static com.google.cloud.spanner.connection.ConnectionProperties.GRPC_KEEPALIVE_TIME; | ||||||||||||||||||||||||||||||||||||||
| import static com.google.cloud.spanner.connection.ConnectionProperties.COMMIT_RPC_TIMEOUT; | ||||||||||||||||||||||||||||||||||||||
| import static com.google.cloud.spanner.connection.ConnectionProperties.GRPC_KEEPALIVE_TIMEOUT; | ||||||||||||||||||||||||||||||||||||||
| import static com.google.cloud.spanner.connection.ConnectionProperties.IS_EXPERIMENTAL_HOST; | ||||||||||||||||||||||||||||||||||||||
| import static com.google.cloud.spanner.connection.ConnectionProperties.LENIENT; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -284,6 +285,9 @@ public class ConnectionOptions { | |||||||||||||||||||||||||||||||||||||
| /** Name of the 'grpcKeepAliveTime' connection property. */ | ||||||||||||||||||||||||||||||||||||||
| public static final String GRPC_KEEPALIVE_TIME_PROPERTY_NAME = "grpcKeepAliveTime"; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /** Name of the 'commitRpcTimeout' connection property. */ | ||||||||||||||||||||||||||||||||||||||
| public static final String COMMIT_RPC_TIMEOUT_PROPERTY_NAME = "commitRpcTimeout"; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /** Name of the 'grpcKeepAliveTimeout' connection property. */ | ||||||||||||||||||||||||||||||||||||||
| public static final String GRPC_KEEPALIVE_TIMEOUT_PROPERTY_NAME = "grpcKeepAliveTimeout"; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -1092,6 +1096,11 @@ public Integer getNumChannels() { | |||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /** The gRPC keepalive time for this connection. */ | ||||||||||||||||||||||||||||||||||||||
| /** The commit RPC timeout for this connection. */ | ||||||||||||||||||||||||||||||||||||||
| public Duration getCommitRpcTimeout() { | ||||||||||||||||||||||||||||||||||||||
| return getInitialConnectionPropertyValue(COMMIT_RPC_TIMEOUT); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| public Duration getGrpcKeepAliveTime() { | ||||||||||||||||||||||||||||||||||||||
| return getInitialConnectionPropertyValue(GRPC_KEEPALIVE_TIME); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1098
to
1106
Contributor
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. The Javadoc comment for
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -153,6 +153,7 @@ static class SpannerPoolKey { | |||||
| private final String host; | ||||||
| private final String projectId; | ||||||
| private final Duration grpcKeepAliveTime; | ||||||
| final Duration commitRpcTimeout; | ||||||
|
Contributor
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. The field
Suggested change
|
||||||
| private final Duration grpcKeepAliveTimeout; | ||||||
| private final CredentialsKey credentialsKey; | ||||||
| private final SessionPoolOptions sessionPoolOptions; | ||||||
|
|
@@ -226,6 +227,7 @@ private SpannerPoolKey(ConnectionOptions options) throws IOException { | |||||
| this.universeDomain = options.getUniverseDomain(); | ||||||
| this.grpcInterceptorProvider = options.getGrpcInterceptorProviderName(); | ||||||
| this.grpcKeepAliveTime = options.getGrpcKeepAliveTime(); | ||||||
| this.commitRpcTimeout = options.getCommitRpcTimeout(); | ||||||
| this.grpcKeepAliveTimeout = options.getGrpcKeepAliveTimeout(); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -266,6 +268,7 @@ public boolean equals(Object o) { | |||||
| && Objects.equals(this.universeDomain, other.universeDomain) | ||||||
| && Objects.equals(this.grpcInterceptorProvider, other.grpcInterceptorProvider) | ||||||
| && Objects.equals(this.grpcKeepAliveTime, other.grpcKeepAliveTime) | ||||||
| && Objects.equals(this.commitRpcTimeout, other.commitRpcTimeout) | ||||||
| && Objects.equals(this.grpcKeepAliveTimeout, other.grpcKeepAliveTimeout); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -301,6 +304,7 @@ public int hashCode() { | |||||
| this.universeDomain, | ||||||
| this.grpcInterceptorProvider, | ||||||
| this.grpcKeepAliveTime, | ||||||
| commitRpcTimeout, | ||||||
|
Contributor
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.grpcKeepAliveTimeout); | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -522,6 +526,9 @@ Spanner createSpanner(SpannerPoolKey key, ConnectionOptions options) { | |||||
| if (key.grpcKeepAliveTime != null) { | ||||||
| builder.setGrpcKeepAliveTime(key.grpcKeepAliveTime); | ||||||
| } | ||||||
| if (key.commitRpcTimeout != null) { | ||||||
| builder.setCommitRpcTimeout(key.commitRpcTimeout); | ||||||
| } | ||||||
| if (key.grpcKeepAliveTimeout != null) { | ||||||
| builder.setGrpcKeepAliveTimeout(key.grpcKeepAliveTimeout); | ||||||
| } | ||||||
|
|
||||||
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.
To prevent invalid configurations early, consider adding a check to ensure that
commitRpcTimeoutis not negative when it is non-null.