|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jolbox.bonecp.BoneCP
public class BoneCP
Connection pool (main class).
| Field Summary | |
|---|---|
protected boolean |
closeConnectionWatch
If set to true, create a new thread that monitors a connection and displays warnings if application failed to close the connection. |
protected boolean |
externalAuth
Config setting. |
static String |
MBEAN_BONECP
JMX constant. |
static String |
MBEAN_CONFIG
JMX constant. |
protected int |
poolAvailabilityThreshold
Create more connections when we hit x% of our possible number of connections. |
protected boolean |
poolShuttingDown
set to true if the connection pool has been flagged as shutting down. |
protected Lock |
terminationLock
Prevent repeated termination of all connections when the DB goes down. |
| Constructor Summary | |
|---|---|
BoneCP(BoneCPConfig config)
Constructor. |
|
| Method Summary | |
|---|---|
protected String |
captureStackTrace(String message)
Throw an exception to capture it so as to be able to print it out later on |
void |
close()
Just a synonym to shutdown. |
Future<Connection> |
getAsyncConnection()
Obtain a connection asynchronously by queueing a request to obtain a connection in a separate thread. |
BoneCPConfig |
getConfig()
Gets config object. |
Connection |
getConnection()
Returns a free connection. |
protected com.google.common.base.FinalizableReferenceQueue |
getFinalizableRefQueue()
Watch for connections that should have been safely closed but the application forgot. |
protected Map<Connection,Reference<ConnectionHandle>> |
getFinalizableRefs()
Return the finalizable refs handle. |
protected ExecutorService |
getReleaseHelper()
|
protected ExecutorService |
getStatementCloseHelperExecutor()
Returns the statementCloseHelper field. |
protected LinkedTransferQueue<StatementHandle> |
getStatementsPendingRelease()
Returns the statementsPendingRelease field. |
Statistics |
getStatistics()
Returns a reference to the statistics class. |
int |
getTotalCreatedConnections()
Return total number of connections created in all partitions. |
int |
getTotalFree()
Return the number of free connections available to an application right away (excluding connections that can be created dynamically) |
int |
getTotalLeased()
Return total number of connections currently in use by an application |
protected void |
initJMX()
Initialises JMX stuff. |
protected void |
initStmtReleaseHelper(String suffix)
Starts off threads released to statement release helpers. |
protected void |
internalReleaseConnection(ConnectionHandle connectionHandle)
Release a connection by placing the connection back in the pool. |
boolean |
isConnectionHandleAlive(ConnectionHandle connection)
Sends a dummy statement to the server to keep the connection alive |
protected boolean |
isReleaseHelperThreadsConfigured()
Returns the releaseHelperThreadsConfigured field. |
protected boolean |
isStatementReleaseHelperThreadsConfigured()
Returns the statementReleaseHelperThreadsConfigured field. |
protected Connection |
obtainRawInternalConnection()
Returns a database connection by using Driver.getConnection() or DataSource.getConnection() |
protected void |
postDestroyConnection(ConnectionHandle handle)
Update counters and call hooks. |
protected void |
putConnectionBackInPartition(ConnectionHandle connectionHandle)
Places a connection back in the originating partition. |
protected void |
releaseConnection(Connection connection)
Releases the given connection back to the pool. |
protected void |
setReleaseHelper(ExecutorService releaseHelper)
|
protected void |
setStatementCloseHelperExecutor(ExecutorService statementCloseHelper)
Sets the statementCloseHelper field. |
void |
shutdown()
Closes off this connection pool. |
protected void |
terminateAllConnections()
Closes off all connections in all partitions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MBEAN_CONFIG
public static final String MBEAN_BONECP
protected final int poolAvailabilityThreshold
protected Lock terminationLock
protected boolean closeConnectionWatch
protected volatile boolean poolShuttingDown
protected boolean externalAuth
| Constructor Detail |
|---|
public BoneCP(BoneCPConfig config)
throws SQLException
config - Configuration for pool
SQLException - on error| Method Detail |
|---|
public void shutdown()
public void close()
protected void terminateAllConnections()
protected void postDestroyConnection(ConnectionHandle handle)
handle - connection handle.
protected Connection obtainRawInternalConnection()
throws SQLException
SQLException - on errorprotected void initStmtReleaseHelper(String suffix)
suffix - of poolprotected void initJMX()
public Connection getConnection()
throws SQLException
SQLExceptionprotected String captureStackTrace(String message)
message - message to display
public Future<Connection> getAsyncConnection()
Future<Connection> result = pool.getAsyncConnection();
... do something else in your application here ...
Connection connection = result.get(); // get the connection
protected void releaseConnection(Connection connection)
throws SQLException
connection - to release
SQLException
protected void internalReleaseConnection(ConnectionHandle connectionHandle)
throws SQLException
connectionHandle - Connection being released.
SQLException
protected void putConnectionBackInPartition(ConnectionHandle connectionHandle)
throws SQLException
connectionHandle - to place back
SQLException - on errorpublic boolean isConnectionHandleAlive(ConnectionHandle connection)
connection - Connection handle to perform activity on
public int getTotalLeased()
public int getTotalFree()
public int getTotalCreatedConnections()
public BoneCPConfig getConfig()
protected ExecutorService getReleaseHelper()
protected void setReleaseHelper(ExecutorService releaseHelper)
releaseHelper - the releaseHelper to setprotected Map<Connection,Reference<ConnectionHandle>> getFinalizableRefs()
protected com.google.common.base.FinalizableReferenceQueue getFinalizableRefQueue()
protected ExecutorService getStatementCloseHelperExecutor()
protected void setStatementCloseHelperExecutor(ExecutorService statementCloseHelper)
statementCloseHelper - the statementCloseHelper to setprotected boolean isReleaseHelperThreadsConfigured()
protected boolean isStatementReleaseHelperThreadsConfigured()
protected LinkedTransferQueue<StatementHandle> getStatementsPendingRelease()
public Statistics getStatistics()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||