use of org.apache.flink.runtime.executiongraph.failover.flip1.TestRestartBackoffTimeStrategy in project flink by apache.
the class ExecutionGraphRestartTest method testFailExecutionAfterCancel.
/**
* Tests that a graph is not restarted after cancellation via a call to {@link
* Execution#fail(Throwable)}. This can happen when a slot is released concurrently with
* cancellation.
*/
@Test
public void testFailExecutionAfterCancel() throws Exception {
try (SlotPool slotPool = SlotPoolUtils.createDeclarativeSlotPoolBridge()) {
SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(createJobGraphToCancel(), mainThreadExecutor).setExecutionSlotAllocatorFactory(createExecutionSlotAllocatorFactory(slotPool)).setRestartBackoffTimeStrategy(new TestRestartBackoffTimeStrategy(false, Long.MAX_VALUE)).setDelayExecutor(taskRestartExecutor).build();
ExecutionGraph eg = scheduler.getExecutionGraph();
startScheduling(scheduler);
offerSlots(slotPool, 1);
// Fail right after cancel (for example with concurrent slot release)
scheduler.cancel();
for (ExecutionVertex v : eg.getAllExecutionVertices()) {
v.getCurrentExecutionAttempt().fail(new Exception("Test Exception"));
}
assertEquals(JobStatus.CANCELED, eg.getTerminationFuture().get());
Execution execution = eg.getAllExecutionVertices().iterator().next().getCurrentExecutionAttempt();
execution.completeCancelling();
assertEquals(JobStatus.CANCELED, eg.getState());
}
}
use of org.apache.flink.runtime.executiongraph.failover.flip1.TestRestartBackoffTimeStrategy in project flink by apache.
the class ExecutionGraphSuspendTest method testSuspendWhileRestarting.
/**
* Tests that we can suspend a job when in state RESTARTING.
*/
@Test
public void testSuspendWhileRestarting() throws Exception {
final ManuallyTriggeredScheduledExecutor taskRestartExecutor = new ManuallyTriggeredScheduledExecutor();
final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(JobGraphTestUtils.emptyJobGraph(), ComponentMainThreadExecutorServiceAdapter.forMainThread()).setRestartBackoffTimeStrategy(new TestRestartBackoffTimeStrategy(true, Long.MAX_VALUE)).setDelayExecutor(taskRestartExecutor).build();
scheduler.startScheduling();
final ExecutionGraph eg = scheduler.getExecutionGraph();
assertEquals(JobStatus.RUNNING, eg.getState());
ExecutionGraphTestUtils.switchAllVerticesToRunning(eg);
scheduler.handleGlobalFailure(new Exception("test"));
assertEquals(JobStatus.RESTARTING, eg.getState());
ExecutionGraphTestUtils.completeCancellingForAllVertices(eg);
assertEquals(JobStatus.RESTARTING, eg.getState());
scheduler.closeAsync();
assertEquals(JobStatus.SUSPENDED, eg.getState());
taskRestartExecutor.triggerScheduledTasks();
assertEquals(JobStatus.SUSPENDED, eg.getState());
}
use of org.apache.flink.runtime.executiongraph.failover.flip1.TestRestartBackoffTimeStrategy in project flink by apache.
the class AdaptiveSchedulerTest method testHowToHandleFailureAllowedByStrategy.
@Test
public void testHowToHandleFailureAllowedByStrategy() throws Exception {
final TestRestartBackoffTimeStrategy restartBackoffTimeStrategy = new TestRestartBackoffTimeStrategy(true, 1234);
final AdaptiveScheduler scheduler = new AdaptiveSchedulerBuilder(createJobGraph(), mainThreadExecutor).setRestartBackoffTimeStrategy(restartBackoffTimeStrategy).build();
final FailureResult failureResult = scheduler.howToHandleFailure(new Exception("test"));
assertThat(failureResult.canRestart()).isTrue();
assertThat(failureResult.getBackoffTime().toMillis()).isEqualTo(restartBackoffTimeStrategy.getBackoffTime());
}
Aggregations