Search in sources :

Example 21 with SchedulerBase

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);
}
Also used : SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Example 22 with SchedulerBase

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));
}
Also used : VertexParallelismInformation(org.apache.flink.runtime.scheduler.VertexParallelismInformation) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) VertexParallelismStore(org.apache.flink.runtime.scheduler.VertexParallelismStore) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Example 23 with SchedulerBase

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()));
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) TaskStateSnapshot(org.apache.flink.runtime.checkpoint.TaskStateSnapshot) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) JobManagerTaskRestore(org.apache.flink.runtime.checkpoint.JobManagerTaskRestore) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Example 24 with SchedulerBase

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()));
}
Also used : SimpleAckingTaskManagerGateway(org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) TestingPhysicalSlotProvider(org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Example 25 with SchedulerBase

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));
    });
}
Also used : TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) TestingPhysicalSlotProvider(org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Aggregations

SchedulerBase (org.apache.flink.runtime.scheduler.SchedulerBase)56 Test (org.junit.Test)49 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)33 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)19 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)10 CompletableFuture (java.util.concurrent.CompletableFuture)8 IOException (java.io.IOException)7 TestingPhysicalSlotProvider (org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider)7 TestRestartBackoffTimeStrategy (org.apache.flink.runtime.executiongraph.failover.flip1.TestRestartBackoffTimeStrategy)6 TaskExecutionState (org.apache.flink.runtime.taskmanager.TaskExecutionState)6 ArrayList (java.util.ArrayList)5 JobStatus (org.apache.flink.api.common.JobStatus)5 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)5 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)4 ResultPartitionID (org.apache.flink.runtime.io.network.partition.ResultPartitionID)4 SlotPool (org.apache.flink.runtime.jobmaster.slotpool.SlotPool)4 TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)4 VertexParallelismInformation (org.apache.flink.runtime.scheduler.VertexParallelismInformation)4 VertexParallelismStore (org.apache.flink.runtime.scheduler.VertexParallelismStore)4 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)4