public class DBConnectionPool
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DBConnectionPool.ConnectionSetting |
Modifier and Type | Field and Description |
---|---|
static int |
LEGACY_FROM_COBOC_PROPERTIES |
static int |
LEGACY_FROM_DSO |
static int |
LEGACY_FROM_WSAPP_PROPERTIES |
Constructor and Description |
---|
DBConnectionPool(IManagedComponent parentComponent,
java.lang.String name,
java.lang.String description,
int legacySource)
Creates a connection pool with the input configuration
|
DBConnectionPool(int configurationNode)
Deprecated.
Use the constructor with a managed parent component instead.
|
Modifier and Type | Method and Description |
---|---|
static DBConnectionPool |
_createInstance(int dso,
IManagedComponent parentComponent,
java.lang.String name,
java.lang.String description)
Creates the DBConnectionPool with the properties given in the dso xml.
|
static javax.sql.XADataSource |
_getXADataSource()
This is an internal method, do not use!
|
static void |
_setXADataSource(javax.sql.XADataSource ds)
This is an internal method, do not use!
|
void |
addCustomProblemStatusEventListener(IProblemStatusEventListener problemStatusEventListener) |
protected void |
finalize() |
int |
getConnectionPoolRefreshInterval()
Get the refresh interval set for this connection pool
|
int |
getCursorCacheRefreshInterval()
Gives the time interval in which cursor cache can be refreshed to clean up un-used open cursors.
|
int |
getCursorCacheSize()
Gives the size of the cache for cursors.
|
int |
getDefaultCursorSize()
Gives the default size of cursor.
|
java.lang.String |
getDriver()
Gets the connector/driver for which the connection pool is configured
It can be OLEDB or JDBC
|
static DBConnectionPool |
getInstance(IManagedComponent parentComponent,
java.lang.String name,
java.lang.String description,
int legacySource)
Get an instance of DBConnectionPool either from the cache or create a new connection pool, based on the sharedPool setting
If sharedPool setting is true that means the connection pool is shared among multiple components
And the actual values taken by the connection pool for creating connections and cache will be determined by connection pool
|
CordysLogger |
getLogger()
Retreives the logger that needs to be used.
|
int |
getMaximumReadConnections()
Gives the maximum number of read connections configured for this pool
|
int |
getMaximumWriteConnections()
Gives the maximum number of write connections configured for this connection pool
|
int |
getMinimumReadConnections()
Gives the minimum number of read connections configured for this pool
|
int |
getMinimumWriteConnections()
Gives the minimum number of write connections configured for this pool
|
WCPDBConnection |
getNonBlockingReadConnection()
Retreives a read connection in non-blocking mode from the read connection pool.
|
WCPDBConnection |
getNonBlockingWriteConnection()
Retrieves a write connection in non-blocking mode from the connection pool.
|
int |
getNumberOfCachedQueries()
Gives the total number for queries cached in all the connections available in the pool.
|
int |
getNumberOfOpenCursors()
Gives the total number for cursors cached in all the connections available in the pool.
|
int |
getNumOfCachedReadConnections()
Gives the total number of read connections present in the pool
|
int |
getNumOfCachedWriteConnections()
Gives the total number of write connections present in the pool
|
int |
getQueryCacheRefreshInterval()
Gives the time interval in which query cache can be refreshed to clean up un-used queries.
|
int |
getQueryCacheSize()
Gives the size of the cache for queries.
|
WCPDBConnection |
getReadConnection()
Retrieves a read connection from the connection pool.
|
WCPDBConnection |
getReadConnection(DBConnectionPool.ConnectionSetting... connectionSettings)
Method to get a read connection from the connection pool.
|
WCPDBConnection |
getReadConnection(int connectionId,
boolean mustWait)
Method to get a read connection from the connection pool based on a given connection id.
|
WCPDBConnection |
getReadConnection(int connectionId,
boolean mustWait,
DBConnectionPool.ConnectionSetting... connectionSettings)
Method to get a read connection from the connection pool based on a given connection id.
|
int |
getReadConnectionId(WCPDBConnection connection)
Method to get the connection id of the connection object, which is a read connection
It returns an integer connection id for the given connection object if it is available in the pool,
Other wise it returns -1.
|
int |
getReconnectionAttempts()
Get the re-connection attempts or tries set for this connection pool
|
long |
getReconnectionInterval()
Get the re-connection interval set for this connection pool
|
long |
getRequestThreshold()
Get the request threshold value set for this connection pool
|
WCPDBConnection |
getWriteConnection()
Retrieves a write connection from the connection pool.
|
WCPDBConnection |
getWriteConnection(int connectionId,
boolean mustWait)
Method to get a write connection from the connection pool based on a given connection id.
|
int |
getWriteConnectionId(WCPDBConnection connection)
Method to get the connection id of the connection object, which is a write connection
It returns an integer connection id for the given connection object if it is available in the pool,
Other wise it returns -1.
|
java.lang.String |
getXmlEncode()
Get the xml encoding set for this connection pool.
|
void |
initialize()
Intializes the connectionpool with already given configuration(either via xml or via managed component)
|
boolean |
isConnectionLost()
Checks if the connection is lost to the databse.
|
void |
putReadConnection(WCPDBConnection connection)
Method to put a read connection in the connection pool
|
void |
putWriteConnection(WCPDBConnection connection)
Method to put a write connection back to the connection pool
|
void |
registerConnectionProblem(long monitorInterval)
Registers the connection-failure problem.
|
void |
reset()
Clears all cache existing at the XQY layer for all connections in the pool
This includes cursor cache, query cache and meta data cache
|
void |
setConnectionLost(boolean connectionLost)
Sets the connection-lost status.
|
void |
setConnectionPoolRefreshInterval(int interval)
Set the time interval in seconds for refreshing connection pool
This can also be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setConversionConfiguration(int configurationNode)
Adds the conversion configuration.
|
void |
setCursorCacheRefreshInterval(int interval)
Set the time interval in seconds for refreshing cursor cache
This can also be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setCursorCacheSize(int size)
Set the size of the cursor cache
Cursor cache size also can be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setDefaultCursorSize(int size)
Set the default size of the cursor
|
void |
setLogger(CordysLogger logger)
Initializes the logger that needs to be used.
|
void |
setMaximumReadConnections(int newMaxReadConnectionCount)
Set the value for maximum number of read connections that can be stored in the connection pool at any point of time
This can also be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setMaximumWriteConnections(int newMaxWriteConnectionCount)
Set the value for maximum number of write connections that can be stored in the connection pool at any point of time
This can also be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setMinimumReadConnections(int newMinReadConnectionCount)
Set the value for minimum number of read connections needed in the connection pool at any point of time
This can also be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setMinimumWriteConnections(int newMinWriteConnectionCount)
Set the value for minimum number of write connections needed in the connection pool at any point of time
This can also be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setNumConnections(int newConnectionCount,
boolean isReadConnectionCount) |
void |
setQueryCacheRefreshInterval(int interval)
Set the time interval in seconds for refreshing query cache
This can also be set via configuration xml used for initializing connection pool or using jmx settings
|
void |
setQueryCacheSize(int size)
Set the size of the query cache
Query cache size also can be set via configuration xml or using jmx settings
|
void |
setReconnectionAttempts(int attempts)
Set the number of trials the pool need to try reconnection in case of connection failure during execution of request.
|
void |
setReconnectionInterval(long interval)
Set the time interval in seconds between two reconnection attempts.
|
void |
setRequestThreshold(long limit)
Set the time in milli seconds which is considered as a threshold limit for processing requests
Any request which takes more than this time will be logged as a warning.
|
void |
unsetXAConnection(WCPDBConnection connection) |
public static final int LEGACY_FROM_COBOC_PROPERTIES
public static final int LEGACY_FROM_DSO
public static final int LEGACY_FROM_WSAPP_PROPERTIES
@Deprecated public DBConnectionPool(int configurationNode)
configuration
- A pointer to a native XML tree containing configuration information for the Database Connections & pool
The xml can be represented in two formats. One in the old legacy dso format and another in new component and datasource format
public DBConnectionPool(IManagedComponent parentComponent, java.lang.String name, java.lang.String description, int legacySource)
configurationNode
- A pointer to a native XML tree containing configuration information for the Database Connections & poolparentComponent
- The parent managed component containing this connection pool. Can be null to indicate that the pool is not managed.name
- The name of this connection pool for representation in management tools. Can be null when the pool is not managed.description
- The description of this connection pool for representation in management tools. Can be null when the pool is not managed.legacySource
- Source for legacy property values. This is either LEGACY_FROM_COBOC_PROPERTIES or LEGACY_FROM_DSO.public WCPDBConnection getNonBlockingReadConnection()
public WCPDBConnection getReadConnection()
public WCPDBConnection getReadConnection(int connectionId, boolean mustWait)
connectionId
- An integer connectionId value which specifies the target connection idmustWait
- a boolean value which specifies whether it should wait till the required connection is available or not.public WCPDBConnection getReadConnection(int connectionId, boolean mustWait, DBConnectionPool.ConnectionSetting... connectionSettings)
connectionId
- An integer connectionId value which specifies the target connection idmustWait
- a boolean value which specifies whether it should wait till the required connection is available or not.connectionSettings
- a set of DBConnectionPool.ConnectionSettingpublic WCPDBConnection getReadConnection(DBConnectionPool.ConnectionSetting... connectionSettings)
connectionSettings
- a set of DBConnectionPool.ConnectionSettingpublic int getReadConnectionId(WCPDBConnection connection)
connection
- WCPDBConnection object to by which the connection id should be fetchedpublic void putReadConnection(WCPDBConnection connection) throws WCPDBConnectionException
connection
- WCPDBConnection object to put in the connection poolWCPDBConnectionException
- if the input connection does not belongs to the connection-poolpublic WCPDBConnection getNonBlockingWriteConnection()
public WCPDBConnection getWriteConnection()
public WCPDBConnection getWriteConnection(int connectionId, boolean mustWait)
connectionId
- An integer value which specifies the target connection idmustWait
- A boolean value which specifies whether it should wait till the required connection is available or not.public int getWriteConnectionId(WCPDBConnection connection)
connection
- WCPDBConnection object to by which the connection id should be fetchedpublic void putWriteConnection(WCPDBConnection connection) throws WCPDBConnectionException
connection
- WCPDBConnection object to put in the write connection poolWCPDBConnectionException
- if the input connection does not belongs to the connection-poolpublic static DBConnectionPool _createInstance(int dso, IManagedComponent parentComponent, java.lang.String name, java.lang.String description)
dso
- A pointer to a native XML tree containing configuration information for the Database Connections & poolparentComponent
- The parent managed component containing this connection pool. Can be null to indicate that the pool is not managed.name
- The name of this connection pool for representation in management tools. Can be null when the pool is not managed.description
- The description of this connection pool for representation in management tools. Can be null when the pool is not managed.public static DBConnectionPool getInstance(IManagedComponent parentComponent, java.lang.String name, java.lang.String description, int legacySource)
parentComponent
- the parent managed component.name
- Managed component name of the connection pool.description
- the description of the componentlegacySource
- For backward compatibility of old dso structureprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void initialize()
public static javax.sql.XADataSource _getXADataSource()
public static void _setXADataSource(javax.sql.XADataSource ds)
public void unsetXAConnection(WCPDBConnection connection)
public int getNumOfCachedReadConnections()
public int getNumOfCachedWriteConnections()
public int getMinimumReadConnections()
public int getMinimumWriteConnections()
public int getMaximumReadConnections()
public int getMaximumWriteConnections()
public int getQueryCacheSize()
public int getCursorCacheSize()
public int getDefaultCursorSize()
public int getNumberOfCachedQueries()
public int getNumberOfOpenCursors()
public int getQueryCacheRefreshInterval()
public int getCursorCacheRefreshInterval()
public int getConnectionPoolRefreshInterval()
public long getRequestThreshold()
public long getReconnectionInterval()
public int getReconnectionAttempts()
public java.lang.String getXmlEncode()
public void setQueryCacheSize(int size)
size
- An integer value which denotes the new size of query cachepublic void reset()
public void setCursorCacheSize(int size)
size
- An integer value which denotes the new size of query cachepublic void setDefaultCursorSize(int size)
size
- An integer value which denotes the default size of the cursorpublic void setQueryCacheRefreshInterval(int interval)
size
- An integer value which denotes the time interval in secondspublic void setCursorCacheRefreshInterval(int interval)
size
- An integer value which denotes the time interval in secondspublic void setConnectionPoolRefreshInterval(int interval)
size
- An integer value which denotes the time interval in secondspublic void setMinimumReadConnections(int newMinReadConnectionCount)
size
- An integer value which denotes the value for minimum read connections in the poolpublic void setMaximumReadConnections(int newMaxReadConnectionCount)
size
- An integer value which denotes the value for maximum read connections in the poolpublic void setMinimumWriteConnections(int newMinWriteConnectionCount)
size
- An integer value which denotes the value for minimum write connections in the poolpublic void setMaximumWriteConnections(int newMaxWriteConnectionCount)
size
- An integer value which denotes the value for maximum write connections in the poolpublic void setReconnectionInterval(long interval)
size
- An integer value which denotes the time interval in secondspublic void setReconnectionAttempts(int attempts)
size
- An integer value which denotes the number of trialspublic void setRequestThreshold(long limit)
size
- An integer value which denotes the threshold time in millisecondspublic boolean isConnectionLost()
public void setConnectionLost(boolean connectionLost)
connectionLost
- The connectionLost to set.public void setNumConnections(int newConnectionCount, boolean isReadConnectionCount)
public java.lang.String getDriver()
public void setLogger(CordysLogger logger)
logger
- public CordysLogger getLogger()
logger
- public void registerConnectionProblem(long monitorInterval)
monitorInterval
- determines in milliseconds the monitoring interval for reconnection to the database.
Any value less than 30000 is not accepted as reconnection is a heavy operation.public void addCustomProblemStatusEventListener(IProblemStatusEventListener problemStatusEventListener)
public void setConversionConfiguration(int configurationNode)
configurationNode
- The xml node representing the conversion configuration
If configuration laready exists, the new entries in the new configuration will be added to the old one.
If the tables mentioned in the new configuration already exists in the configuration, it will be over written.