org.javasimon.jmx
Class CounterMXBeanImpl

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

public class CounterMXBeanImpl
extends AbstractSimonMXBeanImpl
implements CounterMXBean

MX Bean representing a particular Counter. 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, counter is declared protected for this reason.

Author:
Richard "Virgo" Richter

Field Summary
protected  Counter counter
          Wrapped Counter instance - protected for subclasses.
 
Constructor Summary
CounterMXBeanImpl(Counter counter)
          Creates the MX bean for the provided Counter.
 
Method Summary
 void decrease()
          Decrements the counter by one.
 void decrease(long dec)
          Increments the counter by the specified value.
 long getCounter()
          Returns the current value of the counter.
 long getDecrementSum()
          Returns the sum of all decremented values (as a positive number).
 long getIncrementSum()
          Returns the sum of all incremented values.
 long getMax()
          Returns maximal value of counter.
 long getMaxTimestamp()
          Returns ms timestamp when the max value was reached.
 long getMin()
          Returns minimal value of counter.
 long getMinTimestamp()
          Returns ms timestamp when the min value was reached.
 String getType()
          Returns Simon type used as a property in the ObjectName.
 void increase()
          Increments the counter by one.
 void increase(long inc)
          Increments the counter by the specified value.
 CounterSample sample()
          Samples Simon values and returns them in a Java Bean derived from Sample interface.
 CounterSample sampleAndReset()
          Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon.
 void set(long val)
          Sets the value of the counter to specified value.
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

counter

protected Counter counter
Wrapped Counter instance - protected for subclasses.

Constructor Detail

CounterMXBeanImpl

public CounterMXBeanImpl(Counter counter)
Creates the MX bean for the provided Counter.

Parameters:
counter - wrapped Counter
Method Detail

increase

public final void increase()
Description copied from interface: CounterMXBean
Increments the counter by one.

Specified by:
increase in interface CounterMXBean
See Also:
Counter.increase()

decrease

public final void decrease()
Description copied from interface: CounterMXBean
Decrements the counter by one.

Specified by:
decrease in interface CounterMXBean
See Also:
Counter.decrease()

increase

public final void increase(long inc)
Description copied from interface: CounterMXBean
Increments the counter by the specified value.

Specified by:
increase in interface CounterMXBean
Parameters:
inc - added value
See Also:
Counter.increase(long)

decrease

public final void decrease(long dec)
Description copied from interface: CounterMXBean
Increments the counter by the specified value.

Specified by:
decrease in interface CounterMXBean
Parameters:
dec - subtracted value
See Also:
Counter.decrease(long)

getMaxTimestamp

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

Specified by:
getMaxTimestamp in interface CounterMXBean
Returns:
ms timestamp of the max value incremented
See Also:
Counter.getMaxTimestamp()

getMax

public long getMax()
Description copied from interface: CounterMXBean
Returns maximal value of counter.

Specified by:
getMax in interface CounterMXBean
Returns:
maximal reached value
See Also:
Counter.getMax()

getMinTimestamp

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

Specified by:
getMinTimestamp in interface CounterMXBean
Returns:
ms timestamp of the min value decremented
See Also:
Counter.getMinTimestamp()

getMin

public long getMin()
Description copied from interface: CounterMXBean
Returns minimal value of counter.

Specified by:
getMin in interface CounterMXBean
Returns:
maximal reached value
See Also:
Counter.getMin()

getCounter

public long getCounter()
Description copied from interface: CounterMXBean
Returns the current value of the counter.

Specified by:
getCounter in interface CounterMXBean
Returns:
counter value
See Also:
Counter.getCounter()

set

public final void set(long val)
Description copied from interface: CounterMXBean
Sets the value of the counter to specified value.

Specified by:
set in interface CounterMXBean
Parameters:
val - new counter value
See Also:
Counter.set(long)

getIncrementSum

public long getIncrementSum()
Description copied from interface: CounterMXBean
Returns the sum of all incremented values. If incremented value was negative, sum is lowered by this value.

Specified by:
getIncrementSum in interface CounterMXBean
Returns:
sum of all incremented values
See Also:
Counter.getIncrementSum()

getDecrementSum

public long getDecrementSum()
Description copied from interface: CounterMXBean
Returns the sum of all decremented values (as a positive number). If decremented value was negative, sum is lowered by this value.

Specified by:
getDecrementSum in interface CounterMXBean
Returns:
sum of all decremented values
See Also:
Counter.getDecrementSum()

sample

public final CounterSample 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 CounterMXBean
Specified by:
sample in interface SimonSuperMXBean
Returns:
sample containing all Simon values

sampleAndReset

public final CounterSample 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 CounterMXBean
Specified by:
sampleAndReset in interface SimonSuperMXBean
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.