PoolProperties object for storing all the meta information about the connection pool.
As the underlying implementation, the connection pool uses java.util.concurrent.BlockingQueue to store active and idle connections.
A custom implementation of a fair FairBlockingQueue blocking queue is provided with the connection pool itself.
| Modifier and Type | Class and Description |
|---|---|
| protected class | ConnectionPool.
Thread safe wrapper around a future for the regular queue This one retrieves the pooled connection object and performs the initialization according to interceptors and validation rules. |
| protected static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final AtomicLong | borrowedCount
The counters for statistics of the pool. |
| private BlockingQueue | busy
Contains all the connections that are in use TODO - this shouldn't be a blocking queue, simply a list to hold our objects |
| private ThreadPoolExecutor | cancellator
Executor service used to cancel Futures |
| private static Set | |
| private volatile boolean | closed
Pool closed flag |
| private final AtomicLong | |
| private BlockingQueue | idle
Contains all the idle connections |
| protected ConnectionPool | jmxPool
reference to the JMX mbean |
| private static final Log | log
Logger |
| public static final String | POOL_JMX_DOMAIN
Default domain for objects registering with an mbean server |
| public static final String | POOL_JMX_TYPE_PREFIX
Prefix type for JMX registration |
| private volatile ConnectionPool. | poolCleaner
The thread that is responsible for checking abandoned and idle threads |
| private static volatile Timer | |
| private PoolConfiguration | poolProperties
All the information about the connection pool These are the properties the pool got instantiated with |
| private AtomicLong | |
| private Constructor | proxyClassConstructor
Since newProxyInstance performs the same operation, over and over again, it is much more optimized if we simply store the constructor ourselves. |
| private final AtomicLong | |
| private final AtomicLong | |
| private final AtomicLong | |
| private final AtomicLong | |
| private final AtomicLong | |
| private AtomicInteger | size
Carries the size of the pool, instead of relying on a queue implementation that usually iterates over to get an exact count |
| private AtomicInteger | waitcount
counter to track how many threads are waiting for a connection |
| Access | Constructor and Description |
|---|---|
| public | ConnectionPool(PoolConfiguration
PoolProperties - all the properties for this connection pool prop)Instantiate a connection pool. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | abandon(PooledConnection
PooledConnection con)thread safe way to abandon a connection signals a connection to be abandoned. |
| private PooledConnection | Returns: a connection- time to wait, overrides the maxWait from the properties,
set to -1 if you wish to use maxWait, 0 if you wish no wait time. wait, String The user name to use for the connection username, String The password for the connection password)Thread safe way to retrieve a connection from the pool |
| protected PooledConnection | Returns: a connection- timestamp now, PooledConnection - the connection to validate and configure con, String The user name to use for the connection username, String The password for the connection password)Validates and configures a previously idle connection |
| public void | checkAbandoned()
Iterates through all the busy connections and checks for connections that have timed out |
| public void | checkIdle()
Iterates through the idle connections and resizes the idle pool based on parameters
|
| public void | |
| public void | |
| protected void | |
| protected PooledConnection | Returns: a pooled connection objecttrue to increment the connection countCreate a new pooled connection object. |
| protected PooledConnection | Returns: a PooledConnection that has been connectedtimestamp of when this was called now, PooledConnection Argument not used notUsed, String The user name to use for the connection username, String The password for the connection password)Creates a JDBC connection and tries to connect to the database. |
| protected void | |
| protected void | disconnectEvent(PooledConnection
The connection con, boolean true if finalizing the connectionHook to perform final actions on a pooled connection object once it has been disconnected and will be discarded |
| protected void | finalize(PooledConnection
The connection con)Hook to perform final actions on a pooled connection object once it has been disconnected and will be discarded |
| public int | Returns: int - number of established connections that are being used by the applicationReturns the number of connections that are in use |
| public long | Returns: the borrowed connection countThe total number of connections borrowed from this pool. |
| public Connection | Returns: Connection - a java.sql.Connection/javax.sql.PooledConnection reflection proxy, wrapping the underlying object.Borrows a connection from the pool. |
| public Connection | Returns: Connection - a java.sql.Connection/javax.sql.PooledConnection reflection proxy, wrapping the underlying object.The user name to use for the connection username, String The password for the connection password)Borrows a connection from the pool. |
| public Future | Returns: a Future containing a reference to the connection or the future connectionRetrieves a Connection future. |
| public long | Returns: the created connection countThe total number of connections created by this pool. |
| public int | Returns: int - number of established connections not being usedReturns the number of idle connections |
| public ConnectionPool | Returns: the object implementing theorg. interfaceReturn the object that is potentially registered in JMX for notifications |
| public String | |
| public static synchronized Set | |
| public PoolConfiguration | Returns: PoolPropertiesReturns the pool properties associated with this connection pool |
| public static synchronized Timer | |
| public long | |
| public Constructor | Returns: constructor used to instantiate the wrapper objectUse a XA connection xa)Creates and caches a |
| public long | Returns: the reconnected connection countThe total number of connections reconnected by this pool. |
| public long | Returns: the released connection countThe total number of connections released from this pool. |
| public long | Returns: the PoolCleaner evicted idle connection countThe total number of connections released by eviction. |
| public long | Returns: the PoolCleaner removed abandoned connection countThe total number of connections released by remove abandoned. |
| public long | Returns: the returned connection countThe total number of connections returned to this pool. |
| public int | Returns: int - number of established connections to the databaseReturns the total size of this pool, this includes both busy and idle connections |
| public static String | Returns: a string representing the stack trace- the throwable x)Convert an exception into a String |
| protected static String | Returns: a string object representing the current state. TODO investigate if we simply should storejava. elementsCreates a stack trace representing the existing thread's current state. |
| public int | Returns: number of threads waiting for a connectionReturn the number of threads waiting for a connection |
| protected void | init(PoolConfiguration
PoolProperties - properties used to initialize the pool with properties)Initialize the connection pool - called from the constructor |
| public void | |
| public boolean | |
| private boolean | Returns: true if pool is either configured to test connections on connect or a non-NULL init SQL has been configuredReturns whether new connections should be initialized by invoking
|
| public void | |
| public void | |
| protected boolean | Returns: true if the connection was either not expired or expired but reconnecting succeeded, false if reconnecting failed (either because a new connection could not be established or validating the newly created connection failed)PooledConnection con)Checks whether this connection has |
| private static synchronized void | |
| protected void | |
| public void | |
| protected void | returnConnection(PooledConnection
PooledConnection to be returned to the pool con)Returns a connection to the pool If the pool is closed, the connection will be released If the connection is not part of the busy queue, it will be released. |
| protected Connection | Returns: ajava. object wrapping a pooled connection.a con)PooledConnection to wrap in a Proxyconfigures a pooled connection as a proxy. |
| protected boolean | Returns: true if the connection should be abandonedDetermines if a connection should be abandoned based on
|
| protected boolean | Returns: true if the connection should be closed- the connection con, int - the validation action that should be performed action)Determines if a connection should be closed upon return to the pool. |
| protected boolean | |
| protected void | |
| public void | |
| protected boolean | Returns: true if the connection TX termination succeeded
otherwise falseThe connection con)Terminate the current transaction for the given connection. |
| public void | |
| public void | testAllIdle(boolean
whether to only check checkMaxAgeOnly)PooledConnection#isMaxAgeExpired() but
not invoke PooledConnection#validate(int)Forces a validation of all idle connections if |
| private static synchronized void |