public abstract class AbstractMetricsContext extends Object implements org.apache.hadoop.metrics.MetricsContext
emitRecord method in order to transmit
 the data. | Modifier | Constructor and Description | 
|---|---|
| protected  | AbstractMetricsContext()Creates a new instance of AbstractMetricsContext | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Stops monitoring and frees buffered data, returning this
 object to its initial state. | 
| org.apache.hadoop.metrics.MetricsRecord | createRecord(String recordName)Creates a new AbstractMetricsRecord instance with the given  recordName. | 
| protected abstract void | emitRecord(String contextName,
          String recordName,
          org.apache.hadoop.metrics.spi.OutputRecord outRec)Sends a record to the metrics system. | 
| protected void | flush()Called each period after all records have been emitted, this method does nothing. | 
| protected String | getAttribute(String attributeName)Convenience method for subclasses to access factory attributes. | 
| protected Map<String,String> | getAttributeTable(String tableName)Returns an attribute-value map derived from the factory attributes
 by finding all factory attributes that begin with 
 contextName.tableName. | 
| org.apache.hadoop.metrics.ContextFactory | getContextFactory()Returns the factory by which this context was created. | 
| String | getContextName()Returns the context name. | 
| int | getPeriod()Returns the timer period. | 
| void | init(String contextName,
    org.apache.hadoop.metrics.ContextFactory factory)Initializes the context. | 
| boolean | isMonitoring()Returns true if monitoring is currently in progress. | 
| protected org.apache.hadoop.metrics.MetricsRecord | newRecord(String recordName)Subclasses should override this if they subclass MetricsRecordImpl. | 
| void | registerUpdater(org.apache.hadoop.metrics.Updater updater)Registers a callback to be called at time intervals determined by
 the configuration. | 
| protected void | remove(org.apache.hadoop.metrics.spi.MetricsRecordImpl record)Called by MetricsRecordImpl.remove(). | 
| protected void | setPeriod(int period)Sets the timer period | 
| void | startMonitoring()Starts or restarts monitoring, the emitting of metrics records. | 
| void | stopMonitoring()Stops monitoring. | 
| void | unregisterUpdater(org.apache.hadoop.metrics.Updater updater)Removes a callback, if it exists. | 
| protected void | update(org.apache.hadoop.metrics.spi.MetricsRecordImpl record)Called by MetricsRecordImpl.update(). | 
protected AbstractMetricsContext()
public void init(String contextName, org.apache.hadoop.metrics.ContextFactory factory)
init in interface org.apache.hadoop.metrics.MetricsContextprotected String getAttribute(String attributeName)
protected Map<String,String> getAttributeTable(String tableName)
public String getContextName()
getContextName in interface org.apache.hadoop.metrics.MetricsContextpublic org.apache.hadoop.metrics.ContextFactory getContextFactory()
public void startMonitoring()
                     throws IOException
startMonitoring in interface org.apache.hadoop.metrics.MetricsContextIOExceptionpublic void stopMonitoring()
stopMonitoring in interface org.apache.hadoop.metrics.MetricsContextclose()public boolean isMonitoring()
isMonitoring in interface org.apache.hadoop.metrics.MetricsContextpublic void close()
close in interface org.apache.hadoop.metrics.MetricsContextpublic final org.apache.hadoop.metrics.MetricsRecord createRecord(String recordName)
recordName.
 Throws an exception if the metrics implementation is configured with a fixed
 set of record names and recordName is not in that set.createRecord in interface org.apache.hadoop.metrics.MetricsContextrecordName - the name of the recordorg.apache.hadoop.metrics.MetricsException - if recordName conflicts with configuration dataprotected org.apache.hadoop.metrics.MetricsRecord newRecord(String recordName)
recordName - the name of the recordpublic void registerUpdater(org.apache.hadoop.metrics.Updater updater)
registerUpdater in interface org.apache.hadoop.metrics.MetricsContextupdater - object to be run periodically; it should update
 some metrics recordspublic void unregisterUpdater(org.apache.hadoop.metrics.Updater updater)
unregisterUpdater in interface org.apache.hadoop.metrics.MetricsContextupdater - object to be removed from the callback listprotected abstract void emitRecord(String contextName, String recordName, org.apache.hadoop.metrics.spi.OutputRecord outRec) throws IOException
IOExceptionprotected void flush()
              throws IOException
IOExceptionprotected void update(org.apache.hadoop.metrics.spi.MetricsRecordImpl record)
protected void remove(org.apache.hadoop.metrics.spi.MetricsRecordImpl record)
public int getPeriod()
getPeriod in interface org.apache.hadoop.metrics.MetricsContextprotected void setPeriod(int period)
Copyright © 2014 Apache Software Foundation. All Rights Reserved.