org.gridlab.gat.monitoring
Class MetricDefinition

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

public class MetricDefinition
extends Object
implements Serializable

An instance of this class is a decription of a measurable quantity within a monitoring system. The GAT user can use this class to create metrics by supplying parameters. For continuous metrics, a frequency can also be provided. For instance, a MetricDefinition could describe a diskFree metric. By supplying the deviceName ("/dev/hda1") as a parameter to the createMetric method and "every 5 minutes" as the frequency, the user can create a metric. This metric is then used to interact with the 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 MetricDefinition definition contains the following information:

name The MetricDefinition name is used to identify the Metric definition (e.g. CPU usage). It consists of dot separated words, e.g. host.cpu.user. The last component of a MetricDefinition name is the actual name of the MetricDefinition, the preceding components are called scope. The scope can be used to group MetricDefinitions as well as to differentiate between similar MetricDefinitions defined at different levels (for example, CPU utilisation can be measured on a per-job or per-host level).

measurement type The MetricDefinition Measurement type can be continuous meaning data is always available or discrete meaning data only becomes available when some external event happens (e.g. a sensor embedded in an application can send events any time). Continuous MetricDefinitions are only available using pull model delivery unless the user specifies a measurement frequency. If the user asks for periodic measurements by specifying a measurement frequency the system will generate periodic events automatically. This avoids polling and allows the system to use the measurement frequency information to optimize measurements.

data type The MetricDefinition data type contains the definition of the storage used for representing measurement data.

unit The MetricDefinition unit specifies the physical unit in which the MetricDefinition is measured as a java.lang.String. It is only valid for simple numeric types and java.util.List's of these types. In the latter case it means the unit of all elements of the java.util.List.

See Also:
Serialized Form

Field Summary
static int CONTINUOUS
           
static int DISCRETE
           
 
Constructor Summary
MetricDefinition(String metricName, int measurementType, String dataType, String unit, Map<String,Object> parameterDefinitions, Map<String,Object> returnDefinition)
           
 
Method Summary
 Metric createMetric()
          Create a metric according to this definition.
 Metric createMetric(Map<String,Object> parameters)
          Create a metric according to this definition.
 Metric createMetric(Map<String,Object> parameters, long frequency)
          Create a metric according to this definition.
 boolean equals(Object o)
           
 String getDataType()
           
 int getMeasurementType()
           
 String getMetricName()
           
 Map<String,Object> getParameterDefinitions()
          returns a map of parameter names and types that are needed to retrieve this metric.
 Map<String,Object> getReturnDefinition()
          returns a map of return value names and types that are generated by this metric.
 String getUnit()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTINUOUS

public static final int CONTINUOUS
See Also:
Constant Field Values

DISCRETE

public static final int DISCRETE
See Also:
Constant Field Values
Constructor Detail

MetricDefinition

public MetricDefinition(String metricName,
                        int measurementType,
                        String dataType,
                        String unit,
                        Map<String,Object> parameterDefinitions,
                        Map<String,Object> returnDefinition)
Parameters:
metricName -
measurementType -
dataType -
unit -
Method Detail

createMetric

public Metric createMetric()
                    throws GATInvocationException
Create a metric according to this definition. This method is used for DISCRETE metrics, or CONTINUOUS metrics that are to be polled. Hence, there is no frequency specified. This method works only if there are no parameters needed for the metric

Returns:
the new Netric
Throws:
GATInvocationException

createMetric

public Metric createMetric(Map<String,Object> parameters)
Create a metric according to this definition. This method is used for DISCRETE metrics, or CONTINUOUS metrics that are to be polled. Hence, there is no frequency specified.

Parameters:
parameters - the parameters to this metricDefinition. For instance, when creating a diskFree metric, a parameter could be the physical device name. If no special parameters are needed, it is OK to pass null
Returns:
the new Netric

createMetric

public Metric createMetric(Map<String,Object> parameters,
                           long frequency)
Create a metric according to this definition. This method is used for CONTINUOUS metrics. Hence, there the frequency must be specified.

Parameters:
parameters - the parameters to this metricDefinition. For instance, when creating a diskFree metric, a parameter could be the physical device name. If no special parameters are needed, it is OK to pass null
Returns:
the new Metric

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getDataType

public String getDataType()
Returns:
Returns the dataType.

getMeasurementType

public int getMeasurementType()
Returns:
Returns the measurementType.

getMetricName

public String getMetricName()
Returns:
Returns the metricName.

getUnit

public String getUnit()
Returns:
Returns the unit.

getParameterDefinitions

public Map<String,Object> getParameterDefinitions()
returns a map of parameter names and types that are needed to retrieve this metric.

Returns:
the map

toString

public String toString()
Overrides:
toString in class Object

getReturnDefinition

public Map<String,Object> getReturnDefinition()
returns a map of return value names and types that are generated by this metric.

Returns:
the map