org.objectweb.jonas.resource.pool.lib
Class HArrayPool

java.lang.Object
  extended by org.objectweb.jonas.resource.pool.lib.HArrayPool
All Implemented Interfaces:
Pool

public class HArrayPool
extends java.lang.Object
implements Pool

The class HArrayPool implements a Pool as a HashSet of ManagedConnections, managing free/active resources. Updated to use an LRU list of free resources Author: Eric HARDESTY


Constructor Summary
HArrayPool(org.objectweb.util.monolog.api.Logger logger, java.lang.String jndiname)
          HArrayPool constructor
 
Method Summary
 void adjust()
          Adjust the pool size, according to poolMax and minSize values.
 void closeAllConnections()
          Close all connections in the pool when server is shutting down.
 int getBusyMaxRecent()
           
 int getBusyMinRecent()
           
 int getConnectionFailures()
           
 int getConnectionLeaks()
           
 int getCurrentBusy()
           
 int getCurrentOpened()
           
 int getCurrentWaiters()
           
 int getInitSize()
           
 int getJdbcConnLevel()
          getJdbcConnLevel gets the jdbc connection level
 java.lang.String getJdbcTestStatement()
          getJdbcTestStatement gets the JDBC test statement for this pool
 PoolMatchFactory getMatchFactory()
          getMatchFactory retrieves the PoolMatchFactory assigned to this Pool.
 int getMaxAge()
          getMaxAge gets the max age for a pool entry
 int getMaxOpentime()
          getMaxOpentime gets the max age for a pool entry
 int getMaxSize()
          getMaxSize retrieves the maximum size assigned to this Pool.
 int getMaxWaiters()
          getMaxWaiters gets the maximum number of waiters for a connection in this Pool.
 int getMaxWaitTime()
          getMaxWaitTime gets the maximum number of seconds to wait for a connection in this Pool.
 int getMinSize()
          getMinSize retrieves the minimum size assigned to this Pool.
 int getOpenedCount()
           
 int getRejectedFull()
           
 int getRejectedOpen()
           
 int getRejectedOther()
           
 int getRejectedTimeout()
           
 java.lang.Object getResource(java.lang.Object hints)
          getResource is used to allocate a Object from the Pool.
 java.lang.Object getResource(java.lang.Object hints, boolean freeListOnly)
           
 int getSamplingPeriod()
          getSamplingPeriod gets the number of seconds between statistics sampling for this Pool.
 int getServedOpen()
           
 int getSize()
          Get the size of the pool
 long getTimeout()
          getTimeout retrieves the timeout assigned to this Pool.
 int getWaiterCount()
           
 int getWaitersHigh()
           
 int getWaitersHighRecent()
           
 long getWaitingHigh()
           
 long getWaitingHighRecent()
           
 long getWaitingTime()
           
 void recomputeBusy()
          compute current min/max busyConnections
 void releaseResource(java.lang.Object resource, boolean destroy, boolean adjustment)
          releaseResource releases a Object in order to allow the Pool to recycle this Object.
 void sampling()
          sampling updates the interval pool information
 void setInitSize(int initsize)
          setInitSize creates initsize resoures to this Pool.
 void setJdbcConnLevel(int jdbcConnLevel)
          setJdbcConnLevel sets the JDBC connection level for this pool
 void setJdbcTestStatement(java.lang.String jdbcTestStatement)
          setJdbcTestStatement sets the JDBC test statement for this pool
 void setMatchFactory(PoolMatchFactory pmf)
          setMatchFactory assigns a PoolMatchFactory to this Pool.
 void setMaxAge(int maxAge)
          setMaxAge sets the max age for a pool entry
 void setMaxOpentime(int mx)
          setMaxOpentime sets the max age for an entry to be opened
 void setMaxSize(int maxsize)
          setMaxSize assigns a maximum size to this Pool.
 void setMaxWaiters(int nb)
          setMaxWaiters sets the maximum number of waiters for a connection in this Pool.
 void setMaxWaitTime(int sec)
          setMaxWaitTime sets the maximum number of seconds to wait for a connection in this Pool.
 void setMinSize(int minsize)
          setMinSize assigns a minimum size to this Pool.
 void setSamplingPeriod(int sec)
          setSamplingPeriod sets the number of seconds between statistics sampling for this Pool.
 void setTimeout(long crto)
          setTimeout assigns a timeout to this Pool.
 void startMonitor()
          startMonitor starts the pool monitor for this Pool.
 void validateMCs()
          validateMCs validates ManagedConnections in Pool every 10 minutes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HArrayPool

public HArrayPool(org.objectweb.util.monolog.api.Logger logger,
                  java.lang.String jndiname)
HArrayPool constructor

Parameters:
logger - Logger for the pool to use
Method Detail

getCurrentBusy

public int getCurrentBusy()
Specified by:
getCurrentBusy in interface Pool
Returns:
int number of busy connections

getCurrentOpened

public int getCurrentOpened()
Specified by:
getCurrentOpened in interface Pool
Returns:
int number of opened connections

getInitSize

public int getInitSize()
Specified by:
getInitSize in interface Pool
Returns:
init The pool init size.
See Also:
Pool.getInitSize()

setInitSize

public void setInitSize(int initsize)
                 throws java.lang.Exception
Description copied from interface: Pool
setInitSize creates initsize resoures to this Pool.

Specified by:
setInitSize in interface Pool
Parameters:
initsize - The init size to be created.
Throws:
java.lang.Exception - if an error occurs
See Also:
Pool.setInitSize(int)

getJdbcConnLevel

public int getJdbcConnLevel()
Description copied from interface: Pool
getJdbcConnLevel gets the jdbc connection level

Specified by:
getJdbcConnLevel in interface Pool
Returns:
int jdbc connection level specified
See Also:
Pool.getJdbcConnLevel()

setJdbcConnLevel

public void setJdbcConnLevel(int jdbcConnLevel)
Description copied from interface: Pool
setJdbcConnLevel sets the JDBC connection level for this pool

Specified by:
setJdbcConnLevel in interface Pool
Parameters:
jdbcConnLevel - int JDBC connection level
See Also:
Pool.setJdbcConnLevel(int)

getJdbcTestStatement

public java.lang.String getJdbcTestStatement()
Description copied from interface: Pool
getJdbcTestStatement gets the JDBC test statement for this pool

Specified by:
getJdbcTestStatement in interface Pool
Returns:
String JDBC test statement
See Also:
Pool.getJdbcTestStatement()

setJdbcTestStatement

public void setJdbcTestStatement(java.lang.String jdbcTestStatement)
Description copied from interface: Pool
setJdbcTestStatement sets the JDBC test statement for this pool

Specified by:
setJdbcTestStatement in interface Pool
Parameters:
jdbcTestStatement - String JDBC test statement
See Also:
Pool.setJdbcTestStatement(java.lang.String)

getMaxAge

public int getMaxAge()
Description copied from interface: Pool
getMaxAge gets the max age for a pool entry

Specified by:
getMaxAge in interface Pool
Returns:
int max number of minutes to keep a connection in the pool.
See Also:
Pool.getMaxAge()

setMaxAge

public void setMaxAge(int maxAge)
Description copied from interface: Pool
setMaxAge sets the max age for a pool entry

Specified by:
setMaxAge in interface Pool
Parameters:
maxAge - int max number of minutes to keep a connection in the pool.
See Also:
Pool.setMaxAge(int)

getMaxOpentime

public int getMaxOpentime()
Description copied from interface: Pool
getMaxOpentime gets the max age for a pool entry

Specified by:
getMaxOpentime in interface Pool
Returns:
max age for connections (in mns)

setMaxOpentime

public void setMaxOpentime(int mx)
Description copied from interface: Pool
setMaxOpentime sets the max age for an entry to be opened

Specified by:
setMaxOpentime in interface Pool
Parameters:
mx - max time of open connection in minutes

getMaxSize

public int getMaxSize()
Description copied from interface: Pool
getMaxSize retrieves the maximum size assigned to this Pool.

Specified by:
getMaxSize in interface Pool
Returns:
The maximum size currently assigned to this Pool.
See Also:
Pool.getMaxSize()

setMaxSize

public void setMaxSize(int maxsize)
                throws java.lang.Exception
Description copied from interface: Pool
setMaxSize assigns a maximum size to this Pool.

Specified by:
setMaxSize in interface Pool
Parameters:
maxsize - int maximum size to be assigned.
Throws:
java.lang.Exception - if an error occurs
See Also:
Pool.setMaxSize(int)

getMaxWaiters

public int getMaxWaiters()
Description copied from interface: Pool
getMaxWaiters gets the maximum number of waiters for a connection in this Pool.

Specified by:
getMaxWaiters in interface Pool
Returns:
max nb of waiters

setMaxWaiters

public void setMaxWaiters(int nb)
Description copied from interface: Pool
setMaxWaiters sets the maximum number of waiters for a connection in this Pool.

Specified by:
setMaxWaiters in interface Pool
Parameters:
nb - max nb of waiters

getMaxWaitTime

public int getMaxWaitTime()
Description copied from interface: Pool
getMaxWaitTime gets the maximum number of seconds to wait for a connection in this Pool.

Specified by:
getMaxWaitTime in interface Pool
Returns:
waiter timeout in seconds

setMaxWaitTime

public void setMaxWaitTime(int sec)
Description copied from interface: Pool
setMaxWaitTime sets the maximum number of seconds to wait for a connection in this Pool.

Specified by:
setMaxWaitTime in interface Pool
Parameters:
sec - max time to wait for a connection, in seconds

getMinSize

public int getMinSize()
Description copied from interface: Pool
getMinSize retrieves the minimum size assigned to this Pool.

Specified by:
getMinSize in interface Pool
Returns:
The minimum size currently assigned to this Pool.
See Also:
Pool.getMinSize()

setMinSize

public void setMinSize(int minsize)
                throws java.lang.Exception
Description copied from interface: Pool
setMinSize assigns a minimum size to this Pool.

Specified by:
setMinSize in interface Pool
Parameters:
minsize - int minimum size to be assigned.
Throws:
java.lang.Exception - if an error occurs
See Also:
Pool.setMinSize(int)

getSamplingPeriod

public int getSamplingPeriod()
Description copied from interface: Pool
getSamplingPeriod gets the number of seconds between statistics sampling for this Pool.

Specified by:
getSamplingPeriod in interface Pool
Returns:
sampling period in sec.

setSamplingPeriod

public void setSamplingPeriod(int sec)
Description copied from interface: Pool
setSamplingPeriod sets the number of seconds between statistics sampling for this Pool.

Specified by:
setSamplingPeriod in interface Pool
Parameters:
sec - sampling period in sec.

getSize

public int getSize()
Get the size of the pool

Specified by:
getSize in interface Pool
Returns:
int size of the pool

getTimeout

public long getTimeout()
Description copied from interface: Pool
getTimeout retrieves the timeout assigned to this Pool.

Specified by:
getTimeout in interface Pool
Returns:
The timeout currently assigned to this Pool.
See Also:
Pool.getTimeout()

setTimeout

public void setTimeout(long crto)
Description copied from interface: Pool
setTimeout assigns a timeout to this Pool.

Specified by:
setTimeout in interface Pool
Parameters:
crto - long timeout to be assigned.
See Also:
Pool.setTimeout(long)

getBusyMaxRecent

public int getBusyMaxRecent()
Specified by:
getBusyMaxRecent in interface Pool
Returns:
maximum nb of busy connections in last sampling period

getBusyMinRecent

public int getBusyMinRecent()
Specified by:
getBusyMinRecent in interface Pool
Returns:
minimum nb of busy connections in last sampling period

getCurrentWaiters

public int getCurrentWaiters()
Specified by:
getCurrentWaiters in interface Pool
Returns:
current number of connection waiters

getOpenedCount

public int getOpenedCount()
Specified by:
getOpenedCount in interface Pool
Returns:
int number of physical jdbc connection opened

getConnectionFailures

public int getConnectionFailures()
Specified by:
getConnectionFailures in interface Pool
Returns:
int number of connection failures on open

getConnectionLeaks

public int getConnectionLeaks()
Specified by:
getConnectionLeaks in interface Pool
Returns:
int number of connection leaks

getServedOpen

public int getServedOpen()
Specified by:
getServedOpen in interface Pool
Returns:
int number of connection served

getRejectedFull

public int getRejectedFull()
Specified by:
getRejectedFull in interface Pool
Returns:
int number of open calls that were rejected due to waiter overflow

getRejectedTimeout

public int getRejectedTimeout()
Specified by:
getRejectedTimeout in interface Pool
Returns:
int number of open calls that were rejected by timeout

getRejectedOther

public int getRejectedOther()
Specified by:
getRejectedOther in interface Pool
Returns:
int number of open calls that were rejected

getRejectedOpen

public int getRejectedOpen()
Specified by:
getRejectedOpen in interface Pool
Returns:
int number of open calls that were rejected

getWaitersHigh

public int getWaitersHigh()
Specified by:
getWaitersHigh in interface Pool
Returns:
maximum nb of waiters since the datasource creation

getWaitersHighRecent

public int getWaitersHighRecent()
Specified by:
getWaitersHighRecent in interface Pool
Returns:
maximum nb of waiters in last sampling period

getWaiterCount

public int getWaiterCount()
Specified by:
getWaiterCount in interface Pool
Returns:
total nb of waiters since the datasource creation

getWaitingTime

public long getWaitingTime()
Specified by:
getWaitingTime in interface Pool
Returns:
total waiting time since the datasource creation

getWaitingHigh

public long getWaitingHigh()
Specified by:
getWaitingHigh in interface Pool
Returns:
max waiting time since the datasource creation

getWaitingHighRecent

public long getWaitingHighRecent()
Specified by:
getWaitingHighRecent in interface Pool
Returns:
max waiting time in last sampling period

getResource

public java.lang.Object getResource(java.lang.Object hints)
                             throws java.lang.Exception
Description copied from interface: Pool
getResource is used to allocate a Object from the Pool. Some hints are passed in order to specialise the matching or creation of Object.

Specified by:
getResource in interface Pool
Parameters:
hints - Some properties to specialise the matching or the creation of Object.
Returns:
The Object allocated from the Pool.
Throws:
java.lang.Exception - if an error occurs
See Also:
Pool.getResource(java.lang.Object)

getResource

public java.lang.Object getResource(java.lang.Object hints,
                                    boolean freeListOnly)
                             throws java.lang.Exception
Throws:
java.lang.Exception

releaseResource

public void releaseResource(java.lang.Object resource,
                            boolean destroy,
                            boolean adjustment)
                     throws java.lang.Exception
Description copied from interface: Pool
releaseResource releases a Object in order to allow the Pool to recycle this Object.

Specified by:
releaseResource in interface Pool
Parameters:
resource - The Object to be released.
destroy - boolean to remove the object from the pool and destroy it
adjustment - boolean to determine if a pool adjustment should be done
Throws:
java.lang.Exception - if an error occurs
See Also:
Pool.releaseResource(java.lang.Object, boolean, boolean)

closeAllConnections

public void closeAllConnections()
Close all connections in the pool when server is shutting down.

Specified by:
closeAllConnections in interface Pool

getMatchFactory

public PoolMatchFactory getMatchFactory()
Description copied from interface: Pool
getMatchFactory retrieves the PoolMatchFactory assigned to this Pool.

Specified by:
getMatchFactory in interface Pool
Returns:
The PoolMatchFactory currently assigned to this Pool.
See Also:
Pool.getMatchFactory()

setMatchFactory

public void setMatchFactory(PoolMatchFactory pmf)
Description copied from interface: Pool
setMatchFactory assigns a PoolMatchFactory to this Pool.

Specified by:
setMatchFactory in interface Pool
Parameters:
pmf - The PoolMatchFactory to be assigned.
See Also:
Pool.setMatchFactory(org.objectweb.jonas.resource.pool.api.PoolMatchFactory)

startMonitor

public void startMonitor()
Description copied from interface: Pool
startMonitor starts the pool monitor for this Pool.

Specified by:
startMonitor in interface Pool
See Also:
Pool.startMonitor()

validateMCs

public void validateMCs()
                 throws java.lang.Exception
Description copied from interface: Pool
validateMCs validates ManagedConnections in Pool every 10 minutes

Specified by:
validateMCs in interface Pool
Throws:
java.lang.Exception - if an error occurs
See Also:
Pool.validateMCs()

adjust

public void adjust()
            throws java.lang.Exception
Adjust the pool size, according to poolMax and minSize values. Also remove old connections in the freeList.

Specified by:
adjust in interface Pool
Throws:
java.lang.Exception - if an exception occurs

recomputeBusy

public void recomputeBusy()
compute current min/max busyConnections


sampling

public void sampling()
              throws java.lang.Exception
Description copied from interface: Pool
sampling updates the interval pool information

Specified by:
sampling in interface Pool
Throws:
java.lang.Exception - if an error occurs
See Also:
Pool.sampling()