org.gridlab.gat.monitoring
Class Metric

java.lang.Object
  extended by org.gridlab.gat.monitoring.Metric
All Implemented Interfaces:
Serializable

public class Metric
extends Object
implements Serializable

An instance of this class represents a measurable quantity within a monitoring system. There are two classes of metrics a monitoring system must deal with:

Instances of this class deal with both classes of metrics.

A metric definition contains the following information:

Metric parameters The Metric parameters field in the metric definition contains the formal definition of the metric parameters. Many metrics can be measured at different places simultaneously. For example, CPU utilisation can be measured on several hosts or grid resources. The metric parameters can be used to distinguish between these different metric instances.

See Also:
Serialized Form

Constructor Summary
Metric(MetricDefinition definition, Map<String,Object> metricParameters)
          Constructs a Metric instance from the passed Metric name and concrete values for the Metric parameters.
Metric(MetricDefinition definition, Map<String,Object> metricParameters, long frequency)
          Constructs a Metric instance from the passed Metric name and concrete values for the Metric parameters.
 
Method Summary
 boolean equals(Object object)
          Tests this Metric for equality with the passed Object.
 MetricDefinition getDefinition()
          Gets the MetricDefinition.
 long getFrequency()
          Gets the measurement frequency in milliseconds.
 Object getMetricParameterByName(String name)
          Gets the Metric parameter value associated with the passed Metric parameter name.
 Map<String,Object> getMetricParameters()
          Gets the Metric parameters associated with this Metric.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Metric

public Metric(MetricDefinition definition,
              Map<String,Object> metricParameters)
Constructs a Metric instance from the passed Metric name and concrete values for the Metric parameters. This constructor is used for DISCRETE metrics. Hence, there is no frequency specified.

The passed Metric name must be equal, as determined by String.equals(Object), to the Metric name in the desired target MetricDefinition. In addition, the passed concrete values for the Metric parameters must be of the same name and type as the Metric parameters in the desired target MetricDefinition. Also, all the required Metric parameters as specified in the MetricDefinition must be present.

Parameters:
definition - The MetricDefinition to create an instance of
metricParameters - The Metric parameters, a Map, for the desired MetricDefinition.

Metric

public Metric(MetricDefinition definition,
              Map<String,Object> metricParameters,
              long frequency)
Constructs a Metric instance from the passed Metric name and concrete values for the Metric parameters. This constructor is used for CONTINUOUS metrics. Hence, the frequency must be specified.

The passed Metric name must be equal, as determined by String.equals(Object), to the Metric name in the desired target MetricDefinition. In addition, the passed concrete values for the Metric parameters must be of the same name and type as the Metric parameters in the desired target MetricDefinition. Also, all the required Metric parameters as specified in the MetricDefinition must be present.

Parameters:
definition - The MetricDefinition to create an instance of
metricParameters - The Metric parameters, a Map, for the desired MetricDefinition
frequency - The measuring frequency.
Method Detail

equals

public boolean equals(Object object)
Tests this Metric for equality with the passed Object.

If the given object is not a Metric, then this method immediately returns false.

For two Metric instances to be considered as equal they must have equal descriptors, parameters and frequency.

Overrides:
equals in class Object
Parameters:
object - The Object to test for equality
Returns:
A boolean indicating equality

getMetricParameters

public Map<String,Object> getMetricParameters()
Gets the Metric parameters associated with this Metric.

Returns:
The Metric parameters, a Map

getFrequency

public long getFrequency()
Gets the measurement frequency in milliseconds.

Returns:
the measurement frequency in milliseconds.

getMetricParameterByName

public Object getMetricParameterByName(String name)
Gets the Metric parameter value associated with the passed Metric parameter name. The value null is returned if there is no Metric parameter value with the passed name.

Parameters:
name - The Metric parameter name, a String, for which to obtain the associated Metric
Returns:
The Metric parameter value, an Object, associated with the passed Metric parameter name.

getDefinition

public MetricDefinition getDefinition()
Gets the MetricDefinition.

Returns:
the MetricDefinition

toString

public String toString()
Overrides:
toString in class Object