|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
org.apache.hadoop.metrics2 usage.
See:
Description
| Interface Summary | |
|---|---|
| MetricsContext | Deprecated. in favor of org.apache.hadoop.metrics2 usage. |
| MetricsRecord | Deprecated. in favor of org.apache.hadoop.metrics2 usage. |
| Updater | Deprecated. in favor of org.apache.hadoop.metrics2 usage. |
| Class Summary | |
|---|---|
| ContextFactory | Deprecated. in favor of org.apache.hadoop.metrics2 usage. |
| MetricsServlet | Deprecated. in favor of org.apache.hadoop.metrics2 usage. |
| MetricsUtil | Deprecated. in favor of org.apache.hadoop.metrics2 usage. |
| Exception Summary | |
|---|---|
| MetricsException | Deprecated. in favor of MetricsException. |
Note, this package is deprecated in favor of
org.apache.hadoop.metrics2 usage.
This package defines an API for reporting performance metric information.
The API is abstract so that it can be implemented on top of a variety of metrics client libraries. The choice of client library is a configuration option, and different modules within the same application can use different metrics implementation libraries.
Sub-packages:org.apache.hadoop.metrics.spiorg.apache.hadoop.metrics.fileorg.apache.hadoop.metrics.ganglia
private ContextFactory contextFactory = ContextFactory.getFactory();
void reportMyMetric(float myMetric) {
MetricsContext myContext = contextFactory.getContext("myContext");
MetricsRecord myRecord = myContext.getRecord("myRecord");
myRecord.setMetric("myMetric", myMetric);
myRecord.update();
}
In this example there are three names:
private MetricsRecord diskStats =
contextFactory.getContext("myContext").getRecord("diskStats");
void reportDiskMetrics(String diskName, float diskBusy, float diskUsed) {
diskStats.setTag("diskName", diskName);
diskStats.setMetric("diskBusy", diskBusy);
diskStats.setMetric("diskUsed", diskUsed);
diskStats.update();
}
MetricsRecord.update() is called. Instead it is stored in an
internal table, and the contents of the table are sent periodically.
This can be important for two reasons:
registerUpdater() method. The benefit of this
versus using java.util.Timer is that the callbacks will be done
immediately before sending the data, making the data as current as possible.
ContextFactory factory = ContextFactory.getFactory();
... examine and/or modify factory attributes ...
MetricsContext context = factory.getContext("myContext");
The factory attributes can be examined and modified using the following
ContextFactorymethods:
Object getAttribute(String attributeName)String[] getAttributeNames()void setAttribute(String name, Object value)void removeAttribute(attributeName)ContextFactory.getFactory() initializes the factory attributes by
reading the properties file hadoop-metrics.properties if it exists
on the class path.
A factory attribute named:
contextName.classshould have as its value the fully qualified name of the class to be instantiated by a call of the
CodeFactory method
getContext(contextName). If this factory attribute is not
specified, the default is to instantiate
org.apache.hadoop.metrics.file.FileContext.
Other factory attributes are specific to a particular implementation of this
API and are documented elsewhere. For example, configuration attributes for
the file and Ganglia implementations can be found in the javadoc for
their respective packages.
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||