Package org.ldaptive.pool
Class BlockingConnectionPool
java.lang.Object
org.ldaptive.AbstractFreezable
org.ldaptive.pool.AbstractConnectionPool
org.ldaptive.pool.BlockingConnectionPool
- All Implemented Interfaces:
Freezable,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 PooledConnectionProxyThis blocks until a connection can be acquired.Returns the block wait time.Returns a connection from the pool.voidReturns a connection to the pool.protected PooledConnectionProxyAttempts to retrieve a connection from the available queue.voidsetBlockWaitTime(Duration time) Sets the block wait time.toString()Methods inherited from class org.ldaptive.pool.AbstractConnectionPool
activateAndValidateConnection, activeCount, availableCount, close, createActiveConnection, createAvailableConnection, createAvailableConnections, createConnectionProxy, freeze, getActivator, getConnectOnCreate, getDefaultConnectionFactory, getFailFastInitialize, getMaxPoolSize, getMinPoolSize, getName, getPassivator, getPooledConnectionStatistics, getPruneStrategy, getQueueType, getValidator, 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, validateMethods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
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:AbstractConnectionPoolReturns a connection from the pool.- Specified by:
getConnectionin interfaceConnectionPool- Specified by:
getConnectionin 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:AbstractConnectionPoolReturns a connection to the pool.- Specified by:
putConnectionin classAbstractConnectionPool- Parameters:
c- connection
-
toString
- Overrides:
toStringin classAbstractConnectionPool
-