Search in sources :

Example 31 with SimpleCounter

use of org.apache.flink.metrics.SimpleCounter in project flink by apache.

the class MetricFetcherTest method createRequestDumpAnswer.

private static MetricDumpSerialization.MetricSerializationResult createRequestDumpAnswer(ResourceID tmRID, JobID jobID) {
    Map<Counter, Tuple2<QueryScopeInfo, String>> counters = new HashMap<>();
    Map<Gauge<?>, Tuple2<QueryScopeInfo, String>> gauges = new HashMap<>();
    Map<Histogram, Tuple2<QueryScopeInfo, String>> histograms = new HashMap<>();
    Map<Meter, Tuple2<QueryScopeInfo, String>> meters = new HashMap<>();
    SimpleCounter c1 = new SimpleCounter();
    SimpleCounter c2 = new SimpleCounter();
    c1.inc(1);
    c2.inc(2);
    counters.put(c1, new Tuple2<>(new QueryScopeInfo.OperatorQueryScopeInfo(jobID.toString(), "taskid", 2, "opname", "abc"), "oc"));
    counters.put(c2, new Tuple2<>(new QueryScopeInfo.TaskQueryScopeInfo(jobID.toString(), "taskid", 2, "abc"), "tc"));
    meters.put(new Meter() {

        @Override
        public void markEvent() {
        }

        @Override
        public void markEvent(long n) {
        }

        @Override
        public double getRate() {
            return 5;
        }

        @Override
        public long getCount() {
            return 10;
        }
    }, new Tuple2<>(new QueryScopeInfo.JobQueryScopeInfo(jobID.toString(), "abc"), "jc"));
    gauges.put(new Gauge<String>() {

        @Override
        public String getValue() {
            return "x";
        }
    }, new Tuple2<>(new QueryScopeInfo.TaskManagerQueryScopeInfo(tmRID.toString(), "abc"), "gauge"));
    histograms.put(new TestHistogram(), new Tuple2<>(new QueryScopeInfo.JobManagerQueryScopeInfo("abc"), "hist"));
    MetricDumpSerialization.MetricDumpSerializer serializer = new MetricDumpSerialization.MetricDumpSerializer();
    MetricDumpSerialization.MetricSerializationResult dump = serializer.serialize(counters, gauges, histograms, meters);
    serializer.close();
    return dump;
}
Also used : Histogram(org.apache.flink.metrics.Histogram) TestHistogram(org.apache.flink.metrics.util.TestHistogram) HashMap(java.util.HashMap) Meter(org.apache.flink.metrics.Meter) TestHistogram(org.apache.flink.metrics.util.TestHistogram) Gauge(org.apache.flink.metrics.Gauge) SimpleCounter(org.apache.flink.metrics.SimpleCounter) Counter(org.apache.flink.metrics.Counter) SimpleCounter(org.apache.flink.metrics.SimpleCounter) MetricDumpSerialization(org.apache.flink.runtime.metrics.dump.MetricDumpSerialization) Tuple2(org.apache.flink.api.java.tuple.Tuple2)

Aggregations

SimpleCounter (org.apache.flink.metrics.SimpleCounter)31 Counter (org.apache.flink.metrics.Counter)23 Test (org.junit.Test)13 Test (org.junit.jupiter.api.Test)12 Meter (org.apache.flink.metrics.Meter)8 Histogram (org.apache.flink.metrics.Histogram)7 TestHistogram (org.apache.flink.metrics.util.TestHistogram)7 Gauge (org.apache.flink.metrics.Gauge)6 TestMeter (org.apache.flink.metrics.util.TestMeter)5 MonitoringInfo (org.apache.beam.model.pipeline.v1.MetricsApi.MonitoringInfo)4 SimpleMonitoringInfoBuilder (org.apache.beam.runners.core.metrics.SimpleMonitoringInfoBuilder)4 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)4 MetricGroupTest (org.apache.flink.runtime.metrics.groups.MetricGroupTest)4 HashMap (java.util.HashMap)3 MetricGroup (org.apache.flink.metrics.MetricGroup)3 UnregisteredMetricsGroup (org.apache.flink.metrics.groups.UnregisteredMetricsGroup)3 TestMetricGroup (org.apache.flink.metrics.util.TestMetricGroup)3 List (java.util.List)2 Map (java.util.Map)2 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)2