Package org.attribyte.sql.pool
Class ConnectionPoolSegment.Initializer
java.lang.Object
org.attribyte.sql.pool.ConnectionPoolSegment.Initializer
- Enclosing class:
ConnectionPoolSegment
Initializes and creates a connection pool segment.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty initializer.Creates an initializer from another. -
Method Summary
Modifier and TypeMethodDescriptionCreates a segment after configuration.booleanDoes this initializer have a connection set?setAcquireTimeout(long timeout, TimeUnit timeoutUnit) Sets the maximum amount of time to wait for a connection if all are busy.setActiveTimeout(long timeout, TimeUnit timeoutUnit) Sets the maximum amount of time a connection may be active before automatically closed.setActiveTimeoutMonitorFrequency(long timeout, TimeUnit timeoutUnit) Sets the frequency the active timeout monitor runs.setActivityTimeoutPolicy(ConnectionPoolConnection.ActivityTimeoutPolicy activityTimeoutPolicy) Sets the policy followed by the pool when a connection activity timeout is reached.setCloseConcurrency(int closerConcurrency) Sets the number of threads handling connection close.setCloseTimeLimitMillis(long closeTimeLimitMillis) Sets the maximum amount of time connection close will block.setConnection(JDBConnection jdbcConnection) Sets the database connection.setConnectionLifetime(long connectionLife, TimeUnit connectionLifeUnit) Sets the lifetime of (real) connections before automatic close/reopen.setForceRealClosePolicy(ConnectionPoolConnection.ForceRealClosePolicy forceRealClosePolicy) Sets the policy followed by the pool when a "forced" close is trigger (for example, connection is in-use longer than the configured maximum lease time).setIdleTimeBeforeShutdown(long time, TimeUnit timeUnit) Sets the time this segment must be idle before it is shutdown.setIncompleteTransactionOnClosePolicy(ConnectionPoolConnection.IncompleteTransactionPolicy incompleteTransactionPolicy) Sets the incomplete transaction (on close) policy.setLogger(org.attribyte.api.Logger logger) Sets the logger for this segment.setMaxConcurrentReconnects(int maxConcurrentReconnects) Sets the maximum number of simultaneous database reconnect attempts.setMaxReconnectDelay(long time, TimeUnit timeUnit) Sets the maximum delay (after failure) between reconnect attempts.setMinActiveTime(long time, TimeUnit timeUnit) Sets the minimum time this segment must be active before it is eligible for shutdown.Sets the name of the segment.setOpenStatementOnClosePolicy(ConnectionPoolConnection.OpenStatementPolicy openStatementPolicy) Sets the open statement (on close) policy.setPasswordSource(PasswordSource passwordSource) Sets a password source for this segment.setSize(int size) Sets the number of connections in the segment.setTestOnLogicalClose(boolean testOnLogicalClose) Sets the option to test connections when they are logically closed.setTestOnLogicalOpen(boolean testOnLogicalOpen) Sets thr option to test connections when they are logically opened.voidvalidate(boolean withDefaults) Verify that all required initialization variables are set.
-
Constructor Details
-
Initializer
public Initializer()Creates an empty initializer. -
Initializer
Creates an initializer from another.Does not copy the name segment name.
- Parameters:
other- The other initializer.
-
-
Method Details
-
setName
Sets the name of the segment.- Parameters:
name- The segment name.- Returns:
- A self-reference.
-
setLogger
Sets the logger for this segment.- Parameters:
logger- The logger.- Returns:
- A self-reference.
-
setSize
Sets the number of connections in the segment.- Parameters:
size- The segment size.- Returns:
- A self-reference.
-
setAcquireTimeout
Sets the maximum amount of time to wait for a connection if all are busy.- Parameters:
timeout- The timeout value.timeoutUnit- The timeout units.- Returns:
- A self-reference.
-
setActiveTimeout
Sets the maximum amount of time a connection may be active before automatically closed.- Parameters:
timeout- The timeout value.timeoutUnit- The timeout units.- Returns:
- A self-reference.
-
setActiveTimeoutMonitorFrequency
public ConnectionPoolSegment.Initializer setActiveTimeoutMonitorFrequency(long timeout, TimeUnit timeoutUnit) Sets the frequency the active timeout monitor runs.- Parameters:
timeout- The frequency value.timeoutUnit- The frequency units.- Returns:
- A self-reference.
-
setConnectionLifetime
public ConnectionPoolSegment.Initializer setConnectionLifetime(long connectionLife, TimeUnit connectionLifeUnit) Sets the lifetime of (real) connections before automatic close/reopen.- Parameters:
connectionLife- The connection life.connectionLifeUnit- The connection life units.- Returns:
- A self-reference.
-
setConnection
Sets the database connection.- Parameters:
jdbcConnection- The connection.- Returns:
- A self-reference.
-
hasConnection
public boolean hasConnection()Does this initializer have a connection set?- Returns:
- Is the connection set?
-
setCloseConcurrency
Sets the number of threads handling connection close. Default is0.If concurrency is
0(logical) close operations will be performed (and block) in the calling thread. Higher concurrency allows close to return immediately after queuing the connection, with this number of threads monitoring the queue.- Parameters:
closerConcurrency- The number of threads.- Returns:
- A self-reference.
-
setMaxConcurrentReconnects
Sets the maximum number of simultaneous database reconnect attempts.- Parameters:
maxConcurrentReconnects- The maximum number of concurrent reconnects.- Returns:
- A self-reference.
-
setMaxReconnectDelay
Sets the maximum delay (after failure) between reconnect attempts.- Parameters:
time- The time.timeUnit- The time unit.- Returns:
- A self-reference.
-
setTestOnLogicalOpen
Sets thr option to test connections when they are logically opened.- Parameters:
testOnLogicalOpen- Should connections be tested on logical open?.- Returns:
- A self-reference.
-
setTestOnLogicalClose
Sets the option to test connections when they are logically closed.- Parameters:
testOnLogicalClose- Should connections be tested on logical close?.- Returns:
- A self-reference.
-
setIdleTimeBeforeShutdown
Sets the time this segment must be idle before it is shutdown.- Parameters:
time- The time.timeUnit- The time unit.- Returns:
- A self-reference.
-
setMinActiveTime
Sets the minimum time this segment must be active before it is eligible for shutdown.- Parameters:
time- The time.timeUnit- The time unit.- Returns:
- A self-reference.
-
setPasswordSource
Sets a password source for this segment.- Parameters:
passwordSource- The password source.- Returns:
- A self-reference.
-
setIncompleteTransactionOnClosePolicy
public ConnectionPoolSegment.Initializer setIncompleteTransactionOnClosePolicy(ConnectionPoolConnection.IncompleteTransactionPolicy incompleteTransactionPolicy) Sets the incomplete transaction (on close) policy.- Parameters:
incompleteTransactionPolicy- The policy.- Returns:
- A self-reference.
-
setOpenStatementOnClosePolicy
public ConnectionPoolSegment.Initializer setOpenStatementOnClosePolicy(ConnectionPoolConnection.OpenStatementPolicy openStatementPolicy) Sets the open statement (on close) policy.- Parameters:
openStatementPolicy- The policy.- Returns:
- A self-reference.
-
setForceRealClosePolicy
public ConnectionPoolSegment.Initializer setForceRealClosePolicy(ConnectionPoolConnection.ForceRealClosePolicy forceRealClosePolicy) Sets the policy followed by the pool when a "forced" close is trigger (for example, connection is in-use longer than the configured maximum lease time).- Parameters:
forceRealClosePolicy- The policy.- Returns:
- A self-reference.
-
setCloseTimeLimitMillis
Sets the maximum amount of time connection close will block.- Parameters:
closeTimeLimitMillis- The time.- Returns:
- A self-reference.
-
setActivityTimeoutPolicy
public ConnectionPoolSegment.Initializer setActivityTimeoutPolicy(ConnectionPoolConnection.ActivityTimeoutPolicy activityTimeoutPolicy) Sets the policy followed by the pool when a connection activity timeout is reached. This may happen due to developer error (connection never closed), or due to long-running transactions.- Parameters:
activityTimeoutPolicy- The policy.- Returns:
- A self-reference.
-
createSegment
Creates a segment after configuration.- Returns:
- The segment.
- Throws:
org.attribyte.api.InitializationException- if configuration is invalid.
-
validate
public void validate(boolean withDefaults) throws org.attribyte.api.InitializationException Verify that all required initialization variables are set.- Parameters:
withDefaults- Iftruedefaults will be supplied if possible.- Throws:
org.attribyte.api.InitializationException- If initialization is invalid.
-