org.objectweb.cjdbc.util
Class Stats

java.lang.Object
  extended byorg.objectweb.cjdbc.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 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 display()
          Displays the statistics on the standard output.
 void display(java.io.PrintStream out)
          Displays the statistics on the standard output.
 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
 long getTotalTime()
          Gets the total time of an entry
 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.
 void reset()
          Resets all entries to 0.
 void updateTime(long time)
          Add sa 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


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.


updateTime

public void updateTime(long time)
Add sa 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

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

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

display

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


display

public void display(java.io.PrintStream out)
Displays the statistics on the standard output.

Parameters:
out - the output stream to display the stats


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