org.apache.hadoop.metrics2
usage.请参阅: 说明
接口 | 说明 |
---|---|
MetricsContext | 已过时
in favor of
org.apache.hadoop.metrics2 usage. |
MetricsRecord | 已过时
in favor of
org.apache.hadoop.metrics2 usage. |
Updater | 已过时
in favor of
org.apache.hadoop.metrics2 usage. |
类 | 说明 |
---|---|
ContextFactory | 已过时
in favor of
org.apache.hadoop.metrics2 usage. |
MetricsServlet | 已过时
in favor of
org.apache.hadoop.metrics2 usage. |
MetricsUtil | 已过时
in favor of
org.apache.hadoop.metrics2 usage. |
异常错误 | 说明 |
---|---|
MetricsException | 已过时
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.spi
org.apache.hadoop.metrics.file
org.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
ContextFactory
methods:
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.Copyright © 2009 The Apache Software Foundation