|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.metrics.spi.AbstractMetricsContext
public abstract class AbstractMetricsContext
The main class of the Service Provider Interface. This class should be extended in order to integrate the Metrics API with a specific metrics client library.
This class implements the internal table of metric data, and the timer on which data is to be sent to the metrics system. Subclasses must override the abstractemitRecord
method in order to transmit
the data.
Field Summary |
---|
Fields inherited from interface org.apache.hadoop.metrics.MetricsContext |
---|
DEFAULT_PERIOD |
Constructor Summary | |
---|---|
protected |
AbstractMetricsContext()
Creates a new instance of AbstractMetricsContext |
Method Summary | |
---|---|
void |
close()
Stops monitoring and frees buffered data, returning this object to its initial state. |
MetricsRecord |
createRecord(String recordName)
Creates a new AbstractMetricsRecord instance with the given recordName . |
protected abstract void |
emitRecord(String contextName,
String recordName,
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. |
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,
ContextFactory factory)
Initializes the context. |
boolean |
isMonitoring()
Returns true if monitoring is currently in progress. |
protected MetricsRecordImpl |
newRecord(String recordName)
Subclasses should override this if they subclass MetricsRecordImpl. |
void |
registerUpdater(Updater updater)
Registers a callback to be called at time intervals determined by the configuration. |
protected void |
remove(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(Updater updater)
Removes a callback, if it exists. |
protected void |
update(MetricsRecordImpl record)
Called by MetricsRecordImpl.update(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AbstractMetricsContext()
Method Detail |
---|
public void init(String contextName, ContextFactory factory)
protected String getAttribute(String attributeName)
protected Map<String,String> getAttributeTable(String tableName)
public String getContextName()
getContextName
in interface MetricsContext
public ContextFactory getContextFactory()
public void startMonitoring() throws IOException
startMonitoring
in interface MetricsContext
IOException
public void stopMonitoring()
stopMonitoring
in interface MetricsContext
close()
public boolean isMonitoring()
isMonitoring
in interface MetricsContext
public void close()
close
in interface MetricsContext
public final 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 MetricsContext
recordName
- the name of the record
MetricsException
- if recordName conflicts with configuration dataprotected MetricsRecordImpl newRecord(String recordName)
recordName
- the name of the record
public void registerUpdater(Updater updater)
registerUpdater
in interface MetricsContext
updater
- object to be run periodically; it should update
some metrics recordspublic void unregisterUpdater(Updater updater)
unregisterUpdater
in interface MetricsContext
updater
- object to be removed from the callback listprotected abstract void emitRecord(String contextName, String recordName, OutputRecord outRec) throws IOException
IOException
protected void flush() throws IOException
IOException
protected void update(MetricsRecordImpl record)
protected void remove(MetricsRecordImpl record)
public int getPeriod()
protected void setPeriod(int period)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |