Search in sources :

Example 1 with IdlenessTimer

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());
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) IdlenessTimer(org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer) Test(org.junit.Test)

Example 2 with IdlenessTimer

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;
}
Also used : IdlenessTimer(org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer)

Example 3 with IdlenessTimer

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());
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) IdlenessTimer(org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer) Test(org.junit.Test)

Example 4 with IdlenessTimer

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());
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) IdlenessTimer(org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer) Test(org.junit.Test)

Example 5 with IdlenessTimer

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());
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) IdlenessTimer(org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer) Test(org.junit.Test)

Aggregations

IdlenessTimer (org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer)6 ManualClock (org.apache.flink.util.clock.ManualClock)5 Test (org.junit.Test)5