use of org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer in project flink by apache.
the class WatermarksWithIdlenessTest method testIdleWithoutEvents.
@Test
public void testIdleWithoutEvents() {
final ManualClock clock = new ManualClock(System.nanoTime());
final IdlenessTimer timer = new IdlenessTimer(clock, Duration.ofMillis(10));
// start timer
timer.checkIfIdle();
clock.advanceTime(11, MILLISECONDS);
assertTrue(timer.checkIfIdle());
}
use of org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer in project flink by apache.
the class WatermarksWithIdlenessTest method createTimerAndMakeIdle.
private static IdlenessTimer createTimerAndMakeIdle(ManualClock clock, Duration idleTimeout) {
final IdlenessTimer timer = new IdlenessTimer(clock, idleTimeout);
// start timer
timer.checkIfIdle();
clock.advanceTime(Duration.ofMillis(idleTimeout.toMillis() + 1));
// rigger timer
assertTrue(timer.checkIfIdle());
return timer;
}
use of org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer in project flink by apache.
the class WatermarksWithIdlenessTest method testInitiallyActive.
@Test
public void testInitiallyActive() {
final ManualClock clock = new ManualClock(System.nanoTime());
final IdlenessTimer timer = new IdlenessTimer(clock, Duration.ofMillis(10));
assertFalse(timer.checkIfIdle());
}
use of org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer in project flink by apache.
the class WatermarksWithIdlenessTest method testRepeatedIdleChecks.
@Test
public void testRepeatedIdleChecks() {
final ManualClock clock = new ManualClock(System.nanoTime());
final IdlenessTimer timer = createTimerAndMakeIdle(clock, Duration.ofMillis(122));
assertTrue(timer.checkIfIdle());
clock.advanceTime(100, MILLISECONDS);
assertTrue(timer.checkIfIdle());
}
use of org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer 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());
}
Aggregations