use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionGraphSuspendTest method testSuspendedOutOfDeploying.
/**
* Going into SUSPENDED out of DEPLOYING vertices should cancel all vertices once with RPC
* calls.
*/
@Test
public void testSuspendedOutOfDeploying() 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();
assertEquals(JobStatus.RUNNING, eg.getState());
validateAllVerticesInState(eg, ExecutionState.DEPLOYING);
// suspend
scheduler.closeAsync();
assertEquals(JobStatus.SUSPENDED, eg.getState());
validateCancelRpcCalls(gateway, parallelism);
ensureCannotLeaveSuspendedState(scheduler, gateway);
}
use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class AdaptiveSchedulerComputeReactiveModeVertexParallelismTest method testCreateStoreWithoutAdjustedParallelism.
@Test
public void testCreateStoreWithoutAdjustedParallelism() {
JobVertex jobVertex = createNoOpVertex("test", parallelism, maxParallelism);
VertexParallelismStore store = AdaptiveScheduler.computeReactiveModeVertexParallelismStore(Collections.singleton(jobVertex), SchedulerBase::getDefaultMaxParallelism, false);
VertexParallelismInformation info = store.getParallelismInfo(jobVertex.getID());
Assert.assertEquals("parallelism is not adjusted", parallelism, info.getParallelism());
Assert.assertEquals("expected max", expectedMaxParallelism, info.getMaxParallelism());
Assert.assertEquals("can rescale max", expectedCanRescaleTo, info.canRescaleMaxParallelism(maxToScaleTo));
}
use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionTest method testTaskRestoreStateIsNulledAfterDeployment.
/**
* Tests that the task restore state is nulled after the {@link Execution} has been deployed.
* See FLINK-9693.
*/
@Test
public void testTaskRestoreStateIsNulledAfterDeployment() throws Exception {
final JobVertex jobVertex = createNoOpJobVertex();
final JobVertexID jobVertexId = jobVertex.getID();
final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(JobGraphTestUtils.streamingJobGraph(jobVertex), ComponentMainThreadExecutorServiceAdapter.forMainThread()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(TestingPhysicalSlotProvider.createWithLimitedAmountOfPhysicalSlots(1))).build();
ExecutionJobVertex executionJobVertex = scheduler.getExecutionJobVertex(jobVertexId);
ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0];
final Execution execution = executionVertex.getCurrentExecutionAttempt();
final JobManagerTaskRestore taskRestoreState = new JobManagerTaskRestore(1L, new TaskStateSnapshot());
execution.setInitialState(taskRestoreState);
assertThat(execution.getTaskRestore(), is(notNullValue()));
// schedule the execution vertex and wait for its deployment
scheduler.startScheduling();
assertThat(execution.getTaskRestore(), is(nullValue()));
}
use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionTest method testCanceledExecutionReturnsSlot.
@Test
public void testCanceledExecutionReturnsSlot() throws Exception {
final JobVertex jobVertex = createNoOpJobVertex();
final JobVertexID jobVertexId = jobVertex.getID();
final SimpleAckingTaskManagerGateway taskManagerGateway = new SimpleAckingTaskManagerGateway();
TestingPhysicalSlotProvider physicalSlotProvider = TestingPhysicalSlotProvider.create((resourceProfile) -> CompletableFuture.completedFuture(TestingPhysicalSlot.builder().withTaskManagerGateway(taskManagerGateway).build()));
final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(JobGraphTestUtils.streamingJobGraph(jobVertex), testMainThreadUtil.getMainThreadExecutor()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(physicalSlotProvider)).build();
ExecutionJobVertex executionJobVertex = scheduler.getExecutionJobVertex(jobVertexId);
ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0];
final Execution execution = executionVertex.getCurrentExecutionAttempt();
taskManagerGateway.setCancelConsumer(executionAttemptID -> {
if (execution.getAttemptId().equals(executionAttemptID)) {
execution.completeCancelling();
}
});
testMainThreadUtil.execute(scheduler::startScheduling);
// cancel the execution in case we could schedule the execution
testMainThreadUtil.execute(execution::cancel);
assertThat(physicalSlotProvider.getRequests().keySet(), is(physicalSlotProvider.getCancellations().keySet()));
}
use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.
the class ExecutionTest method testSlotReleaseAtomicallyReleasesExecution.
/**
* Tests that a slot release will atomically release the assigned {@link Execution}.
*/
@Test
public void testSlotReleaseAtomicallyReleasesExecution() throws Exception {
final JobVertex jobVertex = createNoOpJobVertex();
final TestingPhysicalSlotProvider physicalSlotProvider = TestingPhysicalSlotProvider.createWithLimitedAmountOfPhysicalSlots(1);
final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(JobGraphTestUtils.streamingJobGraph(jobVertex), testMainThreadUtil.getMainThreadExecutor()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(physicalSlotProvider)).build();
final Execution execution = scheduler.getExecutionJobVertex(jobVertex.getID()).getTaskVertices()[0].getCurrentExecutionAttempt();
testMainThreadUtil.execute(scheduler::startScheduling);
// wait until the slot has been requested
physicalSlotProvider.awaitAllSlotRequests();
TestingPhysicalSlot physicalSlot = physicalSlotProvider.getFirstResponseOrFail().get();
testMainThreadUtil.execute(() -> {
assertThat(execution.getAssignedAllocationID(), is(physicalSlot.getAllocationId()));
physicalSlot.releasePayload(new FlinkException("Test exception"));
assertThat(execution.getReleaseFuture().isDone(), is(true));
});
}
Aggregations