Package org.attribyte.sql.pool
Class ConnectionPool.Initializer
java.lang.Object
org.attribyte.sql.pool.ConnectionPool.Initializer
- Enclosing class:
ConnectionPool
Initializes and creates connection pools.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddActiveSegment(ConnectionPoolSegment segment) Adds an active segment to the pool.addActiveSegments(List<ConnectionPoolSegment> segments) Adds active segments to the pool.Adds an alias for this pool.addReserveSegment(ConnectionPoolSegment segment) Adds a reserve segment to the pool.addReserveSegments(List<ConnectionPoolSegment> segments) Adds reserve segments to the pool.Creates a configured pool.static final List<ConnectionPool.Initializer> fromConfig(com.typesafe.config.Config config, PasswordSource passwordSource, org.attribyte.api.Logger logger) Create anInitializerfor each configured pool.static final List<ConnectionPool.Initializer> fromConfigFile(File configFile, PasswordSource passwordSource, org.attribyte.api.Logger logger) Parse a config file to create anInitializerfor each configured pool.static final List<ConnectionPool.Initializer> fromProperties(Properties props, PasswordSource passwordSource, org.attribyte.api.Logger logger) Parse properties to create anInitializerfor each configured pool.static final List<ConnectionPool.Initializer> fromPropertiesFile(File propsFile, PasswordSource passwordSource, org.attribyte.api.Logger logger) Parse properties to create anInitializerfor each configured pool.getAka()longintlonggetName()longsetIdleCheckInterval(long idleCheckInterval, TimeUnit idleCheckIntervalUnit) Sets the interval between checks for idle segments.setLogger(org.attribyte.api.Logger logger) Sets the logger.setMinActiveSegments(int minActiveSegments) Sets the minimum number of active statements.setMinSegmentExpansionDelay(long minSegmentExpansionDelayMillis) Sets the minimum delay between segment expansions in milliseconds.Sets the name of the pool.setSaturatedAcquireTimeout(long saturatedAcquireTimeout, TimeUnit saturatedAcquireTimeoutUnit) Sets the maximum amount of time to wait for an available connection when pool is saturated.
-
Constructor Details
-
Initializer
public Initializer()
-
-
Method Details
-
fromConfig
public static final List<ConnectionPool.Initializer> fromConfig(com.typesafe.config.Config config, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException Create anInitializerfor each configured pool.- Parameters:
config- The configuration.passwordSource- The password source. May benull.logger- The logger. May benull.- Returns:
- The list of
Initializers. - Throws:
org.attribyte.api.InitializationException- on invalid configuration.
-
fromConfigFile
public static final List<ConnectionPool.Initializer> fromConfigFile(File configFile, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException Parse a config file to create anInitializerfor each configured pool.File format is HOCON. Configuration must appear in the path:
acp- Parameters:
configFile- The config file.passwordSource- The password source. May benull.logger- The logger. May benull.- Returns:
- The list of
Initializers. - Throws:
org.attribyte.api.InitializationException- on invalid file or configuration.
-
fromProperties
public static final List<ConnectionPool.Initializer> fromProperties(Properties props, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException Parse properties to create anInitializerfor each configured pool.- Parameters:
props- The properties.passwordSource- The password source. May benull.logger- The logger. May benull.- Returns:
- The list of
Initializers. - Throws:
org.attribyte.api.InitializationException- on invalid configuration.
-
fromPropertiesFile
public static final List<ConnectionPool.Initializer> fromPropertiesFile(File propsFile, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException Parse properties to create anInitializerfor each configured pool.- Parameters:
propsFile- A properties file.passwordSource- The password source. May benull.logger- The logger. May benull.- Returns:
- The list of
Initializers. - Throws:
org.attribyte.api.InitializationException- on invalid file or configuration.
-
setName
Sets the name of the pool.- Parameters:
name- The name.- Returns:
- A self-reference.
-
addActiveSegment
Adds an active segment to the pool.- Parameters:
segment- The segment to add.- Returns:
- A self-reference.
-
addActiveSegments
Adds active segments to the pool.- Parameters:
segments- The segments to add.- Returns:
- A self-reference.
-
addReserveSegment
Adds a reserve segment to the pool.- Parameters:
segment- The segment to add.- Returns:
- A self-reference.
-
addReserveSegments
Adds reserve segments to the pool.- Parameters:
segments- The segments to add.- Returns:
- A self-reference.
-
setMinActiveSegments
Sets the minimum number of active statements.- Parameters:
minActiveSegments- The minimum number of active segments.- Returns:
- A self-reference.
-
setMinSegmentExpansionDelay
Sets the minimum delay between segment expansions in milliseconds.- Parameters:
minSegmentExpansionDelayMillis- The delay.- Returns:
- A self-reference.
-
setIdleCheckInterval
public ConnectionPool.Initializer setIdleCheckInterval(long idleCheckInterval, TimeUnit idleCheckIntervalUnit) Sets the interval between checks for idle segments.- Parameters:
idleCheckInterval- The idle check interval.idleCheckIntervalUnit- The idle check interval units.- Returns:
- A self-reference.
-
setSaturatedAcquireTimeout
public ConnectionPool.Initializer setSaturatedAcquireTimeout(long saturatedAcquireTimeout, TimeUnit saturatedAcquireTimeoutUnit) Sets the maximum amount of time to wait for an available connection when pool is saturated.- Parameters:
saturatedAcquireTimeout- The saturated acquire timeout.saturatedAcquireTimeoutUnit- The saturated acquire timeout units.- Returns:
- A self-reference.
-
setLogger
Sets the logger.- Parameters:
logger- The logger.- Returns:
- A self-reference.
-
addAlias
Adds an alias for this pool.- Parameters:
alias- The alias name.- Returns:
- A self-reference.
-
createPool
Creates a configured pool.- Returns:
- The pool.
- Throws:
org.attribyte.api.InitializationException- if pool was improperly configured.
-
getName
- Returns:
- The name.
-
getAka
- Returns:
- The set of alias names.
-
getMinActiveSegments
public int getMinActiveSegments()- Returns:
- The minimum number of active segments.
-
getMinSegmentExpansionDelayMillis
public long getMinSegmentExpansionDelayMillis()- Returns:
- The minimum expansion delay in milliseconds.
-
getSaturatedAcquireTimeoutMillis
public long getSaturatedAcquireTimeoutMillis()- Returns:
- The saturated acquire timeout in milliseconds.
-
getIdleCheckIntervalMillis
public long getIdleCheckIntervalMillis()- Returns:
- The idle check interval in milliseconds.
-