org.javasimon.jmx
Class StopwatchMXBeanImpl

java.lang.Object
  extended by org.javasimon.jmx.AbstractSimonMXBeanImpl
      extended by org.javasimon.jmx.StopwatchMXBeanImpl
All Implemented Interfaces:
SimonSuperMXBean, StopwatchMXBean

public class StopwatchMXBeanImpl
extends AbstractSimonMXBeanImpl
implements StopwatchMXBean

MX Bean representing a particular Stopwatch. It is not created by default when JMX is activated - it must be created explicitely. JmxRegisterCallback can be used to automate this.

Class can be subclassed to override default behavior if desired, stopwatch is declared protected for this reason.

Author:
Richard "Virgo" Richter

Field Summary
protected  Stopwatch stopwatch
          Wrapped Stopwatch instance - protected for subclasses.
 
Constructor Summary
StopwatchMXBeanImpl(Stopwatch stopwatch)
          Creates the MX bean for the provided Stopwatch.
 
Method Summary
 void addTime(long ns)
          Adds split time in nanoseconds to total time of the stopwatch.
 long getActive()
          Returns current number of measured splits (concurrently running).
 long getCounter()
          Returns usage count of the stopwatch.
 long getLast()
          Returns value of the last added split - wheter it was added directly or with stop method.
 String getLastAsString()
          Returns value of the last added split as formatted string.
 long getMax()
          Returns maximal time split value in nanoseconds.
 long getMaxActive()
          Returns peek value of active concurrent splits.
 long getMaxActiveTimestamp()
          Retruns ms timestamp when the last peek of the active split count occured.
 long getMaxTimestamp()
          Returns ms timestamp when the max value was measured.
 double getMean()
          Returns mean value (average) of all measured values.
 long getMin()
          Returns minimal time split value in nanoseconds.
 long getMinTimestamp()
          Returns ms timestamp when the min value was measured.
 double getStandardDeviation()
          Returns standard deviation for all measured values.
 long getTotal()
          Returns total sum of all split times in nanoseconds.
 String getType()
          Returns Simon type used as a property in the ObjectName.
 double getVariance()
          Returns unbiased estimate of the population variance.
 double getVarianceN()
          Returns variance value of all measured values (entire population).
 StopwatchSample sample()
          Samples Simon values and returns them in a Java Bean derived from Sample interface.
 StopwatchSample sampleAndReset()
          Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon.
protected  Simon simon()
          Returns the wrapped Simon.
 
Methods inherited from class org.javasimon.jmx.AbstractSimonMXBeanImpl
getFirstUsage, getFirstUsageAsString, getChildrenNames, getLastUsage, getLastUsageAsString, getName, getNote, getParentName, getState, isEnabled, reset, setNote, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.javasimon.jmx.SimonSuperMXBean
getFirstUsage, getFirstUsageAsString, getChildrenNames, getLastUsage, getLastUsageAsString, getName, getNote, getParentName, getState, isEnabled, reset, setNote, setState
 

Field Detail

stopwatch

protected Stopwatch stopwatch
Wrapped Stopwatch instance - protected for subclasses.

Constructor Detail

StopwatchMXBeanImpl

public StopwatchMXBeanImpl(Stopwatch stopwatch)
Creates the MX bean for the provided Stopwatch.

Parameters:
stopwatch - wrapped Stopwatch
Method Detail

addTime

public final void addTime(long ns)
Description copied from interface: StopwatchMXBean
Adds split time in nanoseconds to total time of the stopwatch.

Specified by:
addTime in interface StopwatchMXBean
Parameters:
ns - split time
See Also:
Stopwatch.addTime(long)

getTotal

public long getTotal()
Description copied from interface: StopwatchMXBean
Returns total sum of all split times in nanoseconds.

Specified by:
getTotal in interface StopwatchMXBean
Returns:
total time of the stopwatch in nanoseconds
See Also:
Stopwatch.getTotal()

getLast

public final long getLast()
Description copied from interface: StopwatchMXBean
Returns value of the last added split - wheter it was added directly or with stop method.

Specified by:
getLast in interface StopwatchMXBean
Returns:
value of the last added split
See Also:
Stopwatch.getLast()

getLastAsString

public final String getLastAsString()
Description copied from interface: StopwatchMXBean
Returns value of the last added split as formatted string.

Specified by:
getLastAsString in interface StopwatchMXBean
Returns:
value of the last added split as string

getCounter

public long getCounter()
Description copied from interface: StopwatchMXBean
Returns usage count of the stopwatch. Counter is increased by addTime and stop - that means that it's updated every time the next time split is added.

Specified by:
getCounter in interface StopwatchMXBean
Returns:
count of time splits
See Also:
Stopwatch.getCounter()

getMax

public long getMax()
Description copied from interface: StopwatchMXBean
Returns maximal time split value in nanoseconds.

Specified by:
getMax in interface StopwatchMXBean
Returns:
maximal time split in nanoseconds
See Also:
Stopwatch.getMax()

getMin

public long getMin()
Description copied from interface: StopwatchMXBean
Returns minimal time split value in nanoseconds.

Specified by:
getMin in interface StopwatchMXBean
Returns:
minimal time split in nanoseconds
See Also:
Stopwatch.getMin()

getMaxTimestamp

public long getMaxTimestamp()
Description copied from interface: StopwatchMXBean
Returns ms timestamp when the max value was measured.

Specified by:
getMaxTimestamp in interface StopwatchMXBean
Returns:
ms timestamp of the max value measurement
See Also:
Stopwatch.getMaxTimestamp()

getMinTimestamp

public long getMinTimestamp()
Description copied from interface: StopwatchMXBean
Returns ms timestamp when the min value was measured.

Specified by:
getMinTimestamp in interface StopwatchMXBean
Returns:
ms timestamp of the min value measurement
See Also:
Stopwatch.getMinTimestamp()

getActive

public long getActive()
Description copied from interface: StopwatchMXBean
Returns current number of measured splits (concurrently running).

Specified by:
getActive in interface StopwatchMXBean
Returns:
current number of active splits
See Also:
Stopwatch.getActive()

getMaxActive

public long getMaxActive()
Description copied from interface: StopwatchMXBean
Returns peek value of active concurrent splits.

Specified by:
getMaxActive in interface StopwatchMXBean
Returns:
maximum reached value of active splits
See Also:
Stopwatch.getMaxActive()

getMaxActiveTimestamp

public long getMaxActiveTimestamp()
Description copied from interface: StopwatchMXBean
Retruns ms timestamp when the last peek of the active split count occured.

Specified by:
getMaxActiveTimestamp in interface StopwatchMXBean
Returns:
ms timestamp of the last peek of the active split count
See Also:
Stopwatch.getMaxActiveTimestamp()

getMean

public double getMean()
Description copied from interface: StopwatchMXBean
Returns mean value (average) of all measured values.

Specified by:
getMean in interface StopwatchMXBean
Returns:
mean value
See Also:
Stopwatch.getMean()

getStandardDeviation

public double getStandardDeviation()
Description copied from interface: StopwatchMXBean
Returns standard deviation for all measured values.

Specified by:
getStandardDeviation in interface StopwatchMXBean
Returns:
standard deviation
See Also:
Stopwatch.getStandardDeviation()

getVariance

public double getVariance()
Description copied from interface: StopwatchMXBean
Returns unbiased estimate of the population variance.

Specified by:
getVariance in interface StopwatchMXBean
Returns:
unbiased estimated variance
See Also:
Stopwatch.getVariance()

getVarianceN

public double getVarianceN()
Description copied from interface: StopwatchMXBean
Returns variance value of all measured values (entire population).

Specified by:
getVarianceN in interface StopwatchMXBean
Returns:
entire population variance
See Also:
Stopwatch.getVarianceN()

sample

public final StopwatchSample sample()
Description copied from interface: SimonSuperMXBean
Samples Simon values and returns them in a Java Bean derived from Sample interface.

Specified by:
sample in interface SimonSuperMXBean
Specified by:
sample in interface StopwatchMXBean
Returns:
sample containing all Simon values

sampleAndReset

public final StopwatchSample sampleAndReset()
Description copied from interface: SimonSuperMXBean
Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon. Operation is synchronized to assure atomicity.

Specified by:
sampleAndReset in interface SimonSuperMXBean
Specified by:
sampleAndReset in interface StopwatchMXBean
Returns:
sample containing all Simon values

getType

public final String getType()
Description copied from interface: SimonSuperMXBean
Returns Simon type used as a property in the ObjectName.

Specified by:
getType in interface SimonSuperMXBean
Returns:
Simon type

simon

protected final Simon simon()
Description copied from class: AbstractSimonMXBeanImpl
Returns the wrapped Simon.

Specified by:
simon in class AbstractSimonMXBeanImpl
Returns:
wrapped Simon


Copyright © 2013. All Rights Reserved.