org.apache.hadoop.metrics
Class Metrics

java.lang.Object
  extended by org.apache.hadoop.metrics.Metrics

public class Metrics
extends Object

Utility class to simplify creation and reporting of hadoop metrics. For examples of usage, see DataNode.

Author:
Milind Bhandarkar
See Also:
MetricsRecord, MetricsContext, ContextFactory

Method Summary
static MetricsRecord createRecord(String contextName, String recordName)
          Utility method to create and return new metrics record instance within the given contextName.
static MetricsRecord createRecord(String contextName, String recordName, String tagName, String tagValue)
          Utility method to create and return a new tagged metrics record instance within the given contextName.
static void report(MetricsRecord record, String metricName, long metricValue)
          Sets the named metric to the specified value in the given metrics record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createRecord

public static MetricsRecord createRecord(String contextName,
                                         String recordName,
                                         String tagName,
                                         String tagValue)
Utility method to create and return a new tagged metrics record instance within the given contextName. If exception is thrown while creating the record for any reason, it is logged, and a null record is returned.

Parameters:
contextName - name of the context
recordName - the name of the record
tagName - name of the tag field of metrics record
tagValue - value of the tag field
Returns:
newly created metrics record

createRecord

public static MetricsRecord createRecord(String contextName,
                                         String recordName)
Utility method to create and return new metrics record instance within the given contextName. This record is tagged with hostname. If exception is thrown while creating the record due to any reason, it is logged, and a null record is returned.

Parameters:
contextName - name of the context
recordName - name of the record
Returns:
newly created metrics record

report

public static void report(MetricsRecord record,
                          String metricName,
                          long metricValue)
Sets the named metric to the specified value in the given metrics record. Updates the table of buffered data which is to be sent periodically.

Parameters:
record - record for which the metric is updated
metricName - name of the metric
metricValue - new value of the metric


Copyright © 2006 The Apache Software Foundation