Search in sources :

Example 81 with JobVertex

use of org.apache.flink.runtime.jobgraph.JobVertex in project flink by apache.

the class OperatorIDGeneratorTest method getOperatorID.

private static OperatorID getOperatorID() {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(1);
    env.fromElements(1, 2, 3).uid(UID).name(OPERATOR_NAME).disableChaining().addSink(new DiscardingSink<>());
    JobGraph graph = env.getStreamGraph().getJobGraph(new JobID());
    JobVertex vertex = StreamSupport.stream(graph.getVertices().spliterator(), false).filter(node -> node.getName().contains(OPERATOR_NAME)).findFirst().orElseThrow(() -> new IllegalStateException("Unable to find vertex"));
    return vertex.getOperatorIDs().get(0).getGeneratedOperatorID();
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) JobID(org.apache.flink.api.common.JobID)

Example 82 with JobVertex

use of org.apache.flink.runtime.jobgraph.JobVertex in project flink by apache.

the class ExecutionPartitionLifecycleTest method setupExecutionGraphAndStartRunningJob.

private void setupExecutionGraphAndStartRunningJob(ResultPartitionType resultPartitionType, JobMasterPartitionTracker partitionTracker, TaskManagerGateway taskManagerGateway, ShuffleMaster<?> shuffleMaster) throws Exception {
    final JobVertex producerVertex = createNoOpJobVertex();
    final JobVertex consumerVertex = createNoOpJobVertex();
    consumerVertex.connectNewDataSetAsInput(producerVertex, DistributionPattern.ALL_TO_ALL, resultPartitionType);
    final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
    final TestingPhysicalSlotProvider physicalSlotProvider = TestingPhysicalSlotProvider.create((resourceProfile) -> CompletableFuture.completedFuture(TestingPhysicalSlot.builder().withTaskManagerGateway(taskManagerGateway).withTaskManagerLocation(taskManagerLocation).build()));
    final JobGraph jobGraph = JobGraphTestUtils.batchJobGraph(producerVertex, consumerVertex);
    final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(jobGraph, ComponentMainThreadExecutorServiceAdapter.forMainThread()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(physicalSlotProvider)).setShuffleMaster(shuffleMaster).setPartitionTracker(partitionTracker).build();
    final ExecutionGraph executionGraph = scheduler.getExecutionGraph();
    final ExecutionJobVertex executionJobVertex = executionGraph.getJobVertex(producerVertex.getID());
    final ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0];
    execution = executionVertex.getCurrentExecutionAttempt();
    scheduler.startScheduling();
    execution.switchToRecovering();
    execution.switchToRunning();
    final IntermediateResultPartitionID expectedIntermediateResultPartitionId = executionJobVertex.getProducedDataSets()[0].getPartitions()[0].getPartitionId();
    descriptor = execution.getResultPartitionDeploymentDescriptor(expectedIntermediateResultPartitionId).get();
    taskExecutorResourceId = taskManagerLocation.getResourceID();
    jobId = executionGraph.getJobID();
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) TestingPhysicalSlotProvider(org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)

Example 83 with JobVertex

use of org.apache.flink.runtime.jobgraph.JobVertex in project flink by apache.

the class ExecutionTest method createNoOpJobVertex.

@Nonnull
private JobVertex createNoOpJobVertex() {
    final JobVertex jobVertex = new JobVertex("Test vertex", new JobVertexID());
    jobVertex.setInvokableClass(NoOpInvokable.class);
    return jobVertex;
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) Nonnull(javax.annotation.Nonnull)

Example 84 with JobVertex

use of org.apache.flink.runtime.jobgraph.JobVertex in project flink by apache.

the class ExecutionTest method testTerminationFutureIsCompletedAfterSlotRelease.

/**
 * Checks that the {@link Execution} termination future is only completed after the assigned
 * slot has been released.
 *
 * <p>NOTE: This test only fails spuriously without the fix of this commit. Thus, one has to
 * execute this test multiple times to see the failure.
 */
@Test
public void testTerminationFutureIsCompletedAfterSlotRelease() throws Exception {
    final JobVertex jobVertex = createNoOpJobVertex();
    final JobVertexID jobVertexId = jobVertex.getID();
    final TestingPhysicalSlotProvider physicalSlotProvider = TestingPhysicalSlotProvider.createWithLimitedAmountOfPhysicalSlots(1);
    final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(JobGraphTestUtils.streamingJobGraph(jobVertex), ComponentMainThreadExecutorServiceAdapter.forMainThread()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(physicalSlotProvider)).build();
    ExecutionJobVertex executionJobVertex = scheduler.getExecutionJobVertex(jobVertexId);
    ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0];
    scheduler.startScheduling();
    Execution currentExecutionAttempt = executionVertex.getCurrentExecutionAttempt();
    CompletableFuture<? extends PhysicalSlot> returnedSlotFuture = physicalSlotProvider.getFirstResponseOrFail();
    CompletableFuture<?> terminationFuture = executionVertex.cancel();
    currentExecutionAttempt.completeCancelling();
    CompletableFuture<Boolean> restartFuture = terminationFuture.thenApply(ignored -> {
        assertTrue(returnedSlotFuture.isDone());
        return true;
    });
    // check if the returned slot future was completed first
    restartFuture.get();
}
Also used : 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 85 with JobVertex

use of org.apache.flink.runtime.jobgraph.JobVertex in project flink by apache.

the class FinalizeOnMasterTest method testFinalizeIsNotCalledUponFailure.

@Test
public void testFinalizeIsNotCalledUponFailure() throws Exception {
    final JobVertex vertex = spy(new JobVertex("test vertex 1"));
    vertex.setInvokableClass(NoOpInvokable.class);
    vertex.setParallelism(1);
    final SchedulerBase scheduler = createScheduler(JobGraphTestUtils.streamingJobGraph(vertex), ComponentMainThreadExecutorServiceAdapter.forMainThread());
    scheduler.startScheduling();
    final ExecutionGraph eg = scheduler.getExecutionGraph();
    assertEquals(JobStatus.RUNNING, eg.getState());
    ExecutionGraphTestUtils.switchAllVerticesToRunning(eg);
    // fail the execution
    final Execution exec = eg.getJobVertex(vertex.getID()).getTaskVertices()[0].getCurrentExecutionAttempt();
    exec.fail(new Exception("test"));
    assertEquals(JobStatus.FAILED, eg.waitUntilTerminal());
    verify(vertex, times(0)).finalizeOnMaster(any(ClassLoader.class));
    assertEquals(0, eg.getRegisteredExecutions().size());
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Aggregations

JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)378 Test (org.junit.Test)230 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)197 Configuration (org.apache.flink.configuration.Configuration)74 JobID (org.apache.flink.api.common.JobID)60 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)58 ArrayList (java.util.ArrayList)57 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)47 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)44 SlotSharingGroup (org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)41 SchedulerBase (org.apache.flink.runtime.scheduler.SchedulerBase)35 HashMap (java.util.HashMap)30 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)29 IOException (java.io.IOException)24 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)24 TaskConfig (org.apache.flink.runtime.operators.util.TaskConfig)24 Set (java.util.Set)23 JobException (org.apache.flink.runtime.JobException)23 Scheduler (org.apache.flink.runtime.jobmanager.scheduler.Scheduler)23 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)22