Package com.yahoo.statistics
Class Counter
- java.lang.Object
-
- com.yahoo.statistics.Handle
-
- com.yahoo.statistics.Counter
-
public class Counter extends Handle
A single integer value which can be incremented.- Author:
- Steinar Knutsen
-
-
Constructor Summary
Constructors Constructor Description Counter(java.lang.String name, Statistics manager, boolean fetchParametersFromConfig)
A monotonically increasing 64 bit integer value.Counter(java.lang.String name, Statistics manager, boolean fetchParametersFromConfig, Callback callback, boolean resetCounter)
A monotonically increasing 64 bit integer value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
long
get()
boolean
getResetCounter()
The reset counter is true if this is counter is reset to 0 between each logging interval.int
hashCode()
void
increment()
Increment by 1.void
increment(long n)
Increment by n.void
reset()
If this counter should be set to 0 between each logging interval, do that.void
runHandle()
Log current state and reset.java.lang.String
toString()
-
Methods inherited from class com.yahoo.statistics.Handle
cancel, isCancelled, run, runCallback
-
-
-
-
Constructor Detail
-
Counter
public Counter(java.lang.String name, Statistics manager, boolean fetchParametersFromConfig)
A monotonically increasing 64 bit integer value.- Parameters:
name
- The name of this counter, for use in logging.manager
- the statistics manager acquired by injectionfetchParametersFromConfig
- Whether or not this counter should be initialized from config.
-
Counter
public Counter(java.lang.String name, Statistics manager, boolean fetchParametersFromConfig, Callback callback, boolean resetCounter)
A monotonically increasing 64 bit integer value.- Parameters:
name
- The name of this counter, for use in logging.manager
- the statistics manager acquired by injectionfetchParametersFromConfig
- Whether or not this counter should be initialized from config.callback
- will be invoked each time this counter is written to the logresetCounter
- Control for if this Counter should be reset between each logging interval.
-
-
Method Detail
-
increment
public void increment()
Increment by 1.
-
increment
public void increment(long n)
Increment by n.
-
get
public long get()
- Returns:
- current value of this counter
-
getResetCounter
public boolean getResetCounter()
The reset counter is true if this is counter is reset to 0 between each logging interval.- Returns:
- whether this counter is reset between each logging interval.
-
reset
public void reset()
If this counter should be set to 0 between each logging interval, do that.
-
runHandle
public void runHandle()
Log current state and reset.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-