public class GangliaState extends Object implements IGangliaState
| Constructor and Description |
|---|
GangliaState(String hostName,
IGangliaMetadataFactory metadataFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
deleteHost(String hostName)
Drop counters for the named host.
|
String |
getHostName()
Return the name of this host.
|
String[] |
getKnownHosts()
Return a snapshot of the known hosts.
|
IGangliaMetadataMessage |
getMetadata(String metricName)
Return the metadata for the given metric.
|
IGangliaMetadataFactory |
getMetadataFactory()
The factory used to create declarations for new metrics and resolve
received declarations to objects with a richer behavior (such as value
translation and scaling).
|
TimestampMetricValue |
getMetric(String hostName,
String metricName)
Return current
TimestampMetricValue of metric on host
(thread-safe). |
Iterator<TimestampMetricValue> |
iterator(String hostName)
Return an iterator which will visit all timestamped metrics for the
specified host.
|
void |
purgeOldHostsAndMetrics(int dmax)
Purge all metrics for any host whose heartbeat has not been updated in at
the last dmax seconds and any counter which has not been updated within
its dmax seconds.
|
IGangliaMetadataMessage |
putIfAbsent(IGangliaMetadataMessage decl)
Atomically declare/resolve the metadata for a metric (thread-safe).
|
void |
reset()
Reset the soft state, clearing metadata declarations and metric values
for all hosts.
|
public GangliaState(String hostName, IGangliaMetadataFactory metadataFactory)
hostName - The name of this host.metadataFactory - The factory used to create declarations for new metrics.public String getHostName()
IGangliaStategetHostName in interface IGangliaStatepublic IGangliaMetadataFactory getMetadataFactory()
public String[] getKnownHosts()
IGangliaStategetKnownHosts in interface IGangliaStatenull.public Iterator<TimestampMetricValue> iterator(String hostName)
IGangliaStateiterator in interface IGangliaStatehostName - The host name.null.public IGangliaMetadataMessage getMetadata(String metricName)
IGangliaStategetMetadata in interface IGangliaStatemetricName - The metric name (as it appears in ganglia messages).null.public IGangliaMetadataMessage putIfAbsent(IGangliaMetadataMessage decl)
decl - The declaration.IGangliaMetadataFactory.resolve(IGangliaMetadataMessage),
or the pre-existing declaration for the same metric.public TimestampMetricValue getMetric(String hostName, String metricName)
IGangliaStateTimestampMetricValue of metric on host
(thread-safe).
If an IGangliaMetadataMessage is declared for that name, then
either the pre-existing TimestampMetricValue will be returned
-or- a new TimestampMetricValue will be atomically created and
returned.
Otherwise, this method will return null since it lacks the
necessary information to create an IGangliaMetadataMessage by
itself.
getMetric in interface IGangliaStatehostName - The name of the host.metricName - The name of the metric.null if there is no IGangliaMetadataMessage
for that metric.public void purgeOldHostsAndMetrics(int dmax)
Note: This method should be invoked periodically to age out hosts and metrics which have not reported in for a long time.
dmax - The global DMax value.public void deleteHost(String hostName)
Note:There may be some interactions if another thread is currently in the middle of adding a counter for the host. What can happen is that the other thread gets the counters for the host and then returns the TMV for the metric while this method concurrently deletes the entry for the host from knownHosts. This would mean that the other thread has returned a TMV entry which is not going to remain visible. If there is a problem, it will be related to what is then done with that TMV entry.
hostName - The host name.public void reset()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.