public class TimestampMetricValue extends Object implements ITimestampMetricValue
Note: This class deliberately does not use a generic for the data type. The
data type of the last sampled value remains fluid within instances of this
class. The data type will be converted to the
IGangliaMetadataMessage.getMetricType()
when an
IGangliaMetricMessage
is generated from the current value.
Constructor and Description |
---|
TimestampMetricValue(IGangliaMetadataMessage decl) |
Modifier and Type | Method and Description |
---|---|
int |
getAge()
The age in seconds of the last reported/received value (this reports
seconds for compatibility with tmax and dmax, both of which also use
seconds).
|
IGangliaMetadataMessage |
getMetadata()
The metadata declaration for this metric.
|
long |
getTimestamp()
The timestamp of the last reported/received value (milliseconds).
|
Object |
getValue()
The last reported/received value and
null if no value has
been reported/received. |
int |
priority()
Return the priority.
|
void |
resetTimestamp()
Reset the timestamp.
|
boolean |
setValue(Object newValue)
Update the value associated with the metric.
|
String |
toString()
Human readable representation.
|
void |
update()
Update the timestamp.
|
public TimestampMetricValue(IGangliaMetadataMessage decl)
public IGangliaMetadataMessage getMetadata()
ITimestampMetricValue
getMetadata
in interface ITimestampMetricValue
public long getTimestamp()
ITimestampMetricValue
Note: Tmax is expressed in seconds, so be sure to do the conversion when necessary.
getTimestamp
in interface ITimestampMetricValue
public void resetTimestamp()
public int getAge()
ITimestampMetricValue
getAge
in interface ITimestampMetricValue
public Object getValue()
ITimestampMetricValue
null
if no value has
been reported/received.getValue
in interface ITimestampMetricValue
public boolean setValue(Object newValue)
This method handles any translation which must be applied to the value to
bring it into line with the IGangliaMetadataMessage
for the
metric.
The as stored data type is not important as long as it remains either
String
or a Number
. The IGangliaMessageEncoder
is
responsible for encoding the value according to the ganglia data type
declaration in the IGangliaMetadataMessage
.
newValue
- The new value.true
if the value changed enough to be worth
reporting or if tmax has expired so we need to report the value
anyway.IllegalArgumentException
- if newValue is null
.IllegalArgumentException
- if the metricType is numeric and newValue is not a
Number
.public void update()
public int priority()
tmax - age
, where age is now - timestamp
.
The highest priority is associated with the most negative value. The
lowest priority is associated with the most positive value. These ar the
semantics used by a PriorityBlockingQueue
.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.