org.objectweb.cjdbc.common.util
Class Stats

java.lang.Object
  extended byorg.objectweb.cjdbc.common.util.Stats

public class Stats
extends java.lang.Object

This class provides thread-safe statistics. Each statistic entry is composed as follow:

Version:
1.0
Author:
Emmanuel Cecchet , Julie Marguerite

Field Summary
private  int cacheHit
          Cache hits counter
private  int count
          Statistic counter
private  int error
          Statistic error counter
private  long maxTime
          Maximum time for this entry (automatically computed)
private  long minTime
          Minimum time for this entry (automatically computed)
private  java.lang.String name
          Name of the stats.
private  long totalTime
          Total time for this entry
 
Constructor Summary
Stats(java.lang.String statName)
          Creates a new Stats instance.
 
Method Summary
 void displayOnStdout()
          Displays the statistics on the standard output.
 int getCacheHit()
          Gets current cache hit count of an entry
 int getCount()
          Gets current count of an entry.
 int getError()
          Gets current error count of an entry
 long getMaxTime()
          Gets the maximum time of an entry
 long getMinTime()
          Gets the minimum time of an entry
 java.lang.String getName()
          Gets the name of the current stat.
 long getTotalTime()
          Gets the total time of an entry
 void incrementCacheHit()
          Increments an entry cache hit by one.
 void incrementCount()
          Increments an entry count by one.
 void incrementError()
          Increments an entry error by one.
 void merge(Stats anotherStat)
          Adds the entries of another Stats object to this one.
 java.lang.String multipleLineDisplay()
          Displays the statistics information on multiple lines.
 void reset()
          Resets all entries to 0.
 java.lang.String singleLineDisplay()
          Displays the statistics information on a single line in the format: name count error cacheHit %hit minTime maxTime avgTime totalTime
 java.lang.String[] toStringTable()
          Get the stat information in the form of a String table.
 void updateTime(long time)
          Adds a new time sample for this entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

private int count
Statistic counter


error

private int error
Statistic error counter


cacheHit

private int cacheHit
Cache hits counter


minTime

private long minTime
Minimum time for this entry (automatically computed)


maxTime

private long maxTime
Maximum time for this entry (automatically computed)


totalTime

private long totalTime
Total time for this entry


name

private java.lang.String name
Name of the stats.

Constructor Detail

Stats

public Stats(java.lang.String statName)
Creates a new Stats instance. The entries are reset to 0.

Parameters:
statName - The stat name
Method Detail

reset

public void reset()
Resets all entries to 0.


incrementCount

public void incrementCount()
Increments an entry count by one.


incrementError

public void incrementError()
Increments an entry error by one.


incrementCacheHit

public void incrementCacheHit()
Increments an entry cache hit by one.


updateTime

public void updateTime(long time)
Adds a new time sample for this entry. time is added to total time and both minTime and maxTime are updated if needed.

Parameters:
time - time to add to this entry

getName

public java.lang.String getName()
Gets the name of the current stat.

Returns:
stat name

getCount

public int getCount()
Gets current count of an entry.

Returns:
current entry count value

getError

public int getError()
Gets current error count of an entry

Returns:
current entry error value

getCacheHit

public int getCacheHit()
Gets current cache hit count of an entry

Returns:
current entry cache hit value

getMinTime

public long getMinTime()
Gets the minimum time of an entry

Returns:
entry minimum time

getMaxTime

public long getMaxTime()
Gets the maximum time of an entry

Returns:
entry maximum time

getTotalTime

public long getTotalTime()
Gets the total time of an entry

Returns:
entry total time

merge

public void merge(Stats anotherStat)
           throws java.lang.Exception
Adds the entries of another Stats object to this one.

Parameters:
anotherStat - stat to merge with current stat
Throws:
java.lang.Exception - if you try to merge a stat with itself

displayOnStdout

public void displayOnStdout()
Displays the statistics on the standard output.


multipleLineDisplay

public java.lang.String multipleLineDisplay()
Displays the statistics information on multiple lines.

Returns:
a String containing the Stat output

singleLineDisplay

public java.lang.String singleLineDisplay()
Displays the statistics information on a single line in the format: name count error cacheHit %hit minTime maxTime avgTime totalTime

Returns:
a String containing the Stat output

toStringTable

public java.lang.String[] toStringTable()
Get the stat information in the form of a String table. Format is: name count error cacheHit %hit minTime maxTime avgTime totalTime

Returns:
the String table corresponding to this stat


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.