Class ConnectionPoolConfig
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConnectionPoolConfig
corePool
(int corePoolSize, boolean forceCorePool) A connection selection strategy that prioritizes a configurable "core" pool.static ConnectionPoolConfig
A connection selection strategy that prioritizes connection reuse.static ConnectionPoolConfig
linearSearch
(int linearSearchSpace) A connection selection strategy that prioritizes connection reuse.static ConnectionPoolConfig
p2c
(int corePoolSize, boolean forceCorePool) AConnectionPoolStrategy
that attempts to discern between the health of individual connections.static ConnectionPoolConfig
p2c
(int maxEffort, int corePoolSize, boolean forceCorePool) AConnectionPoolStrategy
that attempts to discern between the health of individual connections.
-
Method Details
-
corePool
A connection selection strategy that prioritizes a configurable "core" pool.This
ConnectionPoolStrategy
attempts to emulate the pooling behavior often seen in thread pools. Specifically it allows for the configuration of a "core pool" size which are intended to be long-lived. Iteration starts in the core pool at a random position and then iterates through the entire core pool before moving to an overflow pool. Because iteration of this core pool starts at a random position the core connections will get an even traffic load and, because they are equally selectable, will tend not to be removed due to idleness.If the core pool cannot satisfy the load traffic can spill over to extra connections which are selected in-order. This has the property of minimizing traffic to the latest elements added outside the core pool size, thus let them idle out of the pool once they're no longer necessary.
- Parameters:
corePoolSize
- the size of the core pool.forceCorePool
- whether to avoid selecting connections from the core pool until it has reached the configured core pool size.- Returns:
- the configured
ConnectionPoolConfig
.
-
linearSearch
A connection selection strategy that prioritizes connection reuse.This
ConnectionPoolStrategy
attempts to minimize the number of connections by attempting to direct traffic to connections in the order they were created in linear order up until a configured quantity. After this linear pool is exhausted the remaining connections will be selected from at random. Prioritizing traffic to the existing connections will let tailing connections be removed due to idleness.- Returns:
- the configured
ConnectionPoolConfig
.
-
linearSearch
A connection selection strategy that prioritizes connection reuse.This
ConnectionPoolStrategy
attempts to minimize the number of connections by attempting to direct traffic to connections in the order they were created in linear order up until a configured quantity. After this linear pool is exhausted the remaining connections will be selected from at random. Prioritizing traffic to the existing connections will let tailing connections be removed due to idleness.- Parameters:
linearSearchSpace
- the space to search linearly before resorting to random selection for remaining connections.- Returns:
- the configured
ConnectionPoolConfig
.
-
p2c
AConnectionPoolStrategy
that attempts to discern between the health of individual connections. If individual connections have health data the P2C strategy can be used to bias traffic toward the best connections. This has the following algorithm: - Randomly select two connections from the 'core pool' (pick-two). - Try to select the 'best' of the two connections. - If we fail to select the best connection, try the other connection. - If both connections fail, repeat the pick-two operation for up to maxEffort attempts, begin linear iteration through the remaining connections searching for an acceptable connection.- Parameters:
corePoolSize
- the size of the core pool.forceCorePool
- whether to avoid selecting connections from the core pool until it has reached the configured core pool size.- Returns:
- the configured
ConnectionPoolConfig
.
-
p2c
AConnectionPoolStrategy
that attempts to discern between the health of individual connections. If individual connections have health data the P2C strategy can be used to bias traffic toward the best connections. This has the following algorithm: - Randomly select two connections from the 'core pool' (pick-two). - Try to select the 'best' of the two connections. - If we fail to select the best connection, try the other connection. - If both connections fail, repeat the pick-two operation for up to maxEffort attempts, begin linear iteration through the remaining connections searching for an acceptable connection.- Parameters:
maxEffort
- the maximum number of attempts to pick a healthy connection from the core pool.corePoolSize
- the size of the core pool.forceCorePool
- whether to avoid selecting connections from the core pool until it has reached the configured core pool size.- Returns:
- the configured
ConnectionPoolConfig
.
-