use of org.apache.flink.runtime.executiongraph.restart.InfiniteDelayRestartStrategy in project flink by apache.
the class ExecutionGraphRestartTest method testFailWhileRestarting.
@Test
public void testFailWhileRestarting() throws Exception {
Scheduler scheduler = new Scheduler(TestingUtils.defaultExecutionContext());
Instance instance = ExecutionGraphTestUtils.getInstance(new ActorTaskManagerGateway(new SimpleActorGateway(TestingUtils.directExecutionContext())), NUM_TASKS);
scheduler.newInstanceAvailable(instance);
// Blocking program
ExecutionGraph executionGraph = new ExecutionGraph(TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), new JobID(), "TestJob", new Configuration(), new SerializedValue<>(new ExecutionConfig()), AkkaUtils.getDefaultTimeout(), // We want to manually control the restart and delay
new InfiniteDelayRestartStrategy(), scheduler);
JobVertex jobVertex = new JobVertex("NoOpInvokable");
jobVertex.setInvokableClass(NoOpInvokable.class);
jobVertex.setParallelism(NUM_TASKS);
JobGraph jobGraph = new JobGraph("TestJob", jobVertex);
executionGraph.attachJobGraph(jobGraph.getVerticesSortedTopologicallyFromSources());
assertEquals(JobStatus.CREATED, executionGraph.getState());
executionGraph.scheduleForExecution();
assertEquals(JobStatus.RUNNING, executionGraph.getState());
// Kill the instance and wait for the job to restart
instance.markDead();
Deadline deadline = TestingUtils.TESTING_DURATION().fromNow();
while (deadline.hasTimeLeft() && executionGraph.getState() != JobStatus.RESTARTING) {
Thread.sleep(100);
}
assertEquals(JobStatus.RESTARTING, executionGraph.getState());
// The restarting should not fail with an ordinary exception
executionGraph.fail(new Exception("Test exception"));
assertEquals(JobStatus.RESTARTING, executionGraph.getState());
// but it should fail when sending a SuppressRestartsException
executionGraph.fail(new SuppressRestartsException(new Exception("Test exception")));
assertEquals(JobStatus.FAILED, executionGraph.getState());
// The restart has been aborted
executionGraph.restart();
assertEquals(JobStatus.FAILED, executionGraph.getState());
}
use of org.apache.flink.runtime.executiongraph.restart.InfiniteDelayRestartStrategy in project flink by apache.
the class ExecutionGraphSignalsTest method testSuspendWhileRestarting.
/**
* Tests that we can suspend a job when in state RESTARTING.
*/
@Test
public void testSuspendWhileRestarting() throws IllegalAccessException, NoSuchFieldException {
Field restartStrategyField = eg.getClass().getDeclaredField("restartStrategy");
restartStrategyField.setAccessible(true);
restartStrategyField.set(eg, new InfiniteDelayRestartStrategy());
f.set(eg, JobStatus.RESTARTING);
final Exception exception = new Exception("Suspended");
eg.suspend(exception);
assertEquals(JobStatus.SUSPENDED, eg.getState());
assertEquals(exception, eg.getFailureCause());
}
use of org.apache.flink.runtime.executiongraph.restart.InfiniteDelayRestartStrategy in project flink by apache.
the class ExecutionGraphSignalsTest method testSuppressRestartFailureWhileRestarting.
/**
* Tests that a {@link SuppressRestartsException} in state RESTARTING stops the restarting
* immediately and sets the execution graph's state to FAILED.
*/
@Test
public void testSuppressRestartFailureWhileRestarting() throws IllegalAccessException, NoSuchFieldException {
Field restartStrategyField = eg.getClass().getDeclaredField("restartStrategy");
restartStrategyField.setAccessible(true);
restartStrategyField.set(eg, new InfiniteDelayRestartStrategy());
f.set(eg, JobStatus.RESTARTING);
// suppress a possible restart
eg.fail(new SuppressRestartsException(new Exception("Test")));
assertEquals(JobStatus.FAILED, eg.getState());
}
Aggregations