Search in sources :

Example 31 with ExecutionVertexID

use of org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID in project flink by apache.

the class DefaultSchedulerTest method deployTasksOnlyWhenAllSlotRequestsAreFulfilled.

@Test
public void deployTasksOnlyWhenAllSlotRequestsAreFulfilled() throws Exception {
    final JobGraph jobGraph = singleJobVertexJobGraph(4);
    final JobVertexID onlyJobVertexId = getOnlyJobVertex(jobGraph).getID();
    testExecutionSlotAllocator.disableAutoCompletePendingRequests();
    final TestSchedulingStrategy.Factory schedulingStrategyFactory = new TestSchedulingStrategy.Factory();
    final DefaultScheduler scheduler = createScheduler(jobGraph, ComponentMainThreadExecutorServiceAdapter.forMainThread(), schedulingStrategyFactory);
    final TestSchedulingStrategy schedulingStrategy = schedulingStrategyFactory.getLastCreatedSchedulingStrategy();
    scheduler.startScheduling();
    final List<ExecutionVertexID> verticesToSchedule = Arrays.asList(new ExecutionVertexID(onlyJobVertexId, 0), new ExecutionVertexID(onlyJobVertexId, 1), new ExecutionVertexID(onlyJobVertexId, 2), new ExecutionVertexID(onlyJobVertexId, 3));
    schedulingStrategy.schedule(verticesToSchedule);
    assertThat(testExecutionVertexOperations.getDeployedVertices(), hasSize(0));
    testExecutionSlotAllocator.completePendingRequest(verticesToSchedule.get(0));
    assertThat(testExecutionVertexOperations.getDeployedVertices(), hasSize(0));
    testExecutionSlotAllocator.completePendingRequests();
    assertThat(testExecutionVertexOperations.getDeployedVertices(), hasSize(4));
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) TestingCheckpointRecoveryFactory(org.apache.flink.runtime.checkpoint.TestingCheckpointRecoveryFactory) SchedulingStrategyFactory(org.apache.flink.runtime.scheduler.strategy.SchedulingStrategyFactory) TestFailoverStrategyFactory(org.apache.flink.runtime.executiongraph.utils.TestFailoverStrategyFactory) CheckpointRecoveryFactory(org.apache.flink.runtime.checkpoint.CheckpointRecoveryFactory) TestSchedulingStrategy(org.apache.flink.runtime.scheduler.strategy.TestSchedulingStrategy) AdaptiveSchedulerTest(org.apache.flink.runtime.scheduler.adaptive.AdaptiveSchedulerTest) Test(org.junit.Test)

Example 32 with ExecutionVertexID

use of org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID in project flink by apache.

the class ExecutionGraphToInputsLocationsRetrieverAdapterTest method testGetTaskManagerLocationWhenScheduled.

/**
 * Tests that it can get the task manager location in an Execution.
 */
@Test
public void testGetTaskManagerLocationWhenScheduled() throws Exception {
    final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1);
    final TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
    final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(jobVertex);
    final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg);
    final ExecutionVertex onlyExecutionVertex = eg.getAllExecutionVertices().iterator().next();
    onlyExecutionVertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
    onlyExecutionVertex.deployToSlot(testingLogicalSlot);
    ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0);
    Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocationOptional = inputsLocationsRetriever.getTaskManagerLocation(executionVertexId);
    assertTrue(taskManagerLocationOptional.isPresent());
    final CompletableFuture<TaskManagerLocation> taskManagerLocationFuture = taskManagerLocationOptional.get();
    assertThat(taskManagerLocationFuture.get(), is(testingLogicalSlot.getTaskManagerLocation()));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) TestingLogicalSlot(org.apache.flink.runtime.jobmaster.TestingLogicalSlot) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) Test(org.junit.Test)

Example 33 with ExecutionVertexID

use of org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID in project flink by apache.

the class DefaultPreferredLocationsRetrieverTest method testInputLocationsIgnoresExcludedProducers.

@Test
public void testInputLocationsIgnoresExcludedProducers() {
    final TestingInputsLocationsRetriever.Builder locationRetrieverBuilder = new TestingInputsLocationsRetriever.Builder();
    final ExecutionVertexID consumerId = new ExecutionVertexID(new JobVertexID(), 0);
    final JobVertexID producerJobVertexId = new JobVertexID();
    final ExecutionVertexID producerId1 = new ExecutionVertexID(producerJobVertexId, 0);
    locationRetrieverBuilder.connectConsumerToProducer(consumerId, producerId1);
    final ExecutionVertexID producerId2 = new ExecutionVertexID(producerJobVertexId, 1);
    locationRetrieverBuilder.connectConsumerToProducer(consumerId, producerId2);
    final TestingInputsLocationsRetriever inputsLocationsRetriever = locationRetrieverBuilder.build();
    inputsLocationsRetriever.markScheduled(producerId1);
    inputsLocationsRetriever.markScheduled(producerId2);
    inputsLocationsRetriever.assignTaskManagerLocation(producerId1);
    inputsLocationsRetriever.assignTaskManagerLocation(producerId2);
    final PreferredLocationsRetriever locationsRetriever = new DefaultPreferredLocationsRetriever(id -> Optional.empty(), inputsLocationsRetriever);
    final CompletableFuture<Collection<TaskManagerLocation>> preferredLocations = locationsRetriever.getPreferredLocations(consumerId, Collections.singleton(producerId1));
    assertThat(preferredLocations.getNow(null), hasSize(1));
    final TaskManagerLocation producerLocation2 = inputsLocationsRetriever.getTaskManagerLocation(producerId2).get().getNow(null);
    assertThat(preferredLocations.getNow(null), contains(producerLocation2));
}
Also used : ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) Collection(java.util.Collection) Test(org.junit.Test)

Example 34 with ExecutionVertexID

use of org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID in project flink by apache.

the class DefaultPreferredLocationsRetrieverTest method testStateLocationsWillBeReturnedIfExist.

@Test
public void testStateLocationsWillBeReturnedIfExist() {
    final TaskManagerLocation stateLocation = new LocalTaskManagerLocation();
    final TestingInputsLocationsRetriever.Builder locationRetrieverBuilder = new TestingInputsLocationsRetriever.Builder();
    final ExecutionVertexID consumerId = new ExecutionVertexID(new JobVertexID(), 0);
    final ExecutionVertexID producerId = new ExecutionVertexID(new JobVertexID(), 0);
    locationRetrieverBuilder.connectConsumerToProducer(consumerId, producerId);
    final TestingInputsLocationsRetriever inputsLocationsRetriever = locationRetrieverBuilder.build();
    inputsLocationsRetriever.markScheduled(producerId);
    final PreferredLocationsRetriever locationsRetriever = new DefaultPreferredLocationsRetriever(id -> Optional.of(stateLocation), inputsLocationsRetriever);
    final CompletableFuture<Collection<TaskManagerLocation>> preferredLocations = locationsRetriever.getPreferredLocations(consumerId, Collections.emptySet());
    assertThat(preferredLocations.getNow(null), contains(stateLocation));
}
Also used : TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) Collection(java.util.Collection) Test(org.junit.Test)

Example 35 with ExecutionVertexID

use of org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID in project flink by apache.

the class DefaultSchedulerTest method skipDeploymentIfVertexVersionOutdated.

@Test
public void skipDeploymentIfVertexVersionOutdated() {
    testExecutionSlotAllocator.disableAutoCompletePendingRequests();
    final JobGraph jobGraph = nonParallelSourceSinkJobGraph();
    final List<JobVertex> sortedJobVertices = jobGraph.getVerticesSortedTopologicallyFromSources();
    final ExecutionVertexID sourceExecutionVertexId = new ExecutionVertexID(sortedJobVertices.get(0).getID(), 0);
    final ExecutionVertexID sinkExecutionVertexId = new ExecutionVertexID(sortedJobVertices.get(1).getID(), 0);
    final DefaultScheduler scheduler = createSchedulerAndStartScheduling(jobGraph);
    testExecutionSlotAllocator.completePendingRequest(sourceExecutionVertexId);
    final ArchivedExecutionVertex sourceExecutionVertex = scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices().iterator().next();
    final ExecutionAttemptID attemptId = sourceExecutionVertex.getCurrentExecutionAttempt().getAttemptId();
    scheduler.updateTaskExecutionState(createFailedTaskExecutionState(attemptId));
    testRestartBackoffTimeStrategy.setCanRestart(false);
    testExecutionSlotAllocator.enableAutoCompletePendingRequests();
    taskRestartExecutor.triggerScheduledTasks();
    assertThat(testExecutionVertexOperations.getDeployedVertices(), containsInAnyOrder(sourceExecutionVertexId, sinkExecutionVertexId));
    assertThat(scheduler.requestJob().getArchivedExecutionGraph().getState(), is(equalTo(JobStatus.RUNNING)));
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) ArchivedExecutionVertex(org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex) AdaptiveSchedulerTest(org.apache.flink.runtime.scheduler.adaptive.AdaptiveSchedulerTest) Test(org.junit.Test)

Aggregations

ExecutionVertexID (org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID)77 Test (org.junit.Test)55 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)21 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)19 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)18 SchedulingExecutionVertex (org.apache.flink.runtime.scheduler.strategy.SchedulingExecutionVertex)17 Set (java.util.Set)16 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)15 AdaptiveSchedulerTest (org.apache.flink.runtime.scheduler.adaptive.AdaptiveSchedulerTest)15 TestingSchedulingExecutionVertex (org.apache.flink.runtime.scheduler.strategy.TestingSchedulingExecutionVertex)15 Collection (java.util.Collection)11 TestingSchedulingTopology (org.apache.flink.runtime.scheduler.strategy.TestingSchedulingTopology)11 HashSet (java.util.HashSet)10 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)10 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 HashMap (java.util.HashMap)8 List (java.util.List)8 CompletableFuture (java.util.concurrent.CompletableFuture)8 ArchivedExecutionVertex (org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex)7