use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionGraphSuspendTest method testSuspendedOutOfCanceled.
/**
* Suspending from CANCELLED should do nothing.
*/
@Test
public void testSuspendedOutOfCanceled() throws Exception {
final InteractionsCountingTaskManagerGateway gateway = new InteractionsCountingTaskManagerGateway();
final int parallelism = 10;
final SchedulerBase scheduler = createScheduler(gateway, parallelism);
final ExecutionGraph eg = scheduler.getExecutionGraph();
scheduler.startScheduling();
ExecutionGraphTestUtils.switchAllVerticesToRunning(eg);
scheduler.cancel();
assertEquals(JobStatus.CANCELLING, eg.getState());
validateCancelRpcCalls(gateway, parallelism);
ExecutionGraphTestUtils.completeCancellingForAllVertices(eg);
assertEquals(JobStatus.CANCELED, eg.getTerminationFuture().get());
// suspend
scheduler.closeAsync();
// still in failed state
assertEquals(JobStatus.CANCELED, eg.getState());
validateCancelRpcCalls(gateway, parallelism);
}
use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionGraphSuspendTest method testSuspendedOutOfFailed.
/**
* Suspending from FAILED should do nothing.
*/
@Test
public void testSuspendedOutOfFailed() throws Exception {
final InteractionsCountingTaskManagerGateway gateway = new InteractionsCountingTaskManagerGateway();
final int parallelism = 10;
final SchedulerBase scheduler = createScheduler(gateway, parallelism);
final ExecutionGraph eg = scheduler.getExecutionGraph();
scheduler.startScheduling();
ExecutionGraphTestUtils.switchAllVerticesToRunning(eg);
scheduler.handleGlobalFailure(new Exception("fail global"));
assertEquals(JobStatus.FAILING, eg.getState());
validateCancelRpcCalls(gateway, parallelism);
ExecutionGraphTestUtils.completeCancellingForAllVertices(eg);
assertEquals(JobStatus.FAILED, eg.getState());
// suspend
scheduler.closeAsync();
// still in failed state
assertEquals(JobStatus.FAILED, eg.getState());
validateCancelRpcCalls(gateway, parallelism);
}
use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionGraphSuspendTest method testSuspendedOutOfCreated.
/**
* Going into SUSPENDED out of CREATED should immediately cancel everything and not send out RPC
* calls.
*/
@Test
public void testSuspendedOutOfCreated() throws Exception {
final InteractionsCountingTaskManagerGateway gateway = new InteractionsCountingTaskManagerGateway();
final int parallelism = 10;
final SchedulerBase scheduler = createScheduler(gateway, parallelism);
final ExecutionGraph eg = scheduler.getExecutionGraph();
assertEquals(JobStatus.CREATED, eg.getState());
// suspend
scheduler.closeAsync();
assertEquals(JobStatus.SUSPENDED, eg.getState());
validateAllVerticesInState(eg, ExecutionState.CANCELED);
validateCancelRpcCalls(gateway, 0);
ensureCannotLeaveSuspendedState(scheduler, gateway);
}
use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionGraphSuspendTest method testSuspendedOutOfFailing.
/**
* Suspending from FAILING goes to SUSPENDED and sends no additional RPC calls.
*/
@Test
public void testSuspendedOutOfFailing() throws Exception {
final int parallelism = 10;
final InteractionsCountingTaskManagerGateway gateway = new InteractionsCountingTaskManagerGateway(parallelism);
final SchedulerBase scheduler = createScheduler(gateway, parallelism);
final ExecutionGraph eg = scheduler.getExecutionGraph();
scheduler.startScheduling();
ExecutionGraphTestUtils.switchAllVerticesToRunning(eg);
scheduler.handleGlobalFailure(new Exception("fail global"));
assertEquals(JobStatus.FAILING, eg.getState());
validateCancelRpcCalls(gateway, parallelism);
// suspend
scheduler.closeAsync();
assertEquals(JobStatus.SUSPENDED, eg.getState());
ensureCannotLeaveSuspendedState(scheduler, gateway);
}
use of org.apache.flink.runtime.scheduler.SchedulerBase 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());
}
Aggregations