public abstract class TdbConnectionPool
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
INFINITE_TIMEOUT
Value to pass to
acquire in order to block indefinitly
waiting for a session to become available. |
Modifier and Type | Method and Description |
---|---|
TdbPooledSession |
acquire()
Acquire a session from the pool -- the first time a session is acquired,
it will incur the cost of a full login to the server.
|
TdbPooledSession |
acquire(long timeout)
Acquire a session from the pool -- the first time a session is acquired,
it will incur the cost of a full login to the server.
|
void |
close()
Shuts down the session pool.
|
TdbActivityLogger |
getActivityLog()
Retrieve a reference to the activity logger currently in use
|
int |
getIdleTimeout()
Get/set number of seconds a session can remain idle in the pool without
being removed by the purge routine.
|
boolean |
getIsolateSessions()
Check if sessions in the pool are to be isolated.
|
int |
getLimit()
Returns the limit for the number of sessions that can be maintained
by this session pool.
|
int |
getMinIdle()
Get the minimum number of idle sessions that should remain in the
pool after a purge.
|
TdbPoolInitializer |
getPoolInitializer()
Returns the current pool initialization procedure for sessions in the pool.
|
int |
getPurgeInterval()
Get the purge interval.
|
int |
getRestoreDelay()
Get the number of milliseconds to wait between session attempts to
re-establish a broken session.
|
int |
getRestoreRetries()
Get the max number of retries for re-establising a broken session
(e.g. one that has lost connection to the server).
|
int |
getSize()
Returns the current size of the pool.
|
boolean |
isClosed()
Returns true if this connection pool has been closed.
|
void |
reserve(int reserve)
Establish a reserve of sessions within the pool.
|
void |
setActivityLog(TdbActivityLogger logger)
Set the activity logger reference for this pool.
|
void |
setIdleTimeout(int idleTimeout)
Set the number of seconds a session can remain idle in the pool without
being removed by the purge routine.
|
void |
setIsolateSessions(boolean isolate)
Determine if sessions in the pool are to be isolated.
|
void |
setLimit(int newLimit)
Set a limit to the number of sessions that can be maintained by
this session pool.
|
void |
setMinIdle(int minIdle)
Set the minimum number of idle sessions that should remain in the
pool after a purge.
|
void |
setPoolInitializer(TdbPoolInitializer initproc)
Assigns a pool initialization procedure for sessions in the pool.
|
void |
setPurgeInterval(int purgeInterval)
Set the purge interval.
|
void |
setRestoreDelay(int delay)
Set the number of milliseconds to wait between session attempts to
re-establish a broken session.
|
void |
setRestoreRetries(int retries)
Set the max number of retries for re-establising a broken session
(e.g. one that has lost connection to the server).
|
public static final long INFINITE_TIMEOUT
acquire
in order to block indefinitly
waiting for a session to become available.public TdbPooledSession acquire() throws TdbException
code
set to
UNUSABLE_SESSION
if there are no available idle sessions to return.TdbException
- If the pool is closed or a failure occurred reserve a session.public TdbPooledSession acquire(long timeout) throws TdbException
code
set to
UNUSABLE_SESSION
if there are no available idle sessions to return.timeout
- Timeout in milliseconds, or use INFINITE_TIMEOUT
to wait indefinitely.TdbException
- If the pool is closed or a failure occurred reserve a session.public void reserve(int reserve) throws TdbException
reserve
- Number of sessions to establishTdbException
public void close()
Shuts down the session pool.
Available sessions in the pool will be closed by this method. Any sessions still in use by the application are allowed to remain so, but will be closed upon their return to the pool. The application is responsible for returning sessions to the closed pool as soon as possible after calling this method.
public boolean isClosed()
Returns true if this connection pool has been closed.
A closed connection pool will not yield any sessions on calls to its Acquire() method. Any sessions still in use must be returned to the pool as soon as possible.
public void setPoolInitializer(TdbPoolInitializer initproc)
initproc
- Instance of class that implements the TdbPoolInitializer interface.public TdbPoolInitializer getPoolInitializer()
public void setLimit(int newLimit)
newLimit
- The new limit (pass 0 to remove the limit)public int getLimit()
public int getSize()
public int getRestoreRetries()
public void setRestoreRetries(int retries)
public int getRestoreDelay()
public void setRestoreDelay(int delay)
public boolean getIsolateSessions()
NOTE: When this property is false, the use of any other means than the TdbRecordSet class to search and retrieve (e.g. via the TdbCclCommand class) is NOT RECOMMENDED.
public void setIsolateSessions(boolean isolate)
The default value of this property is true. This means that anything that the application does in an acquired session is totally isolated from the next time it is acquired. Any search sets created are automatically deleted when the session is restored to the pool.
Setting this property to false will reduce the number of network transactions by two, which will have a positive performance impact in high-load scenarios.
NOTE: Setting this property to false is only recommended if the TdbRecordSet class is used to search and retrieve, and no other TRIPjxp functionality is used. When using the TdbRecordSet class there will still be a session isolation in effect, because the implementation of the record set on the server-side contains its own isolation mechanism. The use of any other means to search (e.g. via the TdbCclCommand) is NOT RECOMMENDED if this property is false.
public int getPurgeInterval()
TdbConnectionPool.setPurgeInterval(int)
,
TdbConnectionPool.setIdleTimeout(int)
,
TdbConnectionPool.setMinIdle(int)
,
TdbConnectionPool.getIdleTimeout()
,
TdbConnectionPool.getMinIdle()
public void setPurgeInterval(int purgeInterval)
By default, purging of idle sessions is disabled. To enable it, both this property and the IdleTimeout property must be set to positive values.
purgeInterval
- Interval in seconds for the purge routine to run.TdbConnectionPool.setIdleTimeout(int)
,
TdbConnectionPool.setMinIdle(int)
,
TdbConnectionPool.getPurgeInterval()
,
TdbConnectionPool.getIdleTimeout()
,
TdbConnectionPool.getMinIdle()
public int getIdleTimeout()
By default, purging of idle sessions is disabled. To enable it, both this property and the IdleTimeout property must be set to positive values.
TdbConnectionPool.setPurgeInterval(int)
,
TdbConnectionPool.setIdleTimeout(int)
,
TdbConnectionPool.setMinIdle(int)
,
TdbConnectionPool.getPurgeInterval()
,
TdbConnectionPool.getMinIdle()
public void setIdleTimeout(int idleTimeout)
idleTimeout
- New timeout in seconds for idle sessions in this pool.TdbConnectionPool.setPurgeInterval(int)
,
TdbConnectionPool.setMinIdle(int)
,
TdbConnectionPool.getPurgeInterval()
,
TdbConnectionPool.getIdleTimeout()
,
TdbConnectionPool.getMinIdle()
public int getMinIdle()
This property is used when purging idle sessions. The purge will allow up to MinIdle sessions to remain idle in the pool, even if they otherwise would be candidates for removal.
TdbConnectionPool.setPurgeInterval(int)
,
TdbConnectionPool.setIdleTimeout(int)
,
TdbConnectionPool.setMinIdle(int)
,
TdbConnectionPool.getPurgeInterval()
,
TdbConnectionPool.getIdleTimeout()
public void setMinIdle(int minIdle)
This property is used when purging idle sessions. The purge will allow up to MinIdle sessions to remain idle in the pool, even if they otherwise would be candidates for removal.
minIdle
- The minimum number of idle sessions that should remain in
the pool after a purge.TdbConnectionPool.setPurgeInterval(int)
,
TdbConnectionPool.setIdleTimeout(int)
,
TdbConnectionPool.getMinIdle()
,
TdbConnectionPool.getPurgeInterval()
,
TdbConnectionPool.getIdleTimeout()
public TdbActivityLogger getActivityLog()
public void setActivityLog(TdbActivityLogger logger)
Note that logging in a pool can be expensive from a performance point of view. However, it is useful for diagnosis of pool usage and size.
logger
- The activity logger to use; set this to null to remove any
pre-existing logger