|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.statistics.AbstractStatistic
This class provides a default implementation of the Statistic interface, providing such functionality as keeping track of the history for the given statistic, providing access to the average value, the maximum value, etc.
Field Summary | |
protected IntBuffer |
_buffer
IntBuffer for recording stats data -- initialized to an empty buffer until stats are actually recorded. |
protected int |
_current
Long for the statistic currently being added to. |
protected java.lang.String |
_fileName
The file name to write stat data to. |
protected double |
_max
The maximum value ever recorded for any time period. |
protected double |
_total
Variable for the total number of messages received for this statistic. |
protected int |
_totalStatsRecorded
The total number of stats recorded. |
protected static StatisticsManager |
STATS_MANAGER
Constant for the StatisticsManager for use in subclasses. |
Fields inherited from interface com.limegroup.gnutella.statistics.Statistic |
HISTORY_LENGTH |
Constructor Summary | |
protected |
AbstractStatistic()
Constructs a new Statistic instance. |
Method Summary | |
void |
addData(int data)
Add the specified number to the current recording for this statistic. |
void |
clearData()
Clears the current data stored in this statistic. |
double |
getAverage()
Accessor for the average number of this statistic type received per recording time period. |
double |
getMax()
Accessor for the maximum recorded stat value over all recorded time periods. |
IntBuffer |
getStatHistory()
Accessor for the Integer array of all statistics recorded over a discrete interval. |
double |
getTotal()
Accessor for the total number of this statistic recorded. |
void |
incrementStat()
Increments this statistic by one. |
protected void |
initializeBuffer()
Constructs the IntBuffer with 0 for all values if it is not already constructed. |
void |
setWriteStatToFile(boolean write)
Sets whether or not to write this Statistic out to a file. |
void |
storeCurrentStat()
Stores the current set of gathered statistics into the history set, setting the currently recorded data back to zero. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final StatisticsManager STATS_MANAGER
protected IntBuffer _buffer
protected volatile int _current
protected volatile double _total
protected volatile int _totalStatsRecorded
protected volatile double _max
protected java.lang.String _fileName
Constructor Detail |
protected AbstractStatistic()
Method Detail |
public double getTotal()
Statistic
getTotal
in interface Statistic
public double getAverage()
Statistic
getAverage
in interface Statistic
public double getMax()
Statistic
getMax
in interface Statistic
public void incrementStat()
Statistic
incrementStat
in interface Statistic
public void addData(int data)
Statistic
addData
in interface Statistic
data
- the number to increment the current statisticpublic IntBuffer getStatHistory()
Statistic
getStatHistory
in interface Statistic
public void clearData()
Statistic
clearData
in interface Statistic
public void storeCurrentStat()
Statistic
storeCurrentStat
in interface Statistic
public void setWriteStatToFile(boolean write)
Statistic
setWriteStatToFile
in interface Statistic
write
- whether or not to write the data to a fileprotected final void initializeBuffer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |