tyrex.resource
Class PoolMetrics

java.lang.Object
  extended bytyrex.resource.PoolMetrics

public class PoolMetrics
extends java.lang.Object

Holds metrics associated with a connection pool.

This object records usage metrics for the connection pool, recording such information as the accumulated number of connections created and used, the average time a connection is used by the application or held in the pool, etc.

Version:
$Revision: 1.5 $
Author:
Assaf Arkin

Field Summary
protected  int _available
          The number of connections available in the pool (unused).
protected  int _total
          The total number of connections in the pool, both used and unused.
 
Constructor Summary
PoolMetrics()
           
 
Method Summary
 int getAvailable()
          Returns the number of connections available to the pool.
 int getCurrentUnused()
          Returns the current number of managed connection not in use.
 int getCurrentUsed()
          Returns the current number of managed connections in use.
 int getTotal()
          Returns the total number of connections in the pool.
 int getTotalCreated()
          Returns the number of managed connections created during the lifetime of this connector.
 int getTotalDiscarded()
          Returns the number of managed connections discarded.
 int getTotalErrors()
          Returns the number of managed connections discarded due to an error in the connection.
 int getTotalUsed()
          Returns the number of client connections used.
 float getUnusedAvgDuration()
          Returns the average duration for holding a connection in the pool.
 float getUsedAvgDuration()
          Return the average duration for using a connection.
protected  void recordCreated()
          Record a created managed connection.
protected  void recordDiscard()
          Record a discarded managed connection.
protected  void recordError()
          Record an error release of a managed connection.
protected  void recordUnusedDuration(int ms)
          Record the duration for holding a connection.
protected  void recordUsedDuration(int ms)
          Record the duration for using a connection.
 void reset()
          Called to reset this metrics object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_total

protected int _total
The total number of connections in the pool, both used and unused.


_available

protected int _available
The number of connections available in the pool (unused).

Constructor Detail

PoolMetrics

public PoolMetrics()
Method Detail

getTotalCreated

public int getTotalCreated()
Returns the number of managed connections created during the lifetime of this connector. This value is incremented once for each managed connection created, but is not affected by the number of client connections obtained from that managed connection.

Returns:
The number of managed connections created

getTotalUsed

public int getTotalUsed()
Returns the number of client connections used. This value is incremented once for each client connection returned to the application.

The ratio getAccumUsed / #getAccumCreated represents how many client connections are obtained from each managed connections.

Returns:
The number of client connections used

getTotalDiscarded

public int getTotalDiscarded()
Returns the number of managed connections discarded. This value is incremented each time a managed connection is discarded from the pool after a period of inactivity, but is not affected by the application releasing a client connection to the pool.

Returns:
The number of managed connections discarded

getTotalErrors

public int getTotalErrors()
Returns the number of managed connections discarded due to an error in the connection.

Returns:
The number of erroneous connections

getCurrentUsed

public int getCurrentUsed()
Returns the current number of managed connections in use. This represents the number of connections in the pool that are currently used by the application.

Returns:
The current number of managed connections in use

getCurrentUnused

public int getCurrentUnused()
Returns the current number of managed connection not in use. This represents the number of connections in the pool that are available to application. Together with getCurrentUsed it represents the total number of connections currently managed by the pool.

Returns:
The current number of unused managed connections

getUsedAvgDuration

public float getUsedAvgDuration()
Return the average duration for using a connection. Returns the average number of seconds connections are used by the application.

Returns:
The average duration for using a connection

getUnusedAvgDuration

public float getUnusedAvgDuration()
Returns the average duration for holding a connection in the pool. Returns the average number of seconds connections are retained in the pool when they are not used by the application.

Returns:
The average duration for holding an unused connection

getTotal

public int getTotal()
Returns the total number of connections in the pool. The total number includes both used and available connections.

Returns:
The total number of connections in the pool

getAvailable

public int getAvailable()
Returns the number of connections available to the pool.

Returns:
The number of available connections

reset

public void reset()
Called to reset this metrics object.


recordCreated

protected void recordCreated()
Record a created managed connection.


recordDiscard

protected void recordDiscard()
Record a discarded managed connection.


recordError

protected void recordError()
Record an error release of a managed connection.


recordUsedDuration

protected void recordUsedDuration(int ms)
Record the duration for using a connection.

Parameters:
ms - The duration is milliseconds

recordUnusedDuration

protected void recordUnusedDuration(int ms)
Record the duration for holding a connection.

Parameters:
ms - The duration is milliseconds


Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.