Search in sources :

Example 1 with FINISHED

use of org.apache.flink.api.common.JobStatus.FINISHED in project flink by apache.

the class ExecutionGraphCoLocationRestartTest method testConstraintsAfterRestart.

@Test
public void testConstraintsAfterRestart() throws Exception {
    final long timeout = 5000L;
    JobVertex groupVertex = ExecutionGraphTestUtils.createNoOpVertex(NUM_TASKS);
    JobVertex groupVertex2 = ExecutionGraphTestUtils.createNoOpVertex(NUM_TASKS);
    groupVertex2.connectNewDataSetAsInput(groupVertex, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
    SlotSharingGroup sharingGroup = new SlotSharingGroup();
    groupVertex.setSlotSharingGroup(sharingGroup);
    groupVertex2.setSlotSharingGroup(sharingGroup);
    groupVertex.setStrictlyCoLocatedWith(groupVertex2);
    // initiate and schedule job
    final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(groupVertex, groupVertex2);
    final ManuallyTriggeredScheduledExecutorService delayExecutor = new ManuallyTriggeredScheduledExecutorService();
    final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(jobGraph, ComponentMainThreadExecutorServiceAdapter.forMainThread()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(TestingPhysicalSlotProvider.create((ignored) -> CompletableFuture.completedFuture(TestingPhysicalSlot.builder().build())))).setDelayExecutor(delayExecutor).setRestartBackoffTimeStrategy(new FixedDelayRestartBackoffTimeStrategy.FixedDelayRestartBackoffTimeStrategyFactory(1, 0).create()).build();
    final ExecutionGraph eg = scheduler.getExecutionGraph();
    // enable the queued scheduling for the slot pool
    assertEquals(JobStatus.CREATED, eg.getState());
    scheduler.startScheduling();
    Predicate<AccessExecution> isDeploying = ExecutionGraphTestUtils.isInExecutionState(ExecutionState.DEPLOYING);
    ExecutionGraphTestUtils.waitForAllExecutionsPredicate(eg, isDeploying, timeout);
    assertEquals(JobStatus.RUNNING, eg.getState());
    // sanity checks
    validateConstraints(eg);
    eg.getAllExecutionVertices().iterator().next().fail(new FlinkException("Test exception"));
    assertEquals(JobStatus.RESTARTING, eg.getState());
    // trigger registration of restartTasks(...) callback to cancelFuture before completing the
    // cancellation. This ensures the restarting actions to be performed in main thread.
    delayExecutor.triggerNonPeriodicScheduledTask();
    for (ExecutionVertex vertex : eg.getAllExecutionVertices()) {
        if (vertex.getExecutionState() == ExecutionState.CANCELING) {
            vertex.getCurrentExecutionAttempt().completeCancelling();
        }
    }
    // wait until we have restarted
    ExecutionGraphTestUtils.waitUntilJobStatus(eg, JobStatus.RUNNING, timeout);
    ExecutionGraphTestUtils.waitForAllExecutionsPredicate(eg, isDeploying, timeout);
    // checking execution vertex properties
    validateConstraints(eg);
    ExecutionGraphTestUtils.finishAllVertices(eg);
    assertThat(eg.getState(), is(FINISHED));
}
Also used : ComponentMainThreadExecutorServiceAdapter(org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter) TestingPhysicalSlotProvider(org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider) FlinkException(org.apache.flink.util.FlinkException) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) Predicate(java.util.function.Predicate) ExecutionState(org.apache.flink.runtime.execution.ExecutionState) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ManuallyTriggeredScheduledExecutorService(org.apache.flink.runtime.concurrent.ManuallyTriggeredScheduledExecutorService) ResultPartitionType(org.apache.flink.runtime.io.network.partition.ResultPartitionType) Test(org.junit.Test) CompletableFuture(java.util.concurrent.CompletableFuture) JobStatus(org.apache.flink.api.common.JobStatus) Assert.assertThat(org.junit.Assert.assertThat) FINISHED(org.apache.flink.api.common.JobStatus.FINISHED) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) JobGraphTestUtils(org.apache.flink.runtime.jobgraph.JobGraphTestUtils) Matchers.is(org.hamcrest.Matchers.is) FixedDelayRestartBackoffTimeStrategy(org.apache.flink.runtime.executiongraph.failover.flip1.FixedDelayRestartBackoffTimeStrategy) SchedulerTestingUtils(org.apache.flink.runtime.scheduler.SchedulerTestingUtils) DistributionPattern(org.apache.flink.runtime.jobgraph.DistributionPattern) Assert.assertEquals(org.junit.Assert.assertEquals) FixedDelayRestartBackoffTimeStrategy(org.apache.flink.runtime.executiongraph.failover.flip1.FixedDelayRestartBackoffTimeStrategy) FlinkException(org.apache.flink.util.FlinkException) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ManuallyTriggeredScheduledExecutorService(org.apache.flink.runtime.concurrent.ManuallyTriggeredScheduledExecutorService) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) Test(org.junit.Test)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)1 Predicate (java.util.function.Predicate)1 JobStatus (org.apache.flink.api.common.JobStatus)1 FINISHED (org.apache.flink.api.common.JobStatus.FINISHED)1 ComponentMainThreadExecutorServiceAdapter (org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter)1 ManuallyTriggeredScheduledExecutorService (org.apache.flink.runtime.concurrent.ManuallyTriggeredScheduledExecutorService)1 ExecutionState (org.apache.flink.runtime.execution.ExecutionState)1 FixedDelayRestartBackoffTimeStrategy (org.apache.flink.runtime.executiongraph.failover.flip1.FixedDelayRestartBackoffTimeStrategy)1 ResultPartitionType (org.apache.flink.runtime.io.network.partition.ResultPartitionType)1 DistributionPattern (org.apache.flink.runtime.jobgraph.DistributionPattern)1 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)1 JobGraphTestUtils (org.apache.flink.runtime.jobgraph.JobGraphTestUtils)1 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)1 SlotSharingGroup (org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)1 SchedulerBase (org.apache.flink.runtime.scheduler.SchedulerBase)1 SchedulerTestingUtils (org.apache.flink.runtime.scheduler.SchedulerTestingUtils)1 TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)1 TestingPhysicalSlotProvider (org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider)1 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)1 FlinkException (org.apache.flink.util.FlinkException)1