Search in sources :

Example 26 with ManualClock

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

the class FailureRateRestartBackoffTimeStrategyTest method testManyFailuresWithinRate.

@Test
public void testManyFailuresWithinRate() {
    final int numFailures = 3;
    final long intervalMS = 1L;
    ManualClock clock = new ManualClock();
    final FailureRateRestartBackoffTimeStrategy restartStrategy = new FailureRateRestartBackoffTimeStrategy(clock, 1, intervalMS, 0);
    for (int failuresLeft = numFailures; failuresLeft > 0; failuresLeft--) {
        restartStrategy.notifyFailure(failure);
        assertTrue(restartStrategy.canRestart());
        clock.advanceTime(intervalMS + 1, TimeUnit.MILLISECONDS);
    }
    assertTrue(restartStrategy.canRestart());
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) Test(org.junit.Test)

Example 27 with ManualClock

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

the class FailureRateRestartBackoffTimeStrategyTest method testBackoffTime.

@Test
public void testBackoffTime() {
    final long backoffTimeMS = 10_000L;
    final FailureRateRestartBackoffTimeStrategy restartStrategy = new FailureRateRestartBackoffTimeStrategy(new ManualClock(), 1, 1, backoffTimeMS);
    assertEquals(backoffTimeMS, restartStrategy.getBackoffTime());
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) Test(org.junit.Test)

Example 28 with ManualClock

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

the class ExponentialDelayRestartBackoffTimeStrategyTest method testMaxBackoff.

@Test
public void testMaxBackoff() throws Exception {
    final long maxBackoffMS = 6L;
    final ExponentialDelayRestartBackoffTimeStrategy restartStrategy = new ExponentialDelayRestartBackoffTimeStrategy(new ManualClock(), 1L, maxBackoffMS, 2.0, 8L, 0.25);
    for (int i = 0; i < 10; i++) {
        restartStrategy.notifyFailure(failure);
        assertThat(restartStrategy.getBackoffTime(), lessThanOrEqualTo(maxBackoffMS));
    }
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) Test(org.junit.Test)

Example 29 with ManualClock

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

the class ExponentialDelayRestartBackoffTimeStrategyTest method testJitter.

@Test
public void testJitter() throws Exception {
    final long initialBackoffMS = 2L;
    final long maxBackoffMS = 7L;
    final ExponentialDelayRestartBackoffTimeStrategy restartStrategy = new ExponentialDelayRestartBackoffTimeStrategy(new ManualClock(), initialBackoffMS, maxBackoffMS, 2.0, 1L, 0.25);
    restartStrategy.notifyFailure(failure);
    assertCorrectRandomRange(restartStrategy::getBackoffTime, 3L, 4L, 5L);
    restartStrategy.notifyFailure(failure);
    assertCorrectRandomRange(restartStrategy::getBackoffTime, 6L, 7L);
    restartStrategy.notifyFailure(failure);
    assertCorrectRandomRange(restartStrategy::getBackoffTime, 6L, 7L);
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) Test(org.junit.Test)

Example 30 with ManualClock

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

the class ExponentialDelayRestartBackoffTimeStrategyTest method testBackoffMultiplier.

@Test
public void testBackoffMultiplier() throws Exception {
    long initialBackoffMS = 4L;
    double jitterFactor = 0;
    double backoffMultiplier = 2.3;
    long maxBackoffMS = 300L;
    final ExponentialDelayRestartBackoffTimeStrategy restartStrategy = new ExponentialDelayRestartBackoffTimeStrategy(new ManualClock(), initialBackoffMS, maxBackoffMS, backoffMultiplier, 8L, jitterFactor);
    restartStrategy.notifyFailure(failure);
    // 4 * 2.3
    assertThat(restartStrategy.getBackoffTime(), is(9L));
    restartStrategy.notifyFailure(failure);
    // 9 * 2.3
    assertThat(restartStrategy.getBackoffTime(), is(20L));
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) Test(org.junit.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