Class MetricListener
- java.lang.Object
-
- org.apache.flink.metrics.testutils.MetricListener
-
public class MetricListener extends Object
A MetricListener listens metric and group registration under the provided root metric group, and stores them in an internal HashMap for fetching.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDELIMITERstatic StringROOT_METRIC_GROUP_NAME
-
Constructor Summary
Constructors Constructor Description MetricListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<org.apache.flink.metrics.Counter>getCounter(String... identifier)Get registeredCounterwith identifier relative to the root metric group.<T> Optional<org.apache.flink.metrics.Gauge<T>>getGauge(String... identifier)Get registeredGaugewith identifier relative to the root metric group.Optional<org.apache.flink.metrics.Histogram>getHistogram(String... identifier)Get registeredHistogramwith identifier relative to the root metric group.Optional<org.apache.flink.metrics.Meter>getMeter(String... identifier)Get registeredMeterwith identifier relative to the root metric group.<T extends org.apache.flink.metrics.Metric>
Optional<T>getMetric(Class<T> metricType, String... identifier)Get registeredMetricwith identifier relative to the root metric group.org.apache.flink.metrics.MetricGroupgetMetricGroup()Get the root metric group of this listener.
-
-
-
Field Detail
-
DELIMITER
public static final String DELIMITER
- See Also:
- Constant Field Values
-
ROOT_METRIC_GROUP_NAME
public static final String ROOT_METRIC_GROUP_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getMetricGroup
public org.apache.flink.metrics.MetricGroup getMetricGroup()
Get the root metric group of this listener. Note that only metrics and groups registered under this group will be listened.- Returns:
- Root metric group
-
getMetric
public <T extends org.apache.flink.metrics.Metric> Optional<T> getMetric(Class<T> metricType, String... identifier)
Get registeredMetricwith identifier relative to the root metric group.For example, identifier of metric "myMetric" registered in group "myGroup" under root metric group can be reached by identifier ("myGroup", "myMetric")
- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered metric
-
getMeter
public Optional<org.apache.flink.metrics.Meter> getMeter(String... identifier)
Get registeredMeterwith identifier relative to the root metric group.- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered meter
-
getCounter
public Optional<org.apache.flink.metrics.Counter> getCounter(String... identifier)
Get registeredCounterwith identifier relative to the root metric group.- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered counter
-
getHistogram
public Optional<org.apache.flink.metrics.Histogram> getHistogram(String... identifier)
Get registeredHistogramwith identifier relative to the root metric group.- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered histogram
-
-