Java Code Examples for org.apache.flink.metrics.Counter#dec()

The following examples show how to use org.apache.flink.metrics.Counter#dec() . 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: DCounterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetMetricValue() {
	final Counter backingCounter = new SimpleCounter();
	final DCounter counter = new DCounter(backingCounter, "counter", "localhost", Collections.emptyList(), () -> 0);

	// sane initial state
	assertEquals(0L, counter.getMetricValue());
	counter.ackReport();
	assertEquals(0L, counter.getMetricValue());

	// value is compared against initial state 0
	backingCounter.inc(10);
	assertEquals(10L, counter.getMetricValue());

	// last value was not acked, should still be compared against initial state 0
	backingCounter.inc(10);
	assertEquals(20L, counter.getMetricValue());

	// last value (20) acked, now target of comparison
	counter.ackReport();
	assertEquals(0L, counter.getMetricValue());

	// we now compare against the acked value
	backingCounter.inc(10);
	assertEquals(10L, counter.getMetricValue());

	// properly handle decrements
	backingCounter.dec(10);
	assertEquals(0L, counter.getMetricValue());
}
 
Example 2
Source File: InputChannelMetrics.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void dec() {
	for (Counter c : counters) {
		c.dec();
	}
}
 
Example 3
Source File: InputChannelMetrics.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void dec(long n) {
	for (Counter c : counters) {
		c.dec(n);
	}
}
 
Example 4
Source File: InputChannelMetrics.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void dec() {
	for (Counter c : counters) {
		c.dec();
	}
}
 
Example 5
Source File: InputChannelMetrics.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void dec(long n) {
	for (Counter c : counters) {
		c.dec(n);
	}
}