use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class ThroughputCalculatorTest method testCalculationDuringIdleTime.
@Test
public void testCalculationDuringIdleTime() {
ManualClock clock = new ManualClock();
ThroughputCalculator throughputCalculator = new ThroughputCalculator(clock);
throughputCalculator.incomingDataSize(10);
clock.advanceTime(Duration.ofMillis(1));
throughputCalculator.pauseMeasurement();
// This will be ignored because it is in idle now.
clock.advanceTime(Duration.ofMillis(9));
assertThat(throughputCalculator.calculateThroughput(), is(10L * 1_000));
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class ThroughputCalculatorTest method testIgnoringIdleTime.
@Test
public void testIgnoringIdleTime() {
ManualClock clock = new ManualClock();
ThroughputCalculator throughputCalculator = new ThroughputCalculator(clock);
throughputCalculator.incomingDataSize(7);
clock.advanceTime(Duration.ofMillis(1));
throughputCalculator.pauseMeasurement();
// This will be ignored because it is in idle now.
clock.advanceTime(Duration.ofMillis(9));
// This should resume the measurement time.
throughputCalculator.incomingDataSize(3);
clock.advanceTime(Duration.ofMillis(1));
assertThat(throughputCalculator.calculateThroughput(), is(5L * 1_000));
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class ThroughputCalculatorTest method testCorrectThroughputCalculation.
@Test
public void testCorrectThroughputCalculation() {
ManualClock clock = new ManualClock();
ThroughputCalculator throughputCalculator = new ThroughputCalculator(clock);
throughputCalculator.incomingDataSize(6666);
clock.advanceTime(Duration.ofMillis(1));
throughputCalculator.incomingDataSize(3333);
clock.advanceTime(Duration.ofMillis(33));
throughputCalculator.incomingDataSize(1);
clock.advanceTime(Duration.ofMillis(66));
assertThat(throughputCalculator.calculateThroughput(), is(10_000L * 1_000 / 100));
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class WatermarksWithIdlenessTest method testIdleActiveIdle.
@Test
public void testIdleActiveIdle() {
final ManualClock clock = new ManualClock(System.nanoTime());
final IdlenessTimer timer = createTimerAndMakeIdle(clock, Duration.ofMillis(122));
// active again
timer.activity();
assertFalse(timer.checkIfIdle());
// idle again
// start timer
timer.checkIfIdle();
clock.advanceTime(Duration.ofMillis(123));
assertTrue(timer.checkIfIdle());
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class WatermarksWithIdlenessTest method testActiveAfterIdleness.
@Test
public void testActiveAfterIdleness() {
final ManualClock clock = new ManualClock(System.nanoTime());
final IdlenessTimer timer = createTimerAndMakeIdle(clock, Duration.ofMillis(10));
timer.activity();
assertFalse(timer.checkIfIdle());
}
Aggregations