You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/06/14 03:55:16 UTC

[GitHub] [flink] eaglewatcherwb commented on a change in pull request #8688: [FLINK-12760] [runtime] Implement ExecutionGraph to InputsLocationsRetriever Adapter

eaglewatcherwb commented on a change in pull request #8688: [FLINK-12760] [runtime] Implement ExecutionGraph to InputsLocationsRetriever Adapter
URL: https://github.com/apache/flink/pull/8688#discussion_r293651290
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/EGBasedInputsLocationsRetrieverTest.java
 ##########
 @@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.scheduler;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.execution.ExecutionState;
+import org.apache.flink.runtime.executiongraph.ExecutionGraph;
+import org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils;
+import org.apache.flink.runtime.executiongraph.TestingSlotProvider;
+import org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+import org.apache.flink.runtime.jobgraph.DistributionPattern;
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.jobmaster.TestingLogicalSlot;
+import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider;
+import org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID;
+import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.empty;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Tests for {@link EGBasedInputsLocationsRetriever}.
+ */
+public class EGBasedInputsLocationsRetrieverTest extends TestLogger {
+
+	/**
+	 * 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 EGBasedInputsLocationsRetriever inputsLocationsRetriever = new EGBasedInputsLocationsRetriever(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, contains(Arrays.asList(evIdOfProducer1), Arrays.asList(evIdOfProducer2)));
+	}
+
+	/**
+	 * Tests that when execution is not scheduled, getting task manager location will return null.
+	 */
+	@Test
+	public void testGetNullTaskManagerLocationIfNotScheduled() throws Exception {
+		final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1);
+
+		final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(new JobID(), jobVertex);
+		final EGBasedInputsLocationsRetriever inputsLocationsRetriever = new EGBasedInputsLocationsRetriever(eg);
+
+		ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0);
+		Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocation =
+				inputsLocationsRetriever.getTaskManagerLocation(executionVertexId);
+
+		assertFalse(taskManagerLocation.isPresent());
+	}
+
+	/**
+	 * Tests that when exection is not scheduled, getting task manager location will return null.
 
 Review comment:
   typo: execution
   The doc seems mismatch with the unit test.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services