public class StatisticSlidingAvgCounter extends Statistics<StatisticSlidingAvgCounter> implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
protected static class |
StatisticSlidingAvgCounter.ValueTime
This simple class encapsulates the pair: double value + time when it was added
|
Modifier and Type | Field and Description |
---|---|
protected int |
count |
protected long |
resetTime
Remember the time stamp of reseting (or creating) the statistics
|
protected double |
sum
aggregated values
|
replaceWith
Modifier | Constructor and Description |
---|---|
protected |
StatisticSlidingAvgCounter(java.lang.String name)
Creates a new instance of StatisticSlidingAvgCounter
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(double value)
add value and expect that it has been measured now - get current time
|
void |
addValue(double value,
java.lang.Object obj)
add value and expect that it has been measured now - get current time.
|
protected StatisticSlidingAvgCounter |
cast()
Returns this statistics as the type provided typed argument.
|
double |
getAvg()
return average of the values in queue
|
double |
getAvg(boolean consolidate)
return the average but do not consolidate the list of values if the parameter is false
|
int |
getCnt()
return number of values in the queue
|
double |
getMax()
return maximum value from the queue
|
int |
getMaxNumberOfValues() |
double |
getMin()
return minimum value from the queue
|
static StatisticSlidingAvgCounter |
getStatistics(java.lang.String name)
Create new statistic counter with specified name or get the one already existing
|
double |
getSum()
return the sum of queue values
|
java.lang.String |
getValue()
Returns the value of this statistic.
|
long |
getWindowSizeMilis() |
boolean |
changedSinceCheckpoint()
Reports if value of min/max has been changed since the last setCheckpoint() call.
|
boolean |
checkUsedTime()
Checks whether the sliding window was used for full time period
|
void |
reset()
Reset the current statistic
|
protected void |
setFrom(StatisticSlidingAvgCounter sourceStat)
Set this statistic to values from given statistic
|
void |
setCheckpoint()
Sets checkpoint.
|
void |
setMaxNumberOfValues(int maxNumberOfValues)
sets the size of window to consider
|
void |
setWindowSizeMilis(long windowSizeMilis)
and sets the size of the time-sliding window in milis
|
void |
shiftValuesByTime(long time)
add a given time difference to ALL values in the list
|
java.lang.String |
toString()
Text representation of the SlidingWindow
|
protected void |
updateFrom(StatisticSlidingAvgCounter sourceStat)
the final queue should be sorted according to time as required
|
addBoundStat, bindTo, canPerformOperation, disableGlobally, enableGlobally, getAllStatistics, getAllStatistics, getBoundStats, getBoundTo, getName, getStatistics, isBound, isEnabledGlobally, isRegisteredGlobally, printStatistics, printStatistics, printStatistics, readResolve, removeBoundStat, removeStatistic, resetStatistics, resetStatistics, unbind
protected long resetTime
protected double sum
protected int count
protected StatisticSlidingAvgCounter(java.lang.String name)
public boolean checkUsedTime()
public int getMaxNumberOfValues()
public void setMaxNumberOfValues(int maxNumberOfValues)
maxNumberOfValues
- if < 0 then - use all valuespublic long getWindowSizeMilis()
public void setWindowSizeMilis(long windowSizeMilis)
windowSizeMilis
- if <= 0 - do not use the time windowpublic void shiftValuesByTime(long time)
public void addValue(double value)
public void addValue(double value, java.lang.Object obj)
public double getSum()
public int getCnt()
public double getAvg()
public double getAvg(boolean consolidate)
public double getMin()
public double getMax()
public java.lang.String getValue()
Statistics
getValue
in class Statistics<StatisticSlidingAvgCounter>
public static StatisticSlidingAvgCounter getStatistics(java.lang.String name) throws java.lang.ClassCastException
java.lang.ClassCastException
protected void updateFrom(StatisticSlidingAvgCounter sourceStat)
updateFrom
in class Statistics<StatisticSlidingAvgCounter>
sourceStat
- the statistic from which to update this statprotected void setFrom(StatisticSlidingAvgCounter sourceStat)
setFrom
in class Statistics<StatisticSlidingAvgCounter>
sourceStat
- the statistic from which to set this statpublic void reset()
reset
in class Statistics<StatisticSlidingAvgCounter>
public boolean changedSinceCheckpoint()
public void setCheckpoint()
public java.lang.String toString()
toString
in class java.lang.Object
protected StatisticSlidingAvgCounter cast()
Statistics
cast
in class Statistics<StatisticSlidingAvgCounter>