|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Counter
Counter tracks the single integer value and watches its max/min values. It can be used for values starting with 0 - in that case min might not be important if counter does not go bellow 0. Counter can also start from any other arbitrary number that is set after the first change (increment, decrement, set) - this is more typical case for tracking also the min value.
Counter counter = SimonManager.getCounter("com.my.counter");
System.out.println("counter = " + counter);
Output is:
counter = Simon Counter: [com.my.counter INHERIT] counter=0, max=undef, min=undefThis behavior allows the counter to be initialized before it is used and its exteremes are tracked - first initialization also sets max/min (extreme) values:
Counter counter = SimonManager.getCounter("com.my.counter").set(47);
System.out.println("counter = " + counter);
Output is:
counter = Simon Counter: [com.my.counter INHERIT] counter=47, max=47, min=47
increase() and decrease() methods when
it is possible to track the monitored value - this can be used for example to count users logged
in. If the value changes by more than 1 than it is possible to use methods with arguments -
increase(long) and decrease(long). Finally method set(long) is
always available to set the counter to the particular value when needed.
| Method Summary | |
|---|---|
Counter |
decrease()
Decrements the counter by one. |
Counter |
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. |
Counter |
increase()
Increments the counter by one. |
Counter |
increase(long inc)
Increments the counter by the specified value. |
Counter |
reset()
Resets the Simon values related to the measuring, timestamps and so on - usage timestamps, state, attributes are not affected. |
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. |
Counter |
set(long val)
Sets the value of the counter to specified value. |
| Methods inherited from interface org.javasimon.Simon |
|---|
getFirstUsage, getChildren, getLastReset, getLastUsage, getName, getNote, getParent, getState, isEnabled, setNote, setState |
| Methods inherited from interface org.javasimon.HasAttributes |
|---|
getAttribute, getAttribute, getAttributeNames, getCopyAsSortedMap, removeAttribute, setAttribute |
| Method Detail |
|---|
Counter increase()
Counter decrease()
Counter increase(long inc)
inc - added value
Counter decrease(long dec)
dec - subtracted value
long getCounter()
long getMin()
long getMinTimestamp()
long getMax()
long getMaxTimestamp()
Counter set(long val)
val - new counter value
Counter reset()
SimonSimon.getLastReset(). Reset is perfomed even for disabled Simons.
reset in interface Simonlong getIncrementSum()
long getDecrementSum()
CounterSample sample()
Simon
sample in interface SimonCounterSample sampleAndReset()
Simon
sampleAndReset in interface Simon
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||