Search in sources :

Example 1 with ManualClock

use of org.apache.flink.util.clock.ManualClock in project flink by apache.

the class CheckpointRequestDeciderTest method decider.

private CheckpointRequestDecider decider(int maxQueued, int maxPending, int minPause, AtomicInteger currentPending, AtomicInteger currentCleaning) {
    ManualClock clock = new ManualClock();
    clock.advanceTime(1, TimeUnit.DAYS);
    return new CheckpointRequestDecider(maxPending, NO_OP, clock, minPause, currentPending::get, currentCleaning::get, maxQueued);
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock)

Example 2 with ManualClock

use of org.apache.flink.util.clock.ManualClock 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 3 with ManualClock

use of org.apache.flink.util.clock.ManualClock 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 ManualClock

use of org.apache.flink.util.clock.ManualClock 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 ManualClock

use of org.apache.flink.util.clock.ManualClock in project flink by apache.

the class JobStatusMetricsTest method testCurrentTimeMetric.

@Test
void testCurrentTimeMetric() {
    final ManualClock clock = new ManualClock();
    final JobStatusMetrics jobStatusMetrics = new JobStatusMetrics(0L, enable(MetricOptions.JobStatusMetrics.STATE, MetricOptions.JobStatusMetrics.CURRENT_TIME, MetricOptions.JobStatusMetrics.TOTAL_TIME), clock);
    final StateTimeMetric metric = jobStatusMetrics.createTimeMetric(JobStatus.RUNNING);
    assertThat(metric.getCurrentTime()).isEqualTo(0L);
    jobStatusMetrics.jobStatusChanges(new JobID(), JobStatus.RUNNING, 1L);
    clock.advanceTime(Duration.ofMillis(11));
    assertThat(metric.getCurrentTime()).isEqualTo(10L);
    jobStatusMetrics.jobStatusChanges(new JobID(), JobStatus.RESTARTING, 15L);
    assertThat(metric.getCurrentTime()).isEqualTo(0L);
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) JobID(org.apache.flink.api.common.JobID) Test(org.junit.jupiter.api.Test)

Aggregations

ManualClock (org.apache.flink.util.clock.ManualClock)43 Test (org.junit.Test)30 Test (org.junit.jupiter.api.Test)10 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)7 IdlenessTimer (org.apache.flink.api.common.eventtime.WatermarksWithIdleness.IdlenessTimer)5 JobID (org.apache.flink.api.common.JobID)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 Time (org.apache.flink.api.common.time.Time)2 BufferOrEvent (org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent)2 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CheckpointRequestDeciderTest.regularCheckpoint (org.apache.flink.runtime.checkpoint.CheckpointRequestDeciderTest.regularCheckpoint)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 ManuallyTriggeredScheduledExecutor (org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor)1 Before (org.junit.Before)1