public class SimpleMetric extends Object implements IMetric, Serializable
String key, and contains a number
representing "number of" and a number representing "value of".
Additionally, a timer is "started" (recorded) when the object is created.| Modifier and Type | Field and Description |
|---|---|
protected long |
ended
Timer end (in milliseconds since Epoch).
|
protected long |
lNo
Logs how many times the value is read (intermediate time #).
|
protected long |
started
The startup time (in milliseconds since Epoch).
|
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleMetric()
Default constructor.
|
|
SimpleMetric(String pkey)
Constructor providing ID only.
|
|
SimpleMetric(String s,
long n,
long v)
Constructor setting all values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(long v)
Add a value to a metric and increase the counter.
|
void |
addMS()
Adds the current elapsed time in milliseconds as if with
add(long),
and restarts the timer. |
double |
avg()
Calculates average - value per number.
|
void |
clear()
Resets the metric.
|
Object |
clone()
Make a clone of this object.
|
boolean |
equals(Object that) |
long |
getCount()
Gets the count of updates to this metric.
|
String |
getKey()
Returns the metric key value.
|
long |
getTimer()
Returns the running time so far.
|
long |
getValue()
Gets the total value for this metric.
|
int |
hashCode()
Returns a hash code for this object.
|
void |
reset()
Resets the start time for the timer functions.
|
void |
setCount(long n)
Sets the counter value.
|
protected void |
setEnd()
Captures the current time in
ended for internal operations. |
void |
setKey(String newVal)
Sets the metric key value.
|
void |
setValue(long n)
Sets the new value without changing the count.
|
double |
speed()
Calculates speed - number per second.
|
IMetric |
stopTimer()
Sets the end value for the timer and returns a reference to this object.
|
String |
toString() |
double |
volume()
Calculates volume - value per second.
|
protected long started
protected long ended
setEnd()protected long lNo
protected SimpleMetric()
public SimpleMetric(String pkey)
pkey - IDpublic SimpleMetric(String s, long n, long v)
s - IDn - Value of number of times called (normally 0)v - Value so far (normally 0)protected void setEnd()
ended for internal operations.public Object clone() throws CloneNotSupportedException
IMetricclone in interface IMetricclone in class ObjectCloneNotSupportedException - if it fails...public void add(long v)
public void addMS()
add(long),
and restarts the timer.public void reset()
public String getKey()
getKey in interface IMetricsetKey(java.lang.String)public long getCount()
getCount in interface IMetricsetCount(long)public long getValue()
getValue in interface IMetricsetValue(long)public long getTimer()
public IMetric stopTimer()
public void setKey(String newVal)
setKey in interface IMetricnewVal - New key value. Must not be null.IllegalArgumentException - If key is null.getKey()public void setCount(long n)
setCount in interface IMetricn - New counter valuegetCount()public void setValue(long n)
setValue in interface IMetricn - New valuegetValue()public double avg()
Double.MAX_VALUE if only number is unset.public double speed()
Double.MAX_VALUE if started==ended.public double volume()
Double.MAX_VALUE if started==ended.public int hashCode()
Copyright © 2006–2017 Esito AS. All rights reserved.