Package org.ldaptive.pool
Class BlockingConnectionPool
java.lang.Object
org.ldaptive.pool.AbstractConnectionPool
org.ldaptive.pool.BlockingConnectionPool
- All Implemented Interfaces:
ConnectionPool
- Direct Known Subclasses:
PooledConnectionFactory
Implements a pool of connections that has a set minimum and maximum size. The pool will not grow beyond the maximum
size and when the pool is exhausted, requests for new connections will block. The length of time the pool will block
is determined by
getBlockWaitTime()
. By default, the pool will block for 1 minute and there is no guarantee
that waiting threads will be serviced in the order in which they made their request. This implementation should be
used when you need to control the exact number of connections that can be created. See AbstractConnectionPool
.-
Nested Class Summary
Nested classes/interfaces inherited from class org.ldaptive.pool.AbstractConnectionPool
AbstractConnectionPool.DefaultPooledConnectionProxy
-
Field Summary
FieldsFields inherited from class org.ldaptive.pool.AbstractConnectionPool
active, available, checkOutLock, DEFAULT_MAX_POOL_SIZE, DEFAULT_MIN_POOL_SIZE, logger, poolLock, poolNotEmpty
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new blocking pool.Creates a new blocking pool. -
Method Summary
Modifier and TypeMethodDescriptionprotected PooledConnectionProxy
This blocks until a connection can be acquired.Returns the block wait time.Returns a connection from the pool.void
Returns a connection to the pool.protected PooledConnectionProxy
Attempts to retrieve a connection from the available queue.void
setBlockWaitTime
(Duration time) Sets the block wait time.toString()
Methods inherited from class org.ldaptive.pool.AbstractConnectionPool
activateAndValidateConnection, activeCount, availableCount, close, createActiveConnection, createAvailableConnection, createConnection, createConnectionProxy, getActivator, getConnectOnCreate, getDefaultConnectionFactory, getFailFastInitialize, getMaxPoolSize, getMinPoolSize, getName, getPassivator, getPooledConnectionStatistics, getPruneStrategy, getQueueType, getValidator, grow, grow, initialize, isInitialized, isValidateOnCheckIn, isValidateOnCheckOut, isValidatePeriodically, passivateAndValidateConnection, prune, removeActiveConnection, removeAvailableAndActiveConnection, removeAvailableConnection, retrieveConnectionProxy, setActivator, setConnectOnCreate, setDefaultConnectionFactory, setFailFastInitialize, setMaxPoolSize, setMinPoolSize, setName, setPassivator, setPruneStrategy, setQueueType, setValidateOnCheckIn, setValidateOnCheckOut, setValidatePeriodically, setValidator, throwIfNotInitialized, validate, validateAndPassivateConnection
-
Field Details
-
blockWaitTime
Duration to wait for an available connection.
-
-
Constructor Details
-
BlockingConnectionPool
public BlockingConnectionPool()Creates a new blocking pool. -
BlockingConnectionPool
Creates a new blocking pool.- Parameters:
cf
- connection factory
-
-
Method Details
-
getBlockWaitTime
Returns the block wait time. Default time is 1 minute.- Returns:
- time to wait for available connections
-
setBlockWaitTime
Sets the block wait time. Default time is 1 minute.- Parameters:
time
- to wait for available connections
-
getConnection
Description copied from class:AbstractConnectionPool
Returns a connection from the pool.- Specified by:
getConnection
in interfaceConnectionPool
- Specified by:
getConnection
in classAbstractConnectionPool
- Returns:
- connection
- Throws:
PoolException
- if this operation failsBlockingTimeoutException
- if this pool is configured with a block time and it occurs
-
retrieveAvailableConnection
Attempts to retrieve a connection from the available queue.- Returns:
- connection from the pool
- Throws:
NoSuchElementException
- if the available queue is empty
-
blockAvailableConnection
This blocks until a connection can be acquired.- Returns:
- connection from the pool
- Throws:
PoolException
- if this method failsBlockingTimeoutException
- if this pool is configured with a block time and it occurs
-
putConnection
Description copied from class:AbstractConnectionPool
Returns a connection to the pool.- Specified by:
putConnection
in classAbstractConnectionPool
- Parameters:
c
- connection
-
toString
- Overrides:
toString
in classAbstractConnectionPool
-