tyrex.resource

Class PoolMetrics

public class PoolMetrics extends 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.
Method Summary
intgetAvailable()
Returns the number of connections available to the pool.
intgetCurrentUnused()
Returns the current number of managed connection not in use.
intgetCurrentUsed()
Returns the current number of managed connections in use.
intgetTotal()
Returns the total number of connections in the pool.
intgetTotalCreated()
Returns the number of managed connections created during the lifetime of this connector.
intgetTotalDiscarded()
Returns the number of managed connections discarded.
intgetTotalErrors()
Returns the number of managed connections discarded due to an error in the connection.
intgetTotalUsed()
Returns the number of client connections used.
floatgetUnusedAvgDuration()
Returns the average duration for holding a connection in the pool.
floatgetUsedAvgDuration()
Return the average duration for using a connection.
protected voidrecordCreated()
Record a created managed connection.
protected voidrecordDiscard()
Record a discarded managed connection.
protected voidrecordError()
Record an error release of a managed connection.
protected voidrecordUnusedDuration(int ms)
Record the duration for holding a connection.
protected voidrecordUsedDuration(int ms)
Record the duration for using a connection.
voidreset()
Called to reset this metrics object.

Field Detail

_available

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

_total

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

Method Detail

getAvailable

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

Returns: The number of available connections

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

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

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

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

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

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 #getAccumCreated represents how many client connections are obtained from each managed connections.

Returns: The number of client connections used

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

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

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.

recordUnusedDuration

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

Parameters: ms The duration is milliseconds

recordUsedDuration

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

Parameters: ms The duration is milliseconds

reset

public void reset()
Called to reset this metrics object.
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.