public abstract class AbstractMetricGroup extends Object implements org.apache.flink.metrics.MetricGroup
MetricGroup that contains key functionality for adding metrics and groups.
IMPORTANT IMPLEMENTATION NOTE
This class uses locks for adding and removing metrics objects. This is done to prevent resource leaks in the presence of concurrently closing a group and adding metrics and subgroups. Since closing groups recursively closes the subgroups, the lock acquisition order must be strictly from parent group to subgroup. If at any point, a subgroup holds its group lock and calls a parent method that also acquires the lock, it will create a deadlock condition.
An AbstractMetricGroup can be closed. Upon closing, the group de-register all metrics
from any metrics reporter and any internal maps. Note that even closed metrics groups
return Counters, Gauges, etc to the code, to prevent exceptions in the monitored code.
These metrics simply do not get reported any more, when created on a closed group.
| Modifier and Type | Field and Description |
|---|---|
protected MetricRegistry |
registry
The registry that this metrics group belongs to
|
| Constructor and Description |
|---|
AbstractMetricGroup(MetricRegistry registry,
String[] scope) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.flink.metrics.MetricGroup |
addGroup(int name) |
org.apache.flink.metrics.MetricGroup |
addGroup(String name) |
protected void |
addMetric(String name,
org.apache.flink.metrics.Metric metric)
Adds the given metric to the group and registers it at the registry, if the group
is not yet closed, and if no metric with the same name has been registered before.
|
void |
close() |
org.apache.flink.metrics.Counter |
counter(int name) |
<C extends org.apache.flink.metrics.Counter> |
counter(int name,
C counter) |
org.apache.flink.metrics.Counter |
counter(String name) |
<C extends org.apache.flink.metrics.Counter> |
counter(String name,
C counter) |
<T,G extends org.apache.flink.metrics.Gauge<T>> |
gauge(int name,
G gauge) |
<T,G extends org.apache.flink.metrics.Gauge<T>> |
gauge(String name,
G gauge) |
String |
getMetricIdentifier(String metricName)
Returns the fully qualified metric name, for example
"host-7.taskmanager-2.window_word_count.my-mapper.metricName" |
String |
getMetricIdentifier(String metricName,
org.apache.flink.metrics.CharacterFilter filter)
Returns the fully qualified metric name, for example
"host-7.taskmanager-2.window_word_count.my-mapper.metricName" |
String[] |
getScopeComponents()
Gets the scope as an array of the scope components, for example
["host-7", "taskmanager-2", "window_word_count", "my-mapper"] |
<H extends org.apache.flink.metrics.Histogram> |
histogram(int name,
H histogram) |
<H extends org.apache.flink.metrics.Histogram> |
histogram(String name,
H histogram) |
boolean |
isClosed() |
protected final MetricRegistry registry
public AbstractMetricGroup(MetricRegistry registry, String[] scope)
public String[] getScopeComponents()
["host-7", "taskmanager-2", "window_word_count", "my-mapper"]getScopeComponents in interface org.apache.flink.metrics.MetricGroupgetMetricIdentifier(String)public String getMetricIdentifier(String metricName)
"host-7.taskmanager-2.window_word_count.my-mapper.metricName"getMetricIdentifier in interface org.apache.flink.metrics.MetricGroupmetricName - metric namepublic String getMetricIdentifier(String metricName, org.apache.flink.metrics.CharacterFilter filter)
"host-7.taskmanager-2.window_word_count.my-mapper.metricName"getMetricIdentifier in interface org.apache.flink.metrics.MetricGroupmetricName - metric namefilter - character filter which is applied to the scope components if not null.public void close()
public final boolean isClosed()
public org.apache.flink.metrics.Counter counter(int name)
counter in interface org.apache.flink.metrics.MetricGrouppublic org.apache.flink.metrics.Counter counter(String name)
counter in interface org.apache.flink.metrics.MetricGrouppublic <C extends org.apache.flink.metrics.Counter> C counter(int name,
C counter)
counter in interface org.apache.flink.metrics.MetricGrouppublic <C extends org.apache.flink.metrics.Counter> C counter(String name, C counter)
counter in interface org.apache.flink.metrics.MetricGrouppublic <T,G extends org.apache.flink.metrics.Gauge<T>> G gauge(int name,
G gauge)
gauge in interface org.apache.flink.metrics.MetricGrouppublic <T,G extends org.apache.flink.metrics.Gauge<T>> G gauge(String name, G gauge)
gauge in interface org.apache.flink.metrics.MetricGrouppublic <H extends org.apache.flink.metrics.Histogram> H histogram(int name,
H histogram)
histogram in interface org.apache.flink.metrics.MetricGrouppublic <H extends org.apache.flink.metrics.Histogram> H histogram(String name, H histogram)
histogram in interface org.apache.flink.metrics.MetricGroupprotected void addMetric(String name, org.apache.flink.metrics.Metric metric)
name - the name to register the metric undermetric - the metric to registerpublic org.apache.flink.metrics.MetricGroup addGroup(int name)
addGroup in interface org.apache.flink.metrics.MetricGrouppublic org.apache.flink.metrics.MetricGroup addGroup(String name)
addGroup in interface org.apache.flink.metrics.MetricGroupCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.