Package com.google.cloud.spanner
Class SessionPoolOptions.Builder
- java.lang.Object
-
- com.google.cloud.spanner.SessionPoolOptions.Builder
-
- Enclosing class:
- SessionPoolOptions
public static class SessionPoolOptions.Builder extends Object
Builder for creating SessionPoolOptions.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SessionPoolOptions
build()
Build a SessionPoolOption objectSessionPoolOptions.Builder
setAutoDetectDialect(boolean autoDetectDialect)
Sets whether the client should automatically execute a background query to detect the dialect that is used by the database or not.SessionPoolOptions.Builder
setBlockIfPoolExhausted()
If all sessions are in use and there is no more room for creating new sessions, block for a session to become available.SessionPoolOptions.Builder
setFailIfPoolExhausted()
If all sessions are in use and andmaxSessions
has been reached, fail the request by throwing aSpannerException
with the error codeRESOURCE_EXHAUSTED
.SessionPoolOptions.Builder
setKeepAliveIntervalMinutes(int intervalMinutes)
How frequently to keep alive idle sessions.SessionPoolOptions.Builder
setMaxIdleSessions(int maxIdleSessions)
Deprecated.set a higher value forsetMinSessions(int)
instead of using this configuration option.SessionPoolOptions.Builder
setMaxSessions(int maxSessions)
Maximum number of sessions that this pool will have.SessionPoolOptions.Builder
setMinSessions(int minSessions)
Minimum number of sessions that this pool will always maintain.SessionPoolOptions.Builder
setRemoveInactiveSessionAfter(org.threeten.bp.Duration duration)
SessionPoolOptions.Builder
setWriteSessionsFraction(float writeSessionsFraction)
Deprecated.This configuration value is no longer in use.
-
-
-
Method Detail
-
setMinSessions
public SessionPoolOptions.Builder setMinSessions(int minSessions)
Minimum number of sessions that this pool will always maintain. These will be created eagerly in parallel. Defaults to 100.
-
setMaxSessions
public SessionPoolOptions.Builder setMaxSessions(int maxSessions)
Maximum number of sessions that this pool will have. If current numbers of sessions in the pool is less than this and they are all busy, then a new session will be created for any new operation. If current number of in use sessions is same as this and a new request comes, pool can either block or fail. Defaults to 400.
-
setMaxIdleSessions
@Deprecated public SessionPoolOptions.Builder setMaxIdleSessions(int maxIdleSessions)
Deprecated.set a higher value forsetMinSessions(int)
instead of using this configuration option. This option will be removed in a future release.Maximum number of idle sessions that this pool will maintain. Pool will close any sessions beyond this but making sure to always have at least as many sessions as specified bysetMinSessions(int)
. To determine how many sessions are idle we look at maximum number of sessions used concurrently over a window of time. Any sessions beyond that are idle. Defaults to 0.
-
setRemoveInactiveSessionAfter
public SessionPoolOptions.Builder setRemoveInactiveSessionAfter(org.threeten.bp.Duration duration)
-
setKeepAliveIntervalMinutes
public SessionPoolOptions.Builder setKeepAliveIntervalMinutes(int intervalMinutes)
How frequently to keep alive idle sessions. This should be less than 60 since an idle session is automatically closed after 60 minutes. Sessions will be kept alive by sending a dummy query "Select 1". Default value is 30 minutes.
-
setFailIfPoolExhausted
public SessionPoolOptions.Builder setFailIfPoolExhausted()
If all sessions are in use and andmaxSessions
has been reached, fail the request by throwing aSpannerException
with the error codeRESOURCE_EXHAUSTED
. Default behavior is to block the request.
-
setBlockIfPoolExhausted
public SessionPoolOptions.Builder setBlockIfPoolExhausted()
If all sessions are in use and there is no more room for creating new sessions, block for a session to become available. Default behavior is same.
-
setAutoDetectDialect
public SessionPoolOptions.Builder setAutoDetectDialect(boolean autoDetectDialect)
Sets whether the client should automatically execute a background query to detect the dialect that is used by the database or not. Set this option to true if you do not know what the dialect of the database will be.Note that you can always call
DatabaseClient.getDialect()
to get the dialect of a database regardless of this setting, but by setting this to true, the value will be pre-populated and cached in the client.- Parameters:
autoDetectDialect
- Whether the client should automatically execute a background query to detect the dialect of the underlying database- Returns:
- this builder for chaining
-
setWriteSessionsFraction
public SessionPoolOptions.Builder setWriteSessionsFraction(float writeSessionsFraction)
Deprecated.This configuration value is no longer in use. The session pool does not prepare any sessions for read/write transactions. Instead, a transaction will automatically be started by the first statement that is executed by a transaction by including a BeginTransaction option with that statement.This method may be removed in a future release.
-
build
public SessionPoolOptions build()
Build a SessionPoolOption object
-
-