Search in sources :

Example 71 with ExecutionGraph

use of org.apache.flink.runtime.executiongraph.ExecutionGraph in project flink by apache.

the class FixedDelayRestartStrategyTest method testFixedDelayRestartStrategy.

@Test
public void testFixedDelayRestartStrategy() {
    int numberRestarts = 10;
    long restartDelay = 10;
    FixedDelayRestartStrategy fixedDelayRestartStrategy = new FixedDelayRestartStrategy(numberRestarts, restartDelay);
    ExecutionGraph executionGraph = mock(ExecutionGraph.class);
    when(executionGraph.getFutureExecutor()).thenReturn(ExecutionContext$.MODULE$.fromExecutor(MoreExecutors.directExecutor()));
    while (fixedDelayRestartStrategy.canRestart()) {
        fixedDelayRestartStrategy.restart(executionGraph);
    }
    Mockito.verify(executionGraph, Mockito.times(numberRestarts)).restart();
}
Also used : ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) Test(org.junit.Test)

Example 72 with ExecutionGraph

use of org.apache.flink.runtime.executiongraph.ExecutionGraph in project flink by apache.

the class CreatingExecutionGraph method handleExecutionGraphCreation.

private void handleExecutionGraphCreation(@Nullable ExecutionGraphWithVertexParallelism executionGraphWithVertexParallelism, @Nullable Throwable throwable) {
    if (throwable != null) {
        logger.info("Failed to go from {} to {} because the ExecutionGraph creation failed.", CreatingExecutionGraph.class.getSimpleName(), Executing.class.getSimpleName(), throwable);
        context.goToFinished(context.getArchivedExecutionGraph(JobStatus.FAILED, throwable));
    } else {
        for (ExecutionVertex vertex : executionGraphWithVertexParallelism.executionGraph.getAllExecutionVertices()) {
            vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
        }
        final AssignmentResult result = context.tryToAssignSlots(executionGraphWithVertexParallelism);
        if (result.isSuccess()) {
            logger.debug("Successfully reserved and assigned the required slots for the ExecutionGraph.");
            final ExecutionGraph executionGraph = result.getExecutionGraph();
            final ExecutionGraphHandler executionGraphHandler = new ExecutionGraphHandler(executionGraph, getLogger(), context.getIOExecutor(), context.getMainThreadExecutor());
            // Operator coordinator outlives the current state, so we need to use context as a
            // global failure handler.
            final OperatorCoordinatorHandler operatorCoordinatorHandler = operatorCoordinatorHandlerFactory.create(executionGraph, context);
            operatorCoordinatorHandler.initializeOperatorCoordinators(context.getMainThreadExecutor());
            operatorCoordinatorHandler.startAllOperatorCoordinators();
            context.goToExecuting(result.getExecutionGraph(), executionGraphHandler, operatorCoordinatorHandler, Collections.emptyList());
        } else {
            logger.debug("Failed to reserve and assign the required slots. Waiting for new resources.");
            context.goToWaitingForResources();
        }
    }
}
Also used : ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) ExecutionGraphHandler(org.apache.flink.runtime.scheduler.ExecutionGraphHandler) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) DefaultOperatorCoordinatorHandler(org.apache.flink.runtime.scheduler.DefaultOperatorCoordinatorHandler) OperatorCoordinatorHandler(org.apache.flink.runtime.scheduler.OperatorCoordinatorHandler)

Example 73 with ExecutionGraph

use of org.apache.flink.runtime.executiongraph.ExecutionGraph in project flink by apache.

the class ExecutionGraphToInputsLocationsRetrieverAdapterTest method testGetNonExistingExecutionVertexWillThrowException.

/**
 * Tests that it will throw exception when getting the task manager location of a non existing
 * execution.
 */
@Test
public void testGetNonExistingExecutionVertexWillThrowException() throws Exception {
    final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1);
    final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(jobVertex);
    final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg);
    ExecutionVertexID invalidExecutionVertexId = new ExecutionVertexID(new JobVertexID(), 0);
    try {
        inputsLocationsRetriever.getTaskManagerLocation(invalidExecutionVertexId);
        fail("Should throw exception if execution vertex doesn't exist!");
    } catch (IllegalStateException expected) {
    // expect this exception
    }
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) Test(org.junit.Test)

Example 74 with ExecutionGraph

use of org.apache.flink.runtime.executiongraph.ExecutionGraph in project flink by apache.

the class ExecutionGraphToInputsLocationsRetrieverAdapterTest method testGetEmptyTaskManagerLocationIfVertexNotScheduled.

/**
 * Tests that it will get empty task manager location if vertex is not scheduled.
 */
@Test
public void testGetEmptyTaskManagerLocationIfVertexNotScheduled() throws Exception {
    final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1);
    final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(jobVertex);
    final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg);
    ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0);
    Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocation = inputsLocationsRetriever.getTaskManagerLocation(executionVertexId);
    assertFalse(taskManagerLocation.isPresent());
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) Test(org.junit.Test)

Example 75 with ExecutionGraph

use of org.apache.flink.runtime.executiongraph.ExecutionGraph in project flink by apache.

the class ExecutionGraphToInputsLocationsRetrieverAdapterTest method testGetConsumedResultPartitionsProducers.

/**
 * Tests that can get the producers of consumed result partitions.
 */
@Test
public void testGetConsumedResultPartitionsProducers() throws Exception {
    final JobVertex producer1 = ExecutionGraphTestUtils.createNoOpVertex(1);
    final JobVertex producer2 = ExecutionGraphTestUtils.createNoOpVertex(1);
    final JobVertex consumer = ExecutionGraphTestUtils.createNoOpVertex(1);
    consumer.connectNewDataSetAsInput(producer1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED);
    consumer.connectNewDataSetAsInput(producer2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED);
    final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(producer1, producer2, consumer);
    final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg);
    ExecutionVertexID evIdOfProducer1 = new ExecutionVertexID(producer1.getID(), 0);
    ExecutionVertexID evIdOfProducer2 = new ExecutionVertexID(producer2.getID(), 0);
    ExecutionVertexID evIdOfConsumer = new ExecutionVertexID(consumer.getID(), 0);
    Collection<Collection<ExecutionVertexID>> producersOfProducer1 = inputsLocationsRetriever.getConsumedResultPartitionsProducers(evIdOfProducer1);
    Collection<Collection<ExecutionVertexID>> producersOfProducer2 = inputsLocationsRetriever.getConsumedResultPartitionsProducers(evIdOfProducer2);
    Collection<Collection<ExecutionVertexID>> producersOfConsumer = inputsLocationsRetriever.getConsumedResultPartitionsProducers(evIdOfConsumer);
    assertThat(producersOfProducer1, is(empty()));
    assertThat(producersOfProducer2, is(empty()));
    assertThat(producersOfConsumer, hasSize(2));
    assertThat(producersOfConsumer, hasItem(Collections.singletonList(evIdOfProducer1)));
    assertThat(producersOfConsumer, hasItem(Collections.singletonList(evIdOfProducer2)));
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)120 Test (org.junit.Test)96 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)77 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)53 CheckpointCoordinatorBuilder (org.apache.flink.runtime.checkpoint.CheckpointCoordinatorTestingUtils.CheckpointCoordinatorBuilder)40 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)36 AcknowledgeCheckpoint (org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint)35 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)31 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)24 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)24 HashMap (java.util.HashMap)20 CompletableFuture (java.util.concurrent.CompletableFuture)19 JobID (org.apache.flink.api.common.JobID)19 ArrayList (java.util.ArrayList)17 HashSet (java.util.HashSet)17 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)17 DeclineCheckpoint (org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint)17 ExecutionException (java.util.concurrent.ExecutionException)13 Executor (java.util.concurrent.Executor)13 IOException (java.io.IOException)12