use of org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolBridge in project flink by apache.
the class ExecutionGraphRestartTest method testCancelAllPendingRequestWhileCanceling.
@Test
public void testCancelAllPendingRequestWhileCanceling() throws Exception {
try (DeclarativeSlotPoolBridge slotPool = SlotPoolUtils.createDeclarativeSlotPoolBridge()) {
final int numTasksExceedSlotPool = 50;
// create a graph with task count larger than slot pool
JobVertex sender = ExecutionGraphTestUtils.createJobVertex("Task", NUM_TASKS + numTasksExceedSlotPool, NoOpInvokable.class);
JobGraph graph = JobGraphTestUtils.streamingJobGraph(sender);
SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(graph, mainThreadExecutor).setExecutionSlotAllocatorFactory(createExecutionSlotAllocatorFactory(slotPool)).build();
ExecutionGraph executionGraph = scheduler.getExecutionGraph();
startScheduling(scheduler);
offerSlots(slotPool, NUM_TASKS);
assertEquals(numTasksExceedSlotPool, slotPool.getNumPendingRequests());
scheduler.cancel();
assertEquals(JobStatus.CANCELLING, executionGraph.getState());
assertEquals(0, slotPool.getNumPendingRequests());
}
}
use of org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolBridge in project flink by apache.
the class ExecutionGraphRestartTest method testCancelAllPendingRequestWhileFailing.
@Test
public void testCancelAllPendingRequestWhileFailing() throws Exception {
try (DeclarativeSlotPoolBridge slotPool = SlotPoolUtils.createDeclarativeSlotPoolBridge()) {
final int numTasksExceedSlotPool = 50;
// create a graph with task count larger than slot pool
JobVertex sender = ExecutionGraphTestUtils.createJobVertex("Task", NUM_TASKS + numTasksExceedSlotPool, NoOpInvokable.class);
JobGraph graph = JobGraphTestUtils.streamingJobGraph(sender);
SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(graph, mainThreadExecutor).setExecutionSlotAllocatorFactory(createExecutionSlotAllocatorFactory(slotPool)).build();
ExecutionGraph executionGraph = scheduler.getExecutionGraph();
startScheduling(scheduler);
offerSlots(slotPool, NUM_TASKS);
assertEquals(numTasksExceedSlotPool, slotPool.getNumPendingRequests());
scheduler.handleGlobalFailure(new Exception("test"));
assertEquals(JobStatus.FAILING, executionGraph.getState());
assertEquals(0, slotPool.getNumPendingRequests());
}
}
Aggregations