Java Code Examples for org.apache.flink.metrics.SimpleCounter#inc()

The following examples show how to use org.apache.flink.metrics.SimpleCounter#inc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricFetcherTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 2
Source File: MetricFetcherTest.java    From flink with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 3
Source File: MetricFetcherTest.java    From flink with Apache License 2.0 4 votes vote down vote up
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;
}