|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.counters.Instrument<T>
public abstract class Instrument<T>
Abstract class for reporting instrumented values supporting some useful conversions.
| Field Summary | |
|---|---|
protected long |
lastModified
The timestamp associated with value. |
protected static org.apache.log4j.Logger |
log
|
protected static String |
NA
N/A |
protected T |
value
The current value -or- null if there is no current value. |
| Constructor Summary | |
|---|---|
Instrument()
|
|
| Method Summary | |
|---|---|
T |
getCurrentValue()
Return the current value without taking another sample() |
T |
getValue()
Obtain a sample. |
long |
lastModified()
Obtain the timestamp for the last collected sample. |
String |
nanosToPerSec(long counter,
long nanos)
Converts an event count whose durations were measured in elapsed nanoseconds to an event rate per second. |
protected abstract void |
sample()
Take a sample, setting the current value and timestamp using either setValue(Object) or setValue(Object, long). |
void |
setValue(T value)
Set the value. |
void |
setValue(T value,
long timestamp)
Set the value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.log4j.Logger log
protected static final transient String NA
N/A
protected T value
null if there is no current value.
protected long lastModified
value.
| Constructor Detail |
|---|
public Instrument()
| Method Detail |
|---|
public final String nanosToPerSec(long counter,
long nanos)
counter - The event count.nanos - The elapsed nanoseconds for the events.
protected abstract void sample()
setValue(Object) or setValue(Object, long).
public final void setValue(T value)
value - The value, which will be associated with the current time as
reported by System.currentTimeMillis().
public final void setValue(T value,
long timestamp)
setValue in interface IInstrument<T>value - The value.timestamp - The timestamp for that value.public final T getValue()
IInstrument
getValue in interface IInstrument<T>public T getCurrentValue()
sample()
public final long lastModified()
IInstrument
lastModified in interface IInstrument<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||