Java Code Examples for org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils#createSimpleTestGraph()

The following examples show how to use org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils#createSimpleTestGraph() . 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 vote down vote up
/**
 * 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: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * 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(new JobID(), 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
	}
}
 
Example 3
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * 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.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 4
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * 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
	}
}
 
Example 5
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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(new JobID(), 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)));
}
 
Example 6
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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(new JobID(), jobVertex);
	final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever =
			new ExecutionGraphToInputsLocationsRetrieverAdapter(eg);

	ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0);
	Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocation =
			inputsLocationsRetriever.getTaskManagerLocation(executionVertexId);

	assertFalse(taskManagerLocation.isPresent());
}
 
Example 7
Source File: DefaultSchedulingPipelinedRegionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests if the consumed inputs of the pipelined regions are computed
 * correctly using the Job graph below.
 * <pre>
 *          c
 *        /  X
 * a -+- b   e
 *       \  /
 *        d
 * </pre>
 * Pipelined regions: {a}, {b, c, d, e}
 */
@Test
public void returnsIncidentBlockingPartitions() throws Exception {
	final JobVertex a = ExecutionGraphTestUtils.createNoOpVertex(1);
	final JobVertex b = ExecutionGraphTestUtils.createNoOpVertex(1);
	final JobVertex c = ExecutionGraphTestUtils.createNoOpVertex(1);
	final JobVertex d = ExecutionGraphTestUtils.createNoOpVertex(1);
	final JobVertex e = ExecutionGraphTestUtils.createNoOpVertex(1);

	b.connectNewDataSetAsInput(a, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING);
	c.connectNewDataSetAsInput(b, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
	d.connectNewDataSetAsInput(b, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
	e.connectNewDataSetAsInput(c, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING);
	e.connectNewDataSetAsInput(d, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);

	final ExecutionGraph simpleTestGraph = ExecutionGraphTestUtils.createSimpleTestGraph(a, b, c, d, e);
	final DefaultExecutionTopology topology = new DefaultExecutionTopology(simpleTestGraph);

	final DefaultSchedulingPipelinedRegion firstPipelinedRegion = topology.getPipelinedRegionOfVertex(new ExecutionVertexID(a.getID(), 0));
	final DefaultSchedulingPipelinedRegion secondPipelinedRegion = topology.getPipelinedRegionOfVertex(new ExecutionVertexID(e.getID(), 0));

	final DefaultExecutionVertex vertexB0 = topology.getVertex(new ExecutionVertexID(b.getID(), 0));
	final IntermediateResultPartitionID b0ConsumedResultPartition = Iterables.getOnlyElement(vertexB0.getConsumedResults()).getId();

	final Set<IntermediateResultPartitionID> secondPipelinedRegionConsumedResults = IterableUtils.toStream(secondPipelinedRegion.getConsumedResults())
		.map(DefaultResultPartition::getId)
		.collect(Collectors.toSet());

	assertThat(firstPipelinedRegion.getConsumedResults().iterator().hasNext(), is(false));
	assertThat(secondPipelinedRegionConsumedResults, contains(b0ConsumedResultPartition));
}
 
Example 8
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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)));
}
 
Example 9
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}