com.caucho.env.dbpool
Class ConnectionPool

java.lang.Object
  extended by com.caucho.management.server.AbstractManagedObject
      extended by com.caucho.env.dbpool.ConnectionPool
All Implemented Interfaces:
ConnectionPoolMXBean, ManagedObjectMXBean, AlarmListener, java.io.Serializable, java.util.EventListener, ConnectionManager

@Module
public class ConnectionPool
extends AbstractManagedObject
implements ConnectionManager, AlarmListener, ConnectionPoolMXBean

Implementation of the connection manager.

See Also:
Serialized Form

Constructor Summary
ConnectionPool()
           
 
Method Summary
 java.lang.Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo info)
          Allocates the connection.
 boolean allowLocalTransactionOptimization()
          Returns true if the local transaction optimization is enabled
 void clear()
          Clears the idle connections in the pool.
 void destroy()
          Destroys the manager.
 ActiveTimeMeter getActiveTimeProbe()
          Returns the active time probe
 int getConnectionActiveCount()
          Returns the active connections.
 int getConnectionCount()
          Returns the total connections.
 long getConnectionCountTotal()
          Returns the total connections.
 int getConnectionCreateCount()
          Current number of connections being created.
 long getConnectionCreateCountTotal()
          Returns the total connections.
 long getConnectionFailCountTotal()
          Returns the total failed connections.
 int getConnectionIdleCount()
          Returns the idle connections.
 ActiveTimeMeter getConnectionTimeProbe()
          Returns the connection time probe
 long getConnectionWaitTime()
          Sets the time to wait for connections
 ActiveTimeMeter getIdleTimeProbe()
          Returns the idle time probe
 java.util.Date getLastFailTime()
          Returns the last fail time
 long getMaxActiveTime()
          Returns the max active time.
 int getMaxConnections()
          Gets the maximum number of connections
 int getMaxCreateConnections()
          Gets the maximum number of connections simultaneously creating
 int getMaxIdleCount()
          Returns the max idle count.
 long getMaxIdleTime()
          Returns the max idle time.
 int getMaxOverflowConnections()
          Gets the max number of overflow connections
 long getMaxPoolTime()
          Returns the max pool time.
 int getMinIdleCount()
          Returns the min idle count.
 java.lang.String getName()
          Gets the connection pool name.
 boolean getSaveAllocationStackTrace()
          Returns true if a stack trace should be shared on allocation
 UserTransactionProxy getTransactionManager()
          Returns the transaction manager.
 void handleAlarm(Alarm alarm)
          Alarm listener.
 java.lang.Object init(ManagedConnectionFactory mcf)
          Initialize the connection manager.
 boolean isCloseDanglingConnections()
          Returns true if dangling connections should be closed
 boolean isLocalTransaction()
          Set true for local transaction support.
 boolean isLocalTransactionOptimization()
          Returns true if the local transaction optimization is enabled
 boolean isShareable()
          Returns true if shared connections are allowed.
 boolean isXATransaction()
          Set true for XA transaction support.
 void markForPoolRemoval(ManagedConnection mConn)
           
 void setCloseDanglingConnections(boolean isClose)
          True if dangling connections should be closed.
 void setConnectionWaitTime(Period waitTime)
          Sets the time to wait for connections
 void setLocalTransaction(boolean localTransaction)
          Set true for local transaction support.
 void setLocalTransactionOptimization(boolean enable)
          Returns true if the local transaction optimization is enabled
 void setMaxActiveTime(long maxActiveTime)
          Sets the max active time.
 void setMaxConnections(int maxConnections)
          Sets the max number of connections
 void setMaxCreateConnections(int maxConnections)
          Sets the max number of connections simultaneously creating
 void setMaxIdleCount(int maxIdleCount)
          Sets the max idle count.
 void setMaxIdleTime(long maxIdleTime)
          Sets the max idle time.
 void setMaxOverflowConnections(int maxOverflowConnections)
          Sets the max number of overflow connections
 void setMaxPoolTime(long maxPoolTime)
          Sets the max pool time.
 void setMinIdleCount(int minIdleCount)
          Sets the max idle count.
 void setName(java.lang.String name)
          Sets the connection pool name.
 void setSaveAllocationStackTrace(boolean save)
          Returns true if a stack trace should be shared on allocation
 void setShareable(boolean isShareable)
          Returns true if shared connections are allowed.
 void setTransactionManager(UserTransactionProxy tm)
          Sets the transaction manager.
 void setXATransaction(boolean enable)
          Set true for XA transaction support.
 void start()
          start the connection manager.
 void stop()
          Stops the manager.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.management.server.AbstractManagedObject
