org.apache.commons.monitoring.impl.values
Class AbstractStatValue<T extends StatValue>
java.lang.Object
org.apache.commons.monitoring.impl.values.AbstractStatValue<T>
- All Implemented Interfaces:
- StatValue
- Direct Known Subclasses:
- ThreadSafeCounter, ThreadSafeGauge
public abstract class AbstractStatValue<T extends StatValue>
- extends java.lang.Object
- implements StatValue
A simple implementation of StatValue. Only provide methods to
compute stats from sum provided by derived classes.
- Author:
- Nicolas De Loof
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractStatValue
public AbstractStatValue(Role<T> role)
addListener
public void addListener(StatValue.Listener listener)
- Specified by:
addListener in interface StatValue
removeListener
public void removeListener(StatValue.Listener listener)
- Specified by:
removeListener in interface StatValue
normalize
protected long normalize(long value,
Unit unit)
getMean
public abstract double getMean()
-
- Specified by:
getMean in interface StatValue
- Returns:
- the arithmetic mean value
getMax
public long getMax()
-
- Specified by:
getMax in interface StatValue
- Returns:
- the maximum value
getMin
public long getMin()
-
- Specified by:
getMin in interface StatValue
- Returns:
- the minimum value
computeStats
protected void computeStats(long l)
fireValueChanged
protected void fireValueChanged(long l)
getStandardDeviation
public double getStandardDeviation()
- Computes the
http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
unbiased variance and return the standard deviation
Compute the standard deviation : measures the dispersion of values around
the average value = sqrt( variance ).
- Specified by:
getStandardDeviation in interface StatValue
- Returns:
- the value standard deviation
getSquares
protected abstract long getSquares()
getSum
public abstract long getSum()
getHits
public int getHits()
getMonitor
public Monitor getMonitor()
- Specified by:
getMonitor in interface StatValue
- Returns:
- the monitor this value is attached to
getRole
public Role<T> getRole()
- Specified by:
getRole in interface StatValue
- Returns:
- the role for this value in the monitor
setMonitor
public void setMonitor(Monitor monitor)
- Description copied from interface:
StatValue
- Set the monitor this value is attached to
- Specified by:
setMonitor in interface StatValue
getUnit
public Unit getUnit()
- Specified by:
getUnit in interface StatValue
- Returns:
- the (primary) data unit
Copyright © 2008 The Apache Software Foundation. All Rights Reserved.