com.rocketsoftware.mvapi.pool
Class MVConnectionPool

java.lang.Object
  extended by com.rdta.util.npool.BaseObjectPool
      extended by com.rocketsoftware.mvapi.pool.MVConnectionPool
All Implemented Interfaces:
com.rdta.util.npool.Pool, com.rdta.util.npool.PoolLoggingContext

public class MVConnectionPool
extends com.rdta.util.npool.BaseObjectPool
implements com.rdta.util.npool.PoolLoggingContext

Provides a pool for the MVConnection objects connected to a MVSP server.

Note: In addition to the mvapi.jar being in the CLASSPATH, the utility.jar must be added as well.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.rdta.util.npool.Pool
com.rdta.util.npool.Pool.Listener
 
Field Summary
static int RELEASE_REQUESTS_MAX_WAIT_TIME
          Maximum wait time when releasing connect request waiters
static int RELEASE_REQUESTS_SLEEP_TIME
          Sleep time when releasing connect request waiters
 
Constructor Summary
MVConnectionPool()
          Default constructor.
 
Method Summary
 MVConnection acquire()
          Acquire/get a connection.
 void checkin(java.lang.Object object)
          Checks in an object into the pool.
 java.lang.Object checkout(com.rdta.util.npool.BaseObjectPoolState checkOutState)
          Checks out an object from the pool.
 void checkout(int count, java.util.Collection bundle)
          Checks out the specified count of objects from the pool and add the objects to the collection.
 void clearStats()
          Clear connection pool statistics
 void closePool()
          Closes connection pool and closes all connections to server.
 java.lang.String getConnectInfo()
          Returns the connection information for checked in and checked out entries in connection pool
 MVConnection getConnection()
          Gets connection from pool or creates connection to server and stores it in pool.
 void getStats(MVConnectionPoolStats mvConnectionPoolStats)
          Get connection pool statistics
 boolean isConnectionAvailable()
          Determines if the connection is available.
 boolean isConnectionPoolingSupported()
          Determines if the server supports connection pooling.
 void logException(java.lang.Object sourceObject, java.lang.Exception exception)
           
 void logInfo(java.lang.Object sourceObject, java.lang.String message)
           
 void markUnavailable()
          Mark the connection unavailable.
 void openPool(java.lang.String host, int port, java.lang.String user, java.lang.String pwd, java.lang.String account, java.lang.String accountPwd, boolean sslConnect, int minCapacity, int maxCapacity)
          Opens connection pool and validates and stores parameters used to connect to server.
 void openPool(java.lang.String urlConnection, java.util.Properties connProperties, int minCapacity, int maxCapacity, int inactivityTimeout)
          Opens the connection pool.
 void release(MVConnection mvConnection)
          Release a connection.
 void releaseAllConnections()
          Release all connections.
 void releaseConnection(MVConnection mvConnection)
          Release a connection.
 void setMaximumCapacity(int maximumCapacity)
          Sets the maximum capacity or upper limit of the managed pool.
 void setMinimumCapacity(int minimumCapacity)
          Sets the minimum capacity or lower limit setting of the managed pool.
 
Methods inherited from class com.rdta.util.npool.BaseObjectPool
add, adjustMaximumCapacity, appendState, checkin, checkout, close, closeall, flush, getCheckedInCount, getCheckedOutCount, getMaximumCapacity, getMaximumContentIdleTime, getMaximumThreadWaitTime, getMinimumCapacity, getPoolFactory, getPoolKey, getTotalCount, isAtLicenseLimitCapacity, isAtMaximumCapacity, isAtMinimumCapacity, isAutoGrowToMinimum, isClosed, isExternalNotify, isLimitable, isObjectAvailable, isReducedToMinimum, remove, resize, setMaximumContentIdleTime, setMaximumThreadWaitTime, setPoolFactory, setPoolKey, setPoolLoggingContext, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RELEASE_REQUESTS_MAX_WAIT_TIME

public static final int RELEASE_REQUESTS_MAX_WAIT_TIME
Maximum wait time when releasing connect request waiters

See Also:
Constant Field Values

RELEASE_REQUESTS_SLEEP_TIME

public static final int RELEASE_REQUESTS_SLEEP_TIME
Sleep time when releasing connect request waiters

See Also:
Constant Field Values
Constructor Detail

MVConnectionPool

public MVConnectionPool()
Default constructor.

Method Detail

getConnectInfo

public java.lang.String getConnectInfo()
Returns the connection information for checked in and checked out entries in connection pool

Returns:
String The connection pool information (server port and checked out flag) for entries in connection pool

openPool

public void openPool(java.lang.String urlConnection,
                     java.util.Properties connProperties,
                     int minCapacity,
                     int maxCapacity,
                     int inactivityTimeout)
              throws com.rdta.error.PoolException
Opens the connection pool.

Parameters:
urlConnection - The url to establish the connection
connProperties - connection properties
minCapacity - minimum connections in the pool
maxCapacity - maximum connections allowed in the pool
Throws:
com.rdta.error.PoolException - if any errors occur while opening the pool.

openPool

public void openPool(java.lang.String host,
                     int port,
                     java.lang.String user,
                     java.lang.String pwd,
                     java.lang.String account,
                     java.lang.String accountPwd,
                     boolean sslConnect,
                     int minCapacity,
                     int maxCapacity)
              throws com.rdta.error.PoolException
Opens connection pool and validates and stores parameters used to connect to server.

Parameters:
host - hostname to connect
port - port number
user - user name
pwd - user password
account - default account
accountPwd - default account password
sslConnect - true if using an SSL connection
minCapacity - minimum capacity of connection pool
maxCapacity - maximum capacity of connection pool
Throws:
com.rdta.error.PoolException - if any errors occur

closePool

public void closePool()
               throws com.rdta.error.PoolException
Closes connection pool and closes all connections to server.

Throws:
com.rdta.error.PoolException - if any errors occur

isConnectionAvailable

public boolean isConnectionAvailable()
Determines if the connection is available.

Returns:
boolean true if the connection is available

markUnavailable

public void markUnavailable()
Mark the connection unavailable.


setMinimumCapacity

public void setMinimumCapacity(int minimumCapacity)
Sets the minimum capacity or lower limit setting of the managed pool. The pool will use the value to define the minimum number of objects that must exist within the pool at all times. If the minimum value is greater than the maximum capacity, then the maximum capacity will adjust to equal the minimum value.

Specified by:
setMinimumCapacity in interface com.rdta.util.npool.Pool
Overrides:
setMinimumCapacity in class com.rdta.util.npool.BaseObjectPool
Parameters:
minimumCapacity - The value to use.

setMaximumCapacity

public void setMaximumCapacity(int maximumCapacity)
Sets the maximum capacity or upper limit of the managed pool. If the value is less than the minimum capacity then the minimum capacity will be set equal to this value. The maximum value is used on checkout, a thread will block if the pool has reached this capacity. This method will expire objects once the maximum capacity is known. A maximum capacity of 0 causes the pool to be disabled.

Specified by:
setMaximumCapacity in interface com.rdta.util.npool.Pool
Overrides:
setMaximumCapacity in class com.rdta.util.npool.BaseObjectPool
Parameters:
maximumCapacity - The maximum capacity

isConnectionPoolingSupported

public boolean isConnectionPoolingSupported()
Determines if the server supports connection pooling.

Returns:
boolean true if the server supports connection pooling

acquire

public MVConnection acquire()
                     throws com.rdta.error.PoolException
Acquire/get a connection. Added for compatibility for MV adapter

Returns:
MVConnection
Throws:
com.rdta.error.PoolException

getConnection

public MVConnection getConnection()
                           throws com.rdta.error.PoolException
Gets connection from pool or creates connection to server and stores it in pool. If the connection pool is disabled (maximum capacity = 0) or the server doesn't support connection pooling, then it gets a user licensed connection and doesn't use the pool.

Returns:
MVConnection The connection received from pool or created to server
Throws:
com.rdta.error.PoolException - if any errors occur

checkout

public java.lang.Object checkout(com.rdta.util.npool.BaseObjectPoolState checkOutState)
                          throws com.rdta.error.PoolException
Checks out an object from the pool. It is guaranteed that the pool will always return an object on a return.

Overrides:
checkout in class com.rdta.util.npool.BaseObjectPool
Parameters:
checkOutState - An object for getting checkout state.
Returns:
A object. Should never be null.
Throws:
com.rdta.error.PoolException - Thrown if a general application level exception occurs.

checkout

public void checkout(int count,
                     java.util.Collection bundle)
              throws com.rdta.error.PoolException
Checks out the specified count of objects from the pool and add the objects to the collection.

Overrides:
checkout in class com.rdta.util.npool.BaseObjectPool
Parameters:
count - An integer of the number of objects check out from pool.
bundle - A returned collection of objects that get checked out from pool.
Throws:
com.rdta.error.PoolException - Thrown if a general application level exception occurs.

release

public void release(MVConnection mvConnection)
             throws com.rdta.error.PoolException
Release a connection. If a user licensed connection is being released from the pool being disabled (maximum capacity = 0), then the connection is closed on the server and not returned to the connection pool.

Parameters:
mvConnection - The connection to release.
Throws:
com.rdta.error.PoolException - if any errors occur

releaseConnection

public void releaseConnection(MVConnection mvConnection)
                       throws com.rdta.error.PoolException
Release a connection. If a user licensed connection is being released from the pool being disabled (maximum capacity = 0), then the connection is closed on the server and not returned to the connection pool.

Parameters:
mvConnection - The connection to release.
Throws:
com.rdta.error.PoolException - if any errors occur

releaseAllConnections

public void releaseAllConnections()
                           throws com.rdta.error.PoolException
Release all connections. If a user licensed connection is being released from the pool being disabled (maximum capacity = 0), then the connection is closed on the server and not returned to the connection pool.

Throws:
com.rdta.error.PoolException - if any errors occur

checkin

public void checkin(java.lang.Object object)
             throws com.rdta.error.PoolException
Checks in an object into the pool. If the object is not a pooled, then release the connection.

Specified by:
checkin in interface com.rdta.util.npool.Pool
Overrides:
checkin in class com.rdta.util.npool.BaseObjectPool
Parameters:
object - An object to be released and if pooled, checked into the pool.
Throws:
com.rdta.error.PoolException - Thrown if a general application level exception occurs.

clearStats

public void clearStats()
Clear connection pool statistics


getStats

public void getStats(MVConnectionPoolStats mvConnectionPoolStats)
Get connection pool statistics

Parameters:
mvConnectionPoolStats - Object containing connection pool statistics

logInfo

public void logInfo(java.lang.Object sourceObject,
                    java.lang.String message)
Specified by:
logInfo in interface com.rdta.util.npool.PoolLoggingContext

logException

public void logException(java.lang.Object sourceObject,
                         java.lang.Exception exception)
Specified by:
logException in interface com.rdta.util.npool.PoolLoggingContext