addObjectNameProperties, getObjectName, getType, registerSelf, unregisterSelf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.caucho.management.server.ManagedObjectMXBean
getObjectName, getType
 

Constructor Detail

ConnectionPool

public ConnectionPool()
Method Detail

setName

public void setName(java.lang.String name)
Sets the connection pool name.


getName

public java.lang.String getName()
Gets the connection pool name.

Specified by:
getName in interface ManagedObjectMXBean
Specified by:
getName in class AbstractManagedObject

setTransactionManager

public void setTransactionManager(UserTransactionProxy tm)
Sets the transaction manager.


getTransactionManager

public UserTransactionProxy getTransactionManager()
Returns the transaction manager.


isShareable

public boolean isShareable()
Returns true if shared connections are allowed.

Specified by:
isShareable in interface ConnectionPoolMXBean

setShareable

public void setShareable(boolean isShareable)
Returns true if shared connections are allowed.


isLocalTransactionOptimization

public boolean isLocalTransactionOptimization()
Returns true if the local transaction optimization is enabled

Specified by:
isLocalTransactionOptimization in interface ConnectionPoolMXBean

setLocalTransactionOptimization

public void setLocalTransactionOptimization(boolean enable)
Returns true if the local transaction optimization is enabled


allowLocalTransactionOptimization

public boolean allowLocalTransactionOptimization()
Returns true if the local transaction optimization is enabled


getSaveAllocationStackTrace

public boolean getSaveAllocationStackTrace()
Returns true if a stack trace should be shared on allocation


setSaveAllocationStackTrace

public void setSaveAllocationStackTrace(boolean save)
Returns true if a stack trace should be shared on allocation


isCloseDanglingConnections

public boolean isCloseDanglingConnections()
Returns true if dangling connections should be closed


setCloseDanglingConnections

public void setCloseDanglingConnections(boolean isClose)
True if dangling connections should be closed.


setLocalTransaction

public void setLocalTransaction(boolean localTransaction)
Set true for local transaction support.


isLocalTransaction

public boolean isLocalTransaction()
Set true for local transaction support.


setXATransaction

public void setXATransaction(boolean enable)
Set true for XA transaction support.


isXATransaction

public boolean isXATransaction()
Set true for XA transaction support.


getMaxIdleTime

public long getMaxIdleTime()
Returns the max idle time.

Specified by:
getMaxIdleTime in interface ConnectionPoolMXBean

setMaxIdleTime

public void setMaxIdleTime(long maxIdleTime)
Sets the max idle time.


getMaxIdleCount

public int getMaxIdleCount()
Returns the max idle count.

Specified by:
getMaxIdleCount in interface ConnectionPoolMXBean

setMaxIdleCount

public void setMaxIdleCount(int maxIdleCount)
Sets the max idle count.


getMinIdleCount

public int getMinIdleCount()
Returns the min idle count.

Specified by:
getMinIdleCount in interface ConnectionPoolMXBean

setMinIdleCount

public void setMinIdleCount(int minIdleCount)
Sets the max idle count.


getMaxActiveTime

public long getMaxActiveTime()
Returns the max active time.

Specified by:
getMaxActiveTime in interface ConnectionPoolMXBean

setMaxActiveTime

public void setMaxActiveTime(long maxActiveTime)
Sets the max active time.


getMaxPoolTime

public long getMaxPoolTime()
Returns the max pool time.

Specified by:
getMaxPoolTime in interface ConnectionPoolMXBean

setMaxPoolTime

public void setMaxPoolTime(long maxPoolTime)
Sets the max pool time.


setMaxConnections

public void setMaxConnections(int maxConnections)
                       throws ConfigException
Sets the max number of connections

Throws:
ConfigException

getMaxConnections

public int getMaxConnections()
Gets the maximum number of connections

Specified by:
getMaxConnections in interface ConnectionPoolMXBean

setConnectionWaitTime

public void setConnectionWaitTime(Period waitTime)
Sets the time to wait for connections


getConnectionWaitTime

public long getConnectionWaitTime()
Sets the time to wait for connections

Specified by:
getConnectionWaitTime in interface ConnectionPoolMXBean

setMaxOverflowConnections

public void setMaxOverflowConnections(int maxOverflowConnections)
Sets the max number of overflow connections


getMaxOverflowConnections

public int getMaxOverflowConnections()
Gets the max number of overflow connections

Specified by:
getMaxOverflowConnections in interface ConnectionPoolMXBean

setMaxCreateConnections

public void setMaxCreateConnections(int maxConnections)
                             throws ConfigException
Sets the max number of connections simultaneously creating

Throws:
ConfigException

getMaxCreateConnections

public int getMaxCreateConnections()
Gets the maximum number of connections simultaneously creating

Specified by:
getMaxCreateConnections in interface ConnectionPoolMXBean

getConnectionTimeProbe

public ActiveTimeMeter getConnectionTimeProbe()
Returns the connection time probe


getIdleTimeProbe

public ActiveTimeMeter getIdleTimeProbe()
Returns the idle time probe


getActiveTimeProbe

public ActiveTimeMeter getActiveTimeProbe()
Returns the active time probe


getConnectionCount

public int getConnectionCount()
Returns the total connections.

Specified by:
getConnectionCount in interface ConnectionPoolMXBean

getConnectionIdleCount

public int getConnectionIdleCount()
Returns the idle connections.

Specified by:
getConnectionIdleCount in interface ConnectionPoolMXBean

getConnectionCreateCount

public int getConnectionCreateCount()
Current number of connections being created.

Specified by:
getConnectionCreateCount in interface ConnectionPoolMXBean

getConnectionActiveCount

public int getConnectionActiveCount()
Returns the active connections.

Specified by:
getConnectionActiveCount in interface ConnectionPoolMXBean

getConnectionCountTotal

public long getConnectionCountTotal()
Returns the total connections.

Specified by:
getConnectionCountTotal in interface ConnectionPoolMXBean

getConnectionCreateCountTotal

public long getConnectionCreateCountTotal()
Returns the total connections.

Specified by:
getConnectionCreateCountTotal in interface ConnectionPoolMXBean

getConnectionFailCountTotal

public long getConnectionFailCountTotal()
Returns the total failed connections.

Specified by:
getConnectionFailCountTotal in interface ConnectionPoolMXBean

getLastFailTime

public java.util.Date getLastFailTime()
Returns the last fail time

Specified by:
getLastFailTime in interface ConnectionPoolMXBean

init

public java.lang.Object init(ManagedConnectionFactory mcf)
                      throws ConfigException,
                             ResourceException
Initialize the connection manager.

Throws:
ConfigException
ResourceException

start

public void start()
start the connection manager.


allocateConnection

public java.lang.Object allocateConnection(ManagedConnectionFactory mcf,
                                           ConnectionRequestInfo info)
                                    throws ResourceException
Allocates the connection.

Specified by:
allocateConnection in interface ConnectionManager
Returns:
connection handle for driver specific connection.
Throws:
ResourceException

markForPoolRemoval

public void markForPoolRemoval(ManagedConnection mConn)

clear

public void clear()
Clears the idle connections in the pool.

Specified by:
clear in interface ConnectionPoolMXBean

handleAlarm

public void handleAlarm(Alarm alarm)
Alarm listener.

Specified by:
handleAlarm in interface AlarmListener

stop

public void stop()
Stops the manager.


destroy

public void destroy()
Destroys the manager.


toString

public java.lang.String toString()
Overrides:
toString in class AbstractManagedObject