public class BlockingConnectionPool extends AbstractConnectionPool
getBlockWaitTime()
. By default the pool will block indefinitely 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
.AbstractConnectionPool.DefaultPooledConnectionProxy
Modifier and Type | Field and Description |
---|---|
private Duration |
blockWaitTime
Duration to wait for an available connection.
|
active, available, checkInLock, checkOutLock, poolLock, poolNotEmpty
logger
Constructor and Description |
---|
BlockingConnectionPool()
Creates a new blocking pool.
|
BlockingConnectionPool(DefaultConnectionFactory cf)
Creates a new blocking pool.
|
BlockingConnectionPool(PoolConfig pc,
DefaultConnectionFactory cf)
Creates a new blocking pool.
|
Modifier and Type | Method and Description |
---|---|
protected PooledConnectionProxy |
blockAvailableConnection()
This blocks until a connection can be acquired.
|
Duration |
getBlockWaitTime()
Returns the block wait time.
|
Connection |
getConnection()
Returns a connection from the pool.
|
void |
putConnection(Connection c)
Returns a connection to the pool.
|
protected PooledConnectionProxy |
retrieveAvailableConnection()
Attempts to retrieve a connection from the available queue.
|
void |
setBlockWaitTime(Duration time)
Sets the block wait time.
|
activateAndValidateConnection, activeCount, availableCount, close, createActiveConnection, createActiveConnection, createAvailableConnection, createAvailableConnection, createConnection, createConnection, createConnectionProxy, finalize, getConnectionFactory, getConnectOnCreate, getFailFastInitialize, getPooledConnectionStatistics, getQueueType, grow, grow, initialize, isInitialized, prune, removeActiveConnection, removeAvailableAndActiveConnection, removeAvailableConnection, retrieveConnectionProxy, setConnectionFactory, setConnectOnCreate, setFailFastInitialize, setQueueType, throwIfNotInitialized, toString, validate, validateAndPassivateConnection
activate, getActivator, getName, getPassivator, getPoolConfig, getPruneStrategy, getValidator, passivate, setActivator, setName, setPassivator, setPoolConfig, setPruneStrategy, setValidator, validate
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getActivator, getPassivator, getValidator, setActivator, setPassivator, setValidator
private Duration blockWaitTime
public BlockingConnectionPool()
public BlockingConnectionPool(DefaultConnectionFactory cf)
cf
- connection factorypublic BlockingConnectionPool(PoolConfig pc, DefaultConnectionFactory cf)
pc
- pool configurationcf
- connection factorypublic Duration getBlockWaitTime()
public void setBlockWaitTime(Duration time)
time
- to wait for available connectionspublic Connection getConnection() throws PoolException
AbstractConnectionPool
getConnection
in interface ConnectionPool
getConnection
in class AbstractConnectionPool
PoolException
- if this operation failsBlockingTimeoutException
- if this pool is configured with a block time and it occursPoolInterruptedException
- if this pool is configured with a block time and the current thread is
interruptedprotected PooledConnectionProxy retrieveAvailableConnection()
NoSuchElementException
- if the available queue is emptyprotected PooledConnectionProxy blockAvailableConnection() throws PoolException
PoolException
- if this method failsBlockingTimeoutException
- if this pool is configured with a block time and it occursPoolInterruptedException
- if the current thread is interruptedpublic void putConnection(Connection c)
AbstractConnectionPool
putConnection
in class AbstractConnectionPool
c
- connectionCopyright © 2003-2019 Virginia Tech. All Rights Reserved.