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));
}
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()));
}
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));
}
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));
}
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)));
}
Aggregations