public class CounterMXBeanImpl extends AbstractSimonMXBeanImpl implements CounterMXBean
Counter
. It is not created
by default when JMX is activated - it must be created explicitly.
JmxRegisterCallback
can be used to automate this.
Class can be subclassed to override default behavior if desired, counter
is declared protected for this reason.Modifier and Type | Field and Description |
---|---|
protected Counter |
counter
Wrapped
Counter instance - protected for subclasses. |
Constructor and Description |
---|
CounterMXBeanImpl(Counter counter)
Creates the MX bean for the provided Counter.
|
Modifier and Type | Method and Description |
---|---|
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 |
sampleIncrement(String key)
Samples increment in Simon values since the previous call of this method with the
same key.
|
void |
set(long val)
Sets the value of the counter to specified value.
|
protected Simon |
simon()
Returns the wrapped Simon.
|
boolean |
stopIncrementalSampling(String key)
Stops incremental sampling for the key, removing any internal information for the key.
|
getChildrenNames, getFirstUsage, getFirstUsageAsString, getLastUsage, getLastUsageAsString, getName, getNote, getParentName, getState, isEnabled, setNote, setState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChildrenNames, getFirstUsage, getFirstUsageAsString, getLastUsage, getLastUsageAsString, getName, getNote, getParentName, getState, isEnabled, setNote, setState
public CounterMXBeanImpl(Counter counter)
counter
- wrapped Counterpublic final void increase()
CounterMXBean
increase
in interface CounterMXBean
Counter.increase()
public final void decrease()
CounterMXBean
decrease
in interface CounterMXBean
Counter.decrease()
public final void increase(long inc)
CounterMXBean
increase
in interface CounterMXBean
inc
- added valueCounter.increase(long)
public final void decrease(long dec)
CounterMXBean
decrease
in interface CounterMXBean
dec
- subtracted valueCounter.decrease(long)
public long getMaxTimestamp()
CounterMXBean
getMaxTimestamp
in interface CounterMXBean
Counter.getMaxTimestamp()
public long getMax()
CounterMXBean
getMax
in interface CounterMXBean
Counter.getMax()
public long getMinTimestamp()
CounterMXBean
getMinTimestamp
in interface CounterMXBean
Counter.getMinTimestamp()
public long getMin()
CounterMXBean
getMin
in interface CounterMXBean
Counter.getMin()
public long getCounter()
CounterMXBean
getCounter
in interface CounterMXBean
Counter.getCounter()
public final void set(long val)
CounterMXBean
set
in interface CounterMXBean
val
- new counter valueCounter.set(long)
public long getIncrementSum()
CounterMXBean
getIncrementSum
in interface CounterMXBean
Counter.getIncrementSum()
public long getDecrementSum()
CounterMXBean
getDecrementSum
in interface CounterMXBean
Counter.getDecrementSum()
public final CounterSample sample()
SimonSuperMXBean
sample
in interface CounterMXBean
sample
in interface SimonSuperMXBean
public CounterSample sampleIncrement(String key)
SimonSuperMXBean
SimonSuperMXBean.sample()
. Any subsequent calls with the key
provide increments.
Clients should use a unique key (GUID, host name, etc.), to avoid interference
with other clients.sampleIncrement
in interface CounterMXBean
sampleIncrement
in interface SimonSuperMXBean
key
- key used to access incremental sampleSample
with value incrementspublic final String getType()
SimonSuperMXBean
ObjectName
.getType
in interface SimonSuperMXBean
public boolean stopIncrementalSampling(String key)
SimonSuperMXBean
SimonSuperMXBean.sampleIncrement(String)
for the key will be considered the first
call for the key.stopIncrementalSampling
in interface SimonSuperMXBean
key
- key used to access incremental sampleprotected final Simon simon()
AbstractSimonMXBeanImpl
simon
in class AbstractSimonMXBeanImpl
Copyright © 2019. All rights reserved.