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());
}
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());
}
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));
}
}
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);
}
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));
}
Aggregations