@InterfaceAudience.Public @InterfaceStability.Evolving 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,
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.
|
Map<String,Collection<OutputRecord>> |
getAllRecords()
Retrieves all the records managed by this MetricsContext.
|
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.
|
protected void |
parseAndSetPeriod(String attributeName)
If a period is set in the attribute passed in, override
the default with it.
|
void |
registerUpdater(org.apache.hadoop.metrics.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(org.apache.hadoop.metrics.Updater updater)
Removes a callback, if it exists.
|
protected void |
update(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.MetricsContext
contextName
- The given name for this contextfactory
- The creator of this contextprotected String getAttribute(String attributeName)
protected Map<String,String> getAttributeTable(String tableName)
public String getContextName()
getContextName
in interface org.apache.hadoop.metrics.MetricsContext
public org.apache.hadoop.metrics.ContextFactory getContextFactory()
public void startMonitoring() throws IOException
startMonitoring
in interface org.apache.hadoop.metrics.MetricsContext
IOException
public void stopMonitoring()
stopMonitoring
in interface org.apache.hadoop.metrics.MetricsContext
close()
public boolean isMonitoring()
isMonitoring
in interface org.apache.hadoop.metrics.MetricsContext
public void close()
close
in interface org.apache.hadoop.metrics.MetricsContext
public 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.MetricsContext
recordName
- 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.MetricsContext
updater
- 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.MetricsContext
updater
- object to be removed from the callback listpublic Map<String,Collection<OutputRecord>> getAllRecords()
getAllRecords
in interface org.apache.hadoop.metrics.MetricsContext
protected 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()
getPeriod
in interface org.apache.hadoop.metrics.MetricsContext
protected void setPeriod(int period)
protected void parseAndSetPeriod(String attributeName)
Copyright © 2018 Apache Software Foundation. All rights reserved.