zentol commented on a change in pull request #8316: [FLINK-12369] 
[coordination] Implement a region failover strategy regarding the next version 
FailoverStrategy interfaces
URL: https://github.com/apache/flink/pull/8316#discussion_r282025692
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexTest.java
 ##########
 @@ -0,0 +1,219 @@
+/*
+ * 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.executiongraph;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.JobException;
+import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.blob.VoidBlobWriter;
+import 
org.apache.flink.runtime.executiongraph.failover.RestartPipelinedRegionStrategy;
+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.jobgraph.JobVertexID;
+import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
+import org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID;
+import org.apache.flink.runtime.testingUtils.TestingUtils;
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import static 
org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests of {@link ExecutionVertex}.
+ */
+public class ExecutionVertexTest extends TestLogger {
+
+       @Test
+       public void testExecutionVertexID() {
+               try {
+                       final ExecutionJobVertex ejv = getExecutionVertex(new 
JobVertexID());
+                       final ExecutionVertex vertex = new ExecutionVertex(ejv, 
123, new IntermediateResult[0],
+                               AkkaUtils.getDefaultTimeout());
+
+                       assertEquals(vertex.getExecutionVertexID(), new 
ExecutionVertexID(ejv.getJobVertexId(), 123));
+               }
+               catch (Exception e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               }
+       }
+
+       /**
+        * Tests the input edges query of execution vertices.
+        *
+        * <pre>
+        *     (v1)--(all-to-all)--+
+        *                        +--(v3)---->(v4)
+        *     (v2)--(pointwise)--+
+        * </pre>
+        */
+       @Test
+       public void testExecutionVertexInputEdgeQuery() throws Exception {
+
+               final JobID jobId = new JobID();
+               final String jobName = "Test Job Sample Name";
+
+               JobVertex v1 = new JobVertex("vertex1");
+               JobVertex v2 = new JobVertex("vertex2");
+               JobVertex v3 = new JobVertex("vertex3");
+               JobVertex v4 = new JobVertex("vertex4");
+
+               v1.setParallelism(5);
+               v2.setParallelism(5);
+               v3.setParallelism(5);
+               v4.setParallelism(5);
+
+               v1.setInvokableClass(AbstractInvokable.class);
+               v2.setInvokableClass(AbstractInvokable.class);
+               v3.setInvokableClass(AbstractInvokable.class);
+               v4.setInvokableClass(AbstractInvokable.class);
+
+               v3.connectNewDataSetAsInput(v1, DistributionPattern.ALL_TO_ALL, 
ResultPartitionType.PIPELINED);
+               v3.connectNewDataSetAsInput(v2, DistributionPattern.POINTWISE, 
ResultPartitionType.PIPELINED);
+               v4.connectNewDataSetAsInput(v3, DistributionPattern.ALL_TO_ALL, 
ResultPartitionType.PIPELINED);
+
+               List<JobVertex> ordered = new 
ArrayList<JobVertex>(Arrays.asList(v1, v2, v3, v4));
+
+               final JobInformation jobInformation = new DummyJobInformation(
+                       jobId,
+                       jobName);
+
+               ExecutionGraph eg = new ExecutionGraph(
+                       jobInformation,
+                       TestingUtils.defaultExecutor(),
+                       TestingUtils.defaultExecutor(),
+                       AkkaUtils.getDefaultTimeout(),
+                       new NoRestartStrategy(),
+                       new RestartPipelinedRegionStrategy.Factory(),
+                       new TestingSlotProvider(ignored -> new 
CompletableFuture<>()),
+                       ExecutionGraph.class.getClassLoader(),
+                       VoidBlobWriter.getInstance(),
+                       AkkaUtils.getDefaultTimeout());
+               try {
+                       eg.attachJobGraph(ordered);
+               }
+               catch (JobException e) {
+                       e.printStackTrace();
+                       fail("Job failed with exception: " + e.getMessage());
+               }
+
+               ExecutionVertex ev31 = 
eg.getAllVertices().get(v3.getID()).getTaskVertices()[0];
+               int input1Count = 0;
+               int input2Count = 0;
+               for (ExecutionEdge edge : ev31.getInputEdges()) {
+                       if 
(edge.getSource().getProducer().getJobvertexId().equals(v1.getID())) {
+                               input1Count++;
+                       } else if 
(edge.getSource().getProducer().getJobvertexId().equals(v2.getID())) {
+                               input2Count++;
+                       } else {
+                               fail("Unexpected input edge");
+                       }
+               }
+
+               // execution vertex3-1 should have connection to all vertex1 
parallelism, and only one connection with vertex2(-1)
+               assertEquals(5, input1Count);
+               assertEquals(1, input2Count);
+       }
+
+       /**
+        * Tests the output edges query of execution vertices.
+        *
+        * <pre>
+        *                     +--(all-to-all)--(v3)
+        *     (v1)---->(v2) --+
+        *                     +--(pointwise)--(v4)
+        * </pre>
+        */
+       @Test
+       public void testExecutionVertexOutputEdgeQuery() throws Exception {
+
+               final JobID jobId = new JobID();
+               final String jobName = "Test Job Sample Name";
+
+               JobVertex v1 = new JobVertex("vertex1");
+               JobVertex v2 = new JobVertex("vertex2");
+               JobVertex v3 = new JobVertex("vertex3");
+               JobVertex v4 = new JobVertex("vertex4");
+
+               v1.setParallelism(5);
+               v2.setParallelism(5);
+               v3.setParallelism(5);
+               v4.setParallelism(5);
+
+               v1.setInvokableClass(AbstractInvokable.class);
+               v2.setInvokableClass(AbstractInvokable.class);
+               v3.setInvokableClass(AbstractInvokable.class);
+               v4.setInvokableClass(AbstractInvokable.class);
+
+               v2.connectNewDataSetAsInput(v1, DistributionPattern.ALL_TO_ALL, 
ResultPartitionType.PIPELINED);
+               v3.connectNewDataSetAsInput(v2, DistributionPattern.ALL_TO_ALL, 
ResultPartitionType.PIPELINED);
+               v4.connectNewDataSetAsInput(v2, DistributionPattern.POINTWISE, 
ResultPartitionType.PIPELINED);
+
+               List<JobVertex> ordered = new 
ArrayList<JobVertex>(Arrays.asList(v1, v2, v3, v4));
+
+               final JobInformation jobInformation = new DummyJobInformation(
+                       jobId,
+                       jobName);
+
+               ExecutionGraph eg = new ExecutionGraph(
+                       jobInformation,
+                       TestingUtils.defaultExecutor(),
+                       TestingUtils.defaultExecutor(),
+                       AkkaUtils.getDefaultTimeout(),
+                       new NoRestartStrategy(),
+                       new RestartPipelinedRegionStrategy.Factory(),
+                       new TestingSlotProvider(ignored -> new 
CompletableFuture<>()),
+                       ExecutionGraph.class.getClassLoader(),
+                       VoidBlobWriter.getInstance(),
+                       AkkaUtils.getDefaultTimeout());
+               try {
+                       eg.attachJobGraph(ordered);
+               }
+               catch (JobException e) {
 
 Review comment:
   let the exception bubble up instead

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to