|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.metrics2.lib.DynamicMetricsRegistry
public class DynamicMetricsRegistry
An optional metrics registry class for creating and maintaining a collection of MetricsMutables, making writing metrics source easier. NOTE: this is a copy of org.apache.hadoop.metrics2.lib.MetricsRegistry with added one feature: metrics can be removed. When HADOOP-8313 is fixed, usages of this class should be substituted with org.apache.hadoop.metrics2.lib.MetricsRegistry. This implementation also provides handy methods for creating metrics dynamically. Another difference is that metricsMap & tagsMap implementation is substituted with concurrent map, as we allow dynamic metrics additions/removals.
| Field Summary | |
|---|---|
static String |
CONTEXT_DESC
description for the context tag |
static String |
CONTEXT_KEY
key for the context tag |
| Constructor Summary | |
|---|---|
DynamicMetricsRegistry(String name)
Construct the registry with a record name |
|
DynamicMetricsRegistry(String name,
org.apache.hadoop.metrics2.lib.MetricMutableFactory factory)
Construct the registry with a name and a metric factory |
|
| Method Summary | |
|---|---|
void |
clearMetrics()
|
org.apache.hadoop.metrics2.lib.MetricMutable |
get(String name)
Get a metric by name |
MetricMutableHistogram |
getHistogram(String histoName)
|
org.apache.hadoop.metrics2.lib.MetricMutableCounterLong |
getLongCounter(String counterName,
long potentialStartingValue)
Get a MetricMutableCounterLong from the storage. |
org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong |
getLongGauge(String gaugeName,
long potentialStartingValue)
Get a MetricMutableGaugeLong from the storage. |
MetricMutableQuantiles |
getQuantile(String histoName)
|
Set<Map.Entry<String,org.apache.hadoop.metrics2.lib.MetricMutable>> |
metrics()
Get the metrics |
String |
name()
|
org.apache.hadoop.metrics2.lib.MetricMutableCounterInt |
newCounter(String name,
String description,
int initValue)
Create a mutable integer counter |
org.apache.hadoop.metrics2.lib.MetricMutableCounterLong |
newCounter(String name,
String description,
long initValue)
Create a mutable long integer counter |
org.apache.hadoop.metrics2.lib.MetricMutableGaugeInt |
newGauge(String name,
String description,
int initValue)
Create a mutable integer gauge |
org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong |
newGauge(String name,
String description,
long initValue)
Create a mutable long integer gauge |
MetricMutableHistogram |
newHistogram(String name)
Create a new histogram. |
MetricMutableHistogram |
newHistogram(String name,
String desc)
Create a new histogram. |
MetricMutableQuantiles |
newQuantile(String name)
Create a new MutableQuantile(A more accurate histogram). |
MetricMutableQuantiles |
newQuantile(String name,
String desc)
Create a new MutableQuantile(A more accurate histogram). |
MetricMutableSizeHistogram |
newSizeHistogram(String name)
Create a new histogram with size range counts. |
MetricMutableSizeHistogram |
newSizeHistogram(String name,
String desc)
Create a new histogram with size range counts. |
org.apache.hadoop.metrics2.lib.MetricMutableStat |
newStat(String name)
Create a mutable metric with stats using the name only |
org.apache.hadoop.metrics2.lib.MetricMutableStat |
newStat(String name,
String description,
String sampleName,
String valueName)
Create a mutable metric with stats |
org.apache.hadoop.metrics2.lib.MetricMutableStat |
newStat(String name,
String description,
String sampleName,
String valueName,
boolean extended)
Create a mutable metric with stats |
MetricMutableTimeHistogram |
newTimeHistogram(String name)
Create a new histogram with time range counts. |
MetricMutableTimeHistogram |
newTimeHistogram(String name,
String desc)
Create a new histogram with time range counts. |
void |
removeMetric(String name)
Removes metric by name |
DynamicMetricsRegistry |
setContext(String name)
Set the metrics context tag |
void |
snapshot(MetricsRecordBuilder builder,
boolean all)
Sample all the mutable metrics and put the snapshot in the builder |
DynamicMetricsRegistry |
tag(String name,
String description,
String value)
Add a tag to the metrics |
DynamicMetricsRegistry |
tag(String name,
String description,
String value,
boolean override)
Add a tag to the metrics |
Set<Map.Entry<String,MetricsTag>> |
tags()
Get the tags |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String CONTEXT_KEY
public static final String CONTEXT_DESC
| Constructor Detail |
|---|
public DynamicMetricsRegistry(String name)
name - of the record of the metrics
public DynamicMetricsRegistry(String name,
org.apache.hadoop.metrics2.lib.MetricMutableFactory factory)
name - of the record of the metricsfactory - for creating new mutable metrics| Method Detail |
|---|
public String name()
public org.apache.hadoop.metrics2.lib.MetricMutable get(String name)
name - of the metric
public org.apache.hadoop.metrics2.lib.MetricMutableCounterInt newCounter(String name,
String description,
int initValue)
name - of the metricdescription - of the metricinitValue - of the metric
public org.apache.hadoop.metrics2.lib.MetricMutableCounterLong newCounter(String name,
String description,
long initValue)
name - of the metricdescription - of the metricinitValue - of the metric
public org.apache.hadoop.metrics2.lib.MetricMutableGaugeInt newGauge(String name,
String description,
int initValue)
name - of the metricdescription - of the metricinitValue - of the metric
public org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong newGauge(String name,
String description,
long initValue)
name - of the metricdescription - of the metricinitValue - of the metric
public org.apache.hadoop.metrics2.lib.MetricMutableStat newStat(String name,
String description,
String sampleName,
String valueName,
boolean extended)
name - of the metricdescription - of the metricsampleName - of the metric (e.g., "ops")valueName - of the metric (e.g., "time" or "latency")extended - produce extended stat (stdev, min/max etc.) if true.
public org.apache.hadoop.metrics2.lib.MetricMutableStat newStat(String name,
String description,
String sampleName,
String valueName)
name - of the metricdescription - of the metricsampleName - of the metric (e.g., "ops")valueName - of the metric (e.g., "time" or "latency")
public org.apache.hadoop.metrics2.lib.MetricMutableStat newStat(String name)
name - of the metric
public MetricMutableHistogram newHistogram(String name)
name - Name of the histogram.
public MetricMutableHistogram newHistogram(String name,
String desc)
name - The name of the histogramdesc - The description of the data in the histogram.
public MetricMutableTimeHistogram newTimeHistogram(String name)
name - Name of the histogram.
public MetricMutableTimeHistogram newTimeHistogram(String name,
String desc)
name - The name of the histogramdesc - The description of the data in the histogram.
public MetricMutableSizeHistogram newSizeHistogram(String name)
name - Name of the histogram.
public MetricMutableSizeHistogram newSizeHistogram(String name,
String desc)
name - The name of the histogramdesc - The description of the data in the histogram.
public MetricMutableQuantiles newQuantile(String name)
name - The name of the histogram
public MetricMutableQuantiles newQuantile(String name,
String desc)
name - The name of the histogramdesc - Description of the data.
public DynamicMetricsRegistry setContext(String name)
name - of the context
public DynamicMetricsRegistry tag(String name,
String description,
String value)
name - of the tagdescription - of the tagvalue - of the tag
public DynamicMetricsRegistry tag(String name,
String description,
String value,
boolean override)
name - of the tagdescription - of the tagvalue - of the tagoverride - existing tag if true
public Set<Map.Entry<String,MetricsTag>> tags()
public Set<Map.Entry<String,org.apache.hadoop.metrics2.lib.MetricMutable>> metrics()
public void snapshot(MetricsRecordBuilder builder,
boolean all)
builder - to contain the metrics snapshotall - get all the metrics even if the values are not changed.public void removeMetric(String name)
name - name of the metric to remove
public org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong getLongGauge(String gaugeName,
long potentialStartingValue)
gaugeName - name of the gauge to create or get.potentialStartingValue - value of the new counter if we have to create it.
public org.apache.hadoop.metrics2.lib.MetricMutableCounterLong getLongCounter(String counterName,
long potentialStartingValue)
counterName - Name of the counter to getpotentialStartingValue - starting value if we have to create a new counter
public MetricMutableHistogram getHistogram(String histoName)
public MetricMutableQuantiles getQuantile(String histoName)
public void clearMetrics()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||