eaglewatcherwb commented on a change in pull request #8309: [FLINK-12229] 
[runtime] Implement LazyFromSourcesScheduling Strategy
URL: https://github.com/apache/flink/pull/8309#discussion_r283082959
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/strategy/StrategyTestUtil.java
 ##########
 @@ -0,0 +1,102 @@
+/*
+ * 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.strategy;
+
+import org.apache.flink.api.common.InputDependencyConstraint;
+import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+import org.apache.flink.runtime.jobgraph.IntermediateDataSetID;
+import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+import org.apache.flink.runtime.scheduler.ExecutionVertexDeploymentOption;
+
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+/**
+ * Strategy test utilities.
+ */
+public class StrategyTestUtil {
+
+       static void initVerticesAndPartitions(
+               TestingSchedulingTopology schedulingTopology,
+               ResultPartitionType[] partitionTypes,
+               InputDependencyConstraint[] inputDependencyConstraints,
+               TestingSchedulingExecutionVertex[][] vertices,
+               TestingSchedulingResultPartition[][] partitions) {
+
+               ResultPartitionID[][] resultPartitionIds = new 
ResultPartitionID[vertices.length - 1][vertices[0].length];
+               initVerticesAndPartitions(schedulingTopology, partitionTypes, 
inputDependencyConstraints,
+                       vertices, resultPartitionIds, partitions);
+       }
+
+       static void initVerticesAndPartitions(
+               TestingSchedulingTopology schedulingTopology,
+               ResultPartitionType[] partitionTypes,
+               InputDependencyConstraint[] inputDependencyConstraints,
+               TestingSchedulingExecutionVertex[][] vertices,
+               ResultPartitionID[][] resultPartitionIds,
+               TestingSchedulingResultPartition[][] partitions) {
+
+               final int jobVertexCnt = vertices.length;
+               final int taskCnt = vertices[0].length;
+
+               JobVertexID[] jobVertexIds = new JobVertexID[jobVertexCnt];
+               IntermediateDataSetID[] dataSetIds = new 
IntermediateDataSetID[jobVertexCnt];
+               for (int i = 0; i < jobVertexCnt; i++) {
+                       jobVertexIds[i] = new JobVertexID();
+                       dataSetIds[i] = new IntermediateDataSetID();
+                       
schedulingTopology.addInputDependencyConstraint(jobVertexIds[i], 
inputDependencyConstraints[i]);
+               }
+
+               for (int i = 0; i < jobVertexCnt; i++) {
+                       for (int j = 0; j < taskCnt; j++) {
+                               vertices[i][j] = new 
TestingSchedulingExecutionVertex(jobVertexIds[i], j);
+                               
schedulingTopology.addSchedulingExecutionVertex(vertices[i][j]);
+
+                               if (i != jobVertexCnt - 1) {
+                                       partitions[i][j] = new 
TestingSchedulingResultPartition(dataSetIds[i], new 
IntermediateResultPartitionID(),
+                                               partitionTypes[i], 
vertices[i][j]);
+                                       resultPartitionIds[i][j] = new 
ResultPartitionID(partitions[i][j].getId(), new ExecutionAttemptID());
+                                       
schedulingTopology.addResultPartition(partitions[i][j].getId(), 
partitions[i][j]);
 
 Review comment:
   OK

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to