public class SimpleLongCounter extends Facultative implements SimpleLongCounterMBean, LongCounter
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicLong |
count
Total number of calls
|
private java.util.concurrent.atomic.AtomicLong |
total
Total sum of samples
|
Constructor and Description |
---|
SimpleLongCounter() |
Modifier and Type | Method and Description |
---|---|
long |
getCount()
Get number of calls
|
long |
getTotal()
Get sum of samples
|
void |
print(java.lang.String file)
Print counters' values to the file
|
void |
print(java.lang.String comment,
java.lang.String file)
Print counters' values to the file
|
void |
reset()
Reset counters
|
java.lang.String |
toString(java.lang.String ts,
java.lang.String comment)
Return the string representation of the counter
|
void |
update(long value)
Update counter
|
enable, getAnnotation, isEnabled, register, setAnnotation
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
enable, getAnnotation, isEnabled, setAnnotation
dump
private final java.util.concurrent.atomic.AtomicLong total
private final java.util.concurrent.atomic.AtomicLong count
public void reset()
reset
in interface SimpleLongCounterMBean
public long getTotal()
getTotal
in interface SimpleLongCounterMBean
public long getCount()
getCount
in interface SimpleLongCounterMBean
public void update(long value)
LongCounter
update
in interface LongCounter
value
- new valueLongCounter.update(long)
public void print(java.lang.String file) throws java.io.IOException
print
in interface SimpleLongCounterMBean
file
- output file name (will be appended if exists)java.io.IOException
- on I/O errorpublic void print(java.lang.String comment, java.lang.String file) throws java.io.IOException
comment
- commentfile
- output file name (will be appended if exists)java.io.IOException
- on I/O errorpublic java.lang.String toString(java.lang.String ts, java.lang.String comment) throws java.io.IOException
toString
in interface LongCounter
ts
- timestamp stringcomment
- commentjava.io.IOException
- on I/O error