org.apache.flink.runtime.executiongraph.ExecutionVertex Java Examples
The following examples show how to use
org.apache.flink.runtime.executiongraph.ExecutionVertex.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java From flink with Apache License 2.0 | 6 votes |
/** * 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(new JobID(), jobVertex); final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg); final ExecutionVertex onlyExecutionVertex = eg.getAllExecutionVertices().iterator().next(); 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())); }
Example #2
Source File: DefaultFailoverTopology.java From flink with Apache License 2.0 | 6 votes |
private void connectVerticesWithEdges(Map<ExecutionVertex, DefaultFailoverVertex> failoverVertexMap) { for (ExecutionVertex vertex : failoverVertexMap.keySet()) { final DefaultFailoverVertex failoverVertex = failoverVertexMap.get(vertex); vertex.getProducedPartitions().values().stream() .map(IntermediateResultPartition::getConsumers) .flatMap(Collection::stream) .flatMap(Collection::stream) .forEach(e -> { final DefaultFailoverVertex consumerFailoverVertex = failoverVertexMap.get(e.getTarget()); final DefaultFailoverEdge failoverEdge = new DefaultFailoverEdge( e.getSource().getPartitionId(), e.getSource().getResultType(), failoverVertex, consumerFailoverVertex); failoverVertex.addOutputEdge(failoverEdge); consumerFailoverVertex.addInputEdge(failoverEdge); }); } }
Example #3
Source File: BackPressureStatsTrackerImplTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private ExecutionVertex mockExecutionVertex( ExecutionJobVertex jobVertex, int subTaskIndex) { Execution exec = Mockito.mock(Execution.class); Mockito.when(exec.getAttemptId()).thenReturn(new ExecutionAttemptID()); JobVertexID id = jobVertex.getJobVertexId(); ExecutionVertex vertex = Mockito.mock(ExecutionVertex.class); Mockito.when(vertex.getJobvertexId()).thenReturn(id); Mockito.when(vertex.getCurrentExecutionAttempt()).thenReturn(exec); Mockito.when(vertex.getParallelSubtaskIndex()).thenReturn(subTaskIndex); return vertex; }
Example #4
Source File: StackTraceSampleCoordinatorTest.java From flink with Apache License 2.0 | 6 votes |
/** Tests triggering for reset tasks fails the future. */ @Test(timeout = 1000L) public void testTriggerStackTraceSampleResetRunningTasks() throws Exception { ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), // Fails to send the message to the execution (happens when execution is reset) mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, false) }; CompletableFuture<StackTraceSample> sampleFuture = coord.triggerStackTraceSample( vertices, 1, Time.milliseconds(100L), 0); try { sampleFuture.get(); Assert.fail("Expected exception."); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof RuntimeException); } }
Example #5
Source File: StackTraceSampleCoordinatorTest.java From flink with Apache License 2.0 | 6 votes |
/** Tests cancelling of a pending sample. */ @Test public void testCancelStackTraceSample() throws Exception { ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), }; CompletableFuture<StackTraceSample> sampleFuture = coord.triggerStackTraceSample( vertices, 1, Time.milliseconds(100L), 0); Assert.assertFalse(sampleFuture.isDone()); // Cancel coord.cancelStackTraceSample(0, null); // Verify completed Assert.assertTrue(sampleFuture.isDone()); // Verify no more pending samples Assert.assertEquals(0, coord.getNumberOfPendingSamples()); }
Example #6
Source File: SchedulerTestUtils.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static Execution getTestVertex(Collection<CompletableFuture<TaskManagerLocation>> preferredLocationFutures) { ExecutionJobVertex executionJobVertex = mock(ExecutionJobVertex.class); ExecutionVertex vertex = mock(ExecutionVertex.class); when(vertex.getPreferredLocationsBasedOnInputs()).thenReturn(preferredLocationFutures); when(vertex.getPreferredLocations()).thenReturn(preferredLocationFutures); when(vertex.getJobId()).thenReturn(new JobID()); when(vertex.toString()).thenReturn("TEST-VERTEX"); when(vertex.getJobVertex()).thenReturn(executionJobVertex); when(vertex.getJobvertexId()).thenReturn(new JobVertexID()); Execution execution = mock(Execution.class); when(execution.getVertex()).thenReturn(vertex); when(execution.calculatePreferredLocations(any(LocationPreferenceConstraint.class))).thenCallRealMethod(); return execution; }
Example #7
Source File: DefaultFailoverTopologyTest.java From flink with Apache License 2.0 | 6 votes |
private static void assertVertexEquals(ExecutionVertex originalVertex, FailoverVertex adaptedVertex) { // compare vertex internal properties assertTrue(compareVertexInternalProperties(originalVertex, adaptedVertex)); // compare input edges List<ExecutionEdge> originalInputEdges = IntStream.range(0, originalVertex.getNumberOfInputs()) .mapToObj(originalVertex::getInputEdges) .flatMap(Arrays::stream) .collect(Collectors.toList()); List<FailoverEdge> adaptedInputEdges = StreamSupport.stream( adaptedVertex.getInputEdges().spliterator(), false).collect(Collectors.toList()); assertEdgesEquals(originalInputEdges, adaptedInputEdges); // compare output edges List<ExecutionEdge> originalOutputEdges = originalVertex.getProducedPartitions().values().stream() .map(IntermediateResultPartition::getConsumers) .flatMap(Collection::stream) .flatMap(Collection::stream) .collect(Collectors.toList()); List<FailoverEdge> adaptedOutputEdges = StreamSupport.stream( adaptedVertex.getOutputEdges().spliterator(), false).collect(Collectors.toList()); assertEdgesEquals(originalOutputEdges, adaptedOutputEdges); }
Example #8
Source File: SchedulerBase.java From flink with Apache License 2.0 | 6 votes |
private boolean isNotifiable( final ExecutionVertexID executionVertexId, final TaskExecutionState taskExecutionState) { final ExecutionVertex executionVertex = getExecutionVertex(executionVertexId); // only notifies FINISHED and FAILED states which are needed at the moment. // can be refined in FLINK-14233 after the legacy scheduler is removed and // the actions are factored out from ExecutionGraph. switch (taskExecutionState.getExecutionState()) { case FINISHED: case FAILED: // only notifies a state update if it's effective, namely it successfully // turns the execution state to the expected value. if (executionVertex.getExecutionState() == taskExecutionState.getExecutionState()) { return true; } break; default: break; } return false; }
Example #9
Source File: DefaultScheduler.java From flink with Apache License 2.0 | 6 votes |
private BiFunction<LogicalSlot, Throwable, Void> assignResourceOrHandleError(final DeploymentHandle deploymentHandle) { final ExecutionVertexVersion requiredVertexVersion = deploymentHandle.getRequiredVertexVersion(); final ExecutionVertexID executionVertexId = deploymentHandle.getExecutionVertexId(); return (logicalSlot, throwable) -> { if (executionVertexVersioner.isModified(requiredVertexVersion)) { log.debug("Refusing to assign slot to execution vertex {} because this deployment was " + "superseded by another deployment", executionVertexId); releaseSlotIfPresent(logicalSlot); return null; } if (throwable == null) { final ExecutionVertex executionVertex = getExecutionVertex(executionVertexId); final boolean sendScheduleOrUpdateConsumerMessage = deploymentHandle.getDeploymentOption().sendScheduleOrUpdateConsumerMessage(); executionVertex .getCurrentExecutionAttempt() .registerProducedPartitions(logicalSlot.getTaskManagerLocation(), sendScheduleOrUpdateConsumerMessage); executionVertex.tryAssignResource(logicalSlot); } else { handleTaskDeploymentFailure(executionVertexId, maybeWrapWithNoResourceAvailableException(throwable)); } return null; }; }
Example #10
Source File: StackTraceSampleCoordinatorTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** Tests that collecting for a cancelled sample throws no Exception. */ @Test public void testCollectStackTraceForCanceledSample() throws Exception { ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), }; CompletableFuture<StackTraceSample> sampleFuture = coord.triggerStackTraceSample( vertices, 1, Time.milliseconds(100L), 0); Assert.assertFalse(sampleFuture.isDone()); coord.cancelStackTraceSample(0, null); Assert.assertTrue(sampleFuture.isDone()); // Verify no error on late collect ExecutionAttemptID executionId = vertices[0].getCurrentExecutionAttempt().getAttemptId(); coord.collectStackTraces(0, executionId, new ArrayList<StackTraceElement[]>()); }
Example #11
Source File: PendingCheckpoint.java From flink with Apache License 2.0 | 6 votes |
public PendingCheckpoint( JobID jobId, long checkpointId, long checkpointTimestamp, Map<ExecutionAttemptID, ExecutionVertex> verticesToConfirm, CheckpointProperties props, CheckpointStorageLocation targetLocation, Executor executor) { checkArgument(verticesToConfirm.size() > 0, "Checkpoint needs at least one vertex that commits the checkpoint"); this.jobId = checkNotNull(jobId); this.checkpointId = checkpointId; this.checkpointTimestamp = checkpointTimestamp; this.notYetAcknowledgedTasks = checkNotNull(verticesToConfirm); this.props = checkNotNull(props); this.targetLocation = checkNotNull(targetLocation); this.executor = Preconditions.checkNotNull(executor); this.operatorStates = new HashMap<>(); this.masterState = new ArrayList<>(); this.acknowledgedTasks = new HashSet<>(verticesToConfirm.size()); this.onCompletionPromise = new CompletableFuture<>(); }
Example #12
Source File: DefaultFailoverTopology.java From flink with Apache License 2.0 | 6 votes |
public DefaultFailoverTopology(ExecutionGraph executionGraph) { checkNotNull(executionGraph); this.containsCoLocationConstraints = executionGraph.getAllVertices().values().stream() .map(ExecutionJobVertex::getCoLocationGroup) .anyMatch(Objects::nonNull); // generate vertices this.failoverVertices = new ArrayList<>(); final Map<ExecutionVertex, DefaultFailoverVertex> failoverVertexMap = new IdentityHashMap<>(); for (ExecutionVertex vertex : executionGraph.getAllExecutionVertices()) { final DefaultFailoverVertex failoverVertex = new DefaultFailoverVertex( new ExecutionVertexID(vertex.getJobvertexId(), vertex.getParallelSubtaskIndex()), vertex.getTaskNameWithSubtaskIndex()); this.failoverVertices.add(failoverVertex); failoverVertexMap.put(vertex, failoverVertex); } // generate edges connectVerticesWithEdges(failoverVertexMap); }
Example #13
Source File: CheckpointCoordinatorTestingUtils.java From flink with Apache License 2.0 | 6 votes |
static ExecutionVertex mockExecutionVertex( ExecutionAttemptID attemptID, JobVertexID jobVertexID, List<OperatorID> jobVertexIDs, int parallelism, int maxParallelism, ExecutionState state, ExecutionState ... successiveStates) { return mockExecutionVertex( attemptID, jobVertexID, jobVertexIDs, null, parallelism, maxParallelism, state, successiveStates); }
Example #14
Source File: RestartPipelinedRegionStrategy.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private void makeAllOneRegion(List<ExecutionJobVertex> jobVertices) { LOG.warn("Cannot decompose ExecutionGraph into individual failover regions due to use of " + "Co-Location constraints (iterations). Job will fail over as one holistic unit."); final ArrayList<ExecutionVertex> allVertices = new ArrayList<>(); for (ExecutionJobVertex ejv : jobVertices) { // safe some incremental size growing allVertices.ensureCapacity(allVertices.size() + ejv.getParallelism()); allVertices.addAll(Arrays.asList(ejv.getTaskVertices())); } final FailoverRegion singleRegion = createFailoverRegion(executionGraph, allVertices); for (ExecutionVertex ev : allVertices) { vertexToRegion.put(ev, singleRegion); } }
Example #15
Source File: DefaultExecutionSlotAllocatorPreferredLocationsTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the input edge will be ignored if it has too many different locations. */ @Test public void testIgnoreEdgeOfTooManyLocations() throws Exception { final ExecutionVertexID consumerId = new ExecutionVertexID(new JobVertexID(), 0); final List<ExecutionVertexID> producerIds = new ArrayList<>(ExecutionVertex.MAX_DISTINCT_LOCATIONS_TO_CONSIDER + 1); TestingInputsLocationsRetriever.Builder locationRetrieverBuilder = new TestingInputsLocationsRetriever.Builder(); JobVertexID jobVertexID = new JobVertexID(); for (int i = 0; i < ExecutionVertex.MAX_DISTINCT_LOCATIONS_TO_CONSIDER + 1; i++) { final ExecutionVertexID producerId = new ExecutionVertexID(jobVertexID, i); locationRetrieverBuilder.connectConsumerToProducer(consumerId, producerId); producerIds.add(producerId); } final TestingInputsLocationsRetriever inputsLocationsRetriever = locationRetrieverBuilder.build(); for (int i = 0; i < ExecutionVertex.MAX_DISTINCT_LOCATIONS_TO_CONSIDER + 1; i++) { inputsLocationsRetriever.markScheduled(producerIds.get(i)); } CompletableFuture<Collection<TaskManagerLocation>> preferredLocations = DefaultExecutionSlotAllocator.getPreferredLocationsBasedOnInputs(consumerId, inputsLocationsRetriever); assertThat(preferredLocations.get(), hasSize(0)); }
Example #16
Source File: CheckpointCoordinatorMasterHooksTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static CheckpointCoordinator instantiateCheckpointCoordinator(JobID jid, ExecutionVertex... ackVertices) { return new CheckpointCoordinator( jid, 10000000L, 600000L, 0L, 1, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, new ExecutionVertex[0], ackVertices, new ExecutionVertex[0], new StandaloneCheckpointIDCounter(), new StandaloneCompletedCheckpointStore(10), new MemoryStateBackend(), Executors.directExecutor(), SharedStateRegistry.DEFAULT_FACTORY); }
Example #17
Source File: StackTraceSampleCoordinatorTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** Tests triggering for non-running tasks fails the future. */ @Test public void testTriggerStackTraceSampleNotRunningTasks() throws Exception { ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.DEPLOYING, true) }; CompletableFuture<StackTraceSample> sampleFuture = coord.triggerStackTraceSample( vertices, 1, Time.milliseconds(100L), 0); Assert.assertTrue(sampleFuture.isDone()); try { sampleFuture.get(); Assert.fail("Expected exception."); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof IllegalStateException); } }
Example #18
Source File: StackTraceSampleCoordinatorTest.java From flink with Apache License 2.0 | 6 votes |
/** Tests that collecting for a cancelled sample throws no Exception. */ @Test public void testCollectStackTraceForCanceledSample() throws Exception { ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), }; CompletableFuture<StackTraceSample> sampleFuture = coord.triggerStackTraceSample( vertices, 1, Time.milliseconds(100L), 0); Assert.assertFalse(sampleFuture.isDone()); coord.cancelStackTraceSample(0, null); Assert.assertTrue(sampleFuture.isDone()); // Verify no error on late collect ExecutionAttemptID executionId = vertices[0].getCurrentExecutionAttempt().getAttemptId(); coord.collectStackTraces(0, executionId, new ArrayList<StackTraceElement[]>()); }
Example #19
Source File: StackTraceSampleCoordinatorTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** Tests triggering for reset tasks fails the future. */ @Test(timeout = 1000L) public void testTriggerStackTraceSampleResetRunningTasks() throws Exception { ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), // Fails to send the message to the execution (happens when execution is reset) mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, false) }; CompletableFuture<StackTraceSample> sampleFuture = coord.triggerStackTraceSample( vertices, 1, Time.milliseconds(100L), 0); try { sampleFuture.get(); Assert.fail("Expected exception."); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof RuntimeException); } }
Example #20
Source File: PipelinedFailoverRegionBuildingTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDiamondWithMixedPipelinedAndBlockingExchanges() throws Exception { final JobVertex vertex1 = new JobVertex("vertex1"); vertex1.setInvokableClass(NoOpInvokable.class); vertex1.setParallelism(8); final JobVertex vertex2 = new JobVertex("vertex2"); vertex2.setInvokableClass(NoOpInvokable.class); vertex2.setParallelism(8); final JobVertex vertex3 = new JobVertex("vertex3"); vertex3.setInvokableClass(NoOpInvokable.class); vertex3.setParallelism(8); final JobVertex vertex4 = new JobVertex("vertex4"); vertex4.setInvokableClass(NoOpInvokable.class); vertex4.setParallelism(8); vertex2.connectNewDataSetAsInput(vertex1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); vertex3.connectNewDataSetAsInput(vertex1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); vertex4.connectNewDataSetAsInput(vertex2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); vertex4.connectNewDataSetAsInput(vertex3, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("test job", vertex1, vertex2, vertex3, vertex4); final ExecutionGraph eg = createExecutionGraph(jobGraph); RestartPipelinedRegionStrategy failoverStrategy = (RestartPipelinedRegionStrategy) eg.getFailoverStrategy(); Iterator<ExecutionVertex> evs = eg.getAllExecutionVertices().iterator(); FailoverRegion preRegion = failoverStrategy.getFailoverRegion(evs.next()); while (evs.hasNext()) { FailoverRegion region = failoverStrategy.getFailoverRegion(evs.next()); assertTrue(preRegion == region); } }
Example #21
Source File: CheckpointStateRestoreTest.java From flink with Apache License 2.0 | 5 votes |
private ExecutionVertex mockExecutionVertex(Execution execution, JobVertexID vertexId, int subtask, int parallelism) { ExecutionVertex mock = mock(ExecutionVertex.class); when(mock.getJobvertexId()).thenReturn(vertexId); when(mock.getParallelSubtaskIndex()).thenReturn(subtask); when(mock.getCurrentExecutionAttempt()).thenReturn(execution); when(mock.getTotalNumberOfParallelSubtasks()).thenReturn(parallelism); when(mock.getMaxParallelism()).thenReturn(parallelism); return mock; }
Example #22
Source File: DefaultExecutionTopologyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testGetResultPartition() { for (ExecutionVertex vertex : executionGraph.getAllExecutionVertices()) { for (Map.Entry<IntermediateResultPartitionID, IntermediateResultPartition> entry : vertex.getProducedPartitions().entrySet()) { IntermediateResultPartition partition = entry.getValue(); DefaultResultPartition schedulingResultPartition = adapter.getResultPartition(entry.getKey()); assertPartitionEquals(partition, schedulingResultPartition); } } }
Example #23
Source File: SchedulerTestUtils.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public static Execution getDummyTask() { ExecutionJobVertex executionJobVertex = mock(ExecutionJobVertex.class); ExecutionVertex vertex = mock(ExecutionVertex.class); when(vertex.getJobId()).thenReturn(new JobID()); when(vertex.toString()).thenReturn("TEST-VERTEX"); when(vertex.getJobVertex()).thenReturn(executionJobVertex); when(vertex.getJobvertexId()).thenReturn(new JobVertexID()); Execution execution = mock(Execution.class); when(execution.getVertex()).thenReturn(vertex); return execution; }
Example #24
Source File: CheckpointStateRestoreTest.java From flink with Apache License 2.0 | 5 votes |
private ExecutionJobVertex mockExecutionJobVertex(JobVertexID id, ExecutionVertex[] vertices) { ExecutionJobVertex vertex = mock(ExecutionJobVertex.class); when(vertex.getParallelism()).thenReturn(vertices.length); when(vertex.getMaxParallelism()).thenReturn(vertices.length); when(vertex.getJobVertexId()).thenReturn(id); when(vertex.getTaskVertices()).thenReturn(vertices); when(vertex.getOperatorIDs()).thenReturn(Collections.singletonList(OperatorIDPair.generatedIDOnly(OperatorID.fromJobVertexID(id)))); for (ExecutionVertex v : vertices) { when(v.getJobVertex()).thenReturn(vertex); } return vertex; }
Example #25
Source File: DefaultPreferredLocationsRetrieverTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testInputLocationsIgnoresEdgeOfTooManyLocations() { final TestingInputsLocationsRetriever.Builder locationRetrieverBuilder = new TestingInputsLocationsRetriever.Builder(); final ExecutionVertexID consumerId = new ExecutionVertexID(new JobVertexID(), 0); final int producerParallelism = ExecutionVertex.MAX_DISTINCT_LOCATIONS_TO_CONSIDER + 1; final List<ExecutionVertexID> producerIds = new ArrayList<>(producerParallelism); final JobVertexID producerJobVertexId = new JobVertexID(); for (int i = 0; i < producerParallelism; i++) { final ExecutionVertexID producerId = new ExecutionVertexID(producerJobVertexId, i); locationRetrieverBuilder.connectConsumerToProducer(consumerId, producerId); producerIds.add(producerId); } final TestingInputsLocationsRetriever inputsLocationsRetriever = locationRetrieverBuilder.build(); for (int i = 0; i < producerParallelism; i++) { inputsLocationsRetriever.markScheduled(producerIds.get(i)); } final PreferredLocationsRetriever locationsRetriever = new DefaultPreferredLocationsRetriever( id -> Optional.empty(), inputsLocationsRetriever); final CompletableFuture<Collection<TaskManagerLocation>> preferredLocations = locationsRetriever.getPreferredLocations(consumerId, Collections.emptySet()); assertThat(preferredLocations.getNow(null), hasSize(0)); }
Example #26
Source File: ExecutionGraphCheckpointCoordinatorTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the checkpoint coordinator is shut down if the execution graph * is finished. */ @Test public void testShutdownCheckpointCoordinatorOnFinished() throws Exception { final CompletableFuture<JobStatus> counterShutdownFuture = new CompletableFuture<>(); CheckpointIDCounter counter = new TestingCheckpointIDCounter(counterShutdownFuture); final CompletableFuture<JobStatus> storeShutdownFuture = new CompletableFuture<>(); CompletedCheckpointStore store = new TestingCompletedCheckpointStore(storeShutdownFuture); ExecutionGraph graph = createExecutionGraphAndEnableCheckpointing(counter, store); final CheckpointCoordinator checkpointCoordinator = graph.getCheckpointCoordinator(); assertThat(checkpointCoordinator, Matchers.notNullValue()); assertThat(checkpointCoordinator.isShutdown(), is(false)); graph.scheduleForExecution(); for (ExecutionVertex executionVertex : graph.getAllExecutionVertices()) { final Execution currentExecutionAttempt = executionVertex.getCurrentExecutionAttempt(); graph.updateState(new TaskExecutionState(graph.getJobID(), currentExecutionAttempt.getAttemptId(), ExecutionState.FINISHED)); } assertThat(graph.getTerminationFuture().get(), is(JobStatus.FINISHED)); assertThat(checkpointCoordinator.isShutdown(), is(true)); assertThat(counterShutdownFuture.get(), is(JobStatus.FINISHED)); assertThat(storeShutdownFuture.get(), is(JobStatus.FINISHED)); }
Example #27
Source File: ExecutionGraphToInputsLocationsRetrieverAdapter.java From flink with Apache License 2.0 | 5 votes |
private ExecutionVertex getExecutionVertex(ExecutionVertexID executionVertexId) { ExecutionJobVertex ejv = executionGraph.getJobVertex(executionVertexId.getJobVertexId()); checkState(ejv != null && ejv.getParallelism() > executionVertexId.getSubtaskIndex(), "Failed to find execution %s in execution graph.", executionVertexId); return ejv.getTaskVertices()[executionVertexId.getSubtaskIndex()]; }
Example #28
Source File: BackPressureRequestCoordinatorTest.java From flink with Apache License 2.0 | 5 votes |
TestingExecution( Executor executor, ExecutionVertex vertex, int attemptNumber, long globalModVersion, long startTimestamp, Time rpcTimeout, ExecutionState state, CompletionType completionType, long requestTimeout) { super(executor, vertex, attemptNumber, globalModVersion, startTimestamp, rpcTimeout); this.state = checkNotNull(state); this.completionType = checkNotNull(completionType); this.requestTimeout = requestTimeout; }
Example #29
Source File: CheckpointCoordinatorTestingUtils.java From flink with Apache License 2.0 | 5 votes |
static ExecutionJobVertex mockExecutionJobVertex(JobVertexID id, ExecutionVertex[] vertices) { ExecutionJobVertex vertex = mock(ExecutionJobVertex.class); when(vertex.getParallelism()).thenReturn(vertices.length); when(vertex.getMaxParallelism()).thenReturn(vertices.length); when(vertex.getJobVertexId()).thenReturn(id); when(vertex.getTaskVertices()).thenReturn(vertices); when(vertex.getOperatorIDs()).thenReturn(Collections.singletonList(OperatorIDPair.generatedIDOnly(OperatorID.fromJobVertexID(id)))); for (ExecutionVertex v : vertices) { when(v.getJobVertex()).thenReturn(vertex); } return vertex; }
Example #30
Source File: AdaptedRestartPipelinedRegionStrategyNG.java From flink with Apache License 2.0 | 5 votes |
private List<ExecutionVertex> sortVerticesTopologically(final Set<ExecutionVertex> vertices) { // org execution vertex by jobVertexId final Map<JobVertexID, List<ExecutionVertex>> verticesMap = new HashMap<>(); for (ExecutionVertex vertex : vertices) { verticesMap.computeIfAbsent(vertex.getJobvertexId(), id -> new ArrayList<>()).add(vertex); } // sort in jobVertex topological order final List<ExecutionVertex> sortedVertices = new ArrayList<>(vertices.size()); for (ExecutionJobVertex jobVertex : executionGraph.getVerticesTopologically()) { sortedVertices.addAll(verticesMap.getOrDefault(jobVertex.getJobVertexId(), Collections.emptyList())); } return sortedVertices; }