zentol commented on a change in pull request #8804: [FLINK-12883][WIP][runtime] 
Add elaborated partition release logic
URL: https://github.com/apache/flink/pull/8804#discussion_r295769220
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/flip1/partitionrelease/RegionPartitionReleaseStrategy.java
 ##########
 @@ -0,0 +1,170 @@
+/*
+ * 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.failover.flip1.partitionrelease;
+
+import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID;
+import org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID;
+import org.apache.flink.runtime.scheduler.strategy.SchedulingExecutionVertex;
+import org.apache.flink.runtime.scheduler.strategy.SchedulingResultPartition;
+import org.apache.flink.runtime.scheduler.strategy.SchedulingTopology;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * Releases blocking intermediate result partitions that are incident to a 
{@link PipelinedRegion},
+ * as soon as the region's execution vertices are finished.
+ */
+public class RegionPartitionReleaseStrategy implements 
PartitionReleaseStrategy {
+
+       private final SchedulingTopology schedulingTopology;
+
+       private final Map<PipelinedRegion, 
PipelinedRegionConsumedBlockingPartitions> consumedBlockingPartitionsByRegion = 
new IdentityHashMap<>();
+
+       private final Map<ExecutionVertexID, PipelinedRegionExecutionView> 
regionExecutionViewByVertex = new HashMap<>();
+
+       public RegionPartitionReleaseStrategy(
+                       final SchedulingTopology schedulingTopology,
+                       final Set<PipelinedRegion> pipelinedRegions) {
+
+               this.schedulingTopology = checkNotNull(schedulingTopology);
+
+               checkNotNull(pipelinedRegions);
+               initConsumedBlockingPartitionsByRegion(pipelinedRegions);
 
 Review comment:
   i'm wondering whether we shouldn't use the Failover classes here, purely 
because _similar_ code (restart strategy, pipelined region computation) also 
works against that. I'm just worried that we end up re-inventing the wheel; 
everything we do here the `RestartPipelinedRegionStrategy` also has to do at 
some point.
   
   AN example is determining the set of input vertices. If you'd rely on 
`FailoverRegion` instead of your new `PipelinedRegion`, you could extend the 
FailoverRegion with the below method (just maybe without streams), allowing us 
to share the logic between the release and failover strategies.
   
   ```
   public Set<FailoverVertex> getInputVertices() {
        return getAllExecutionVertices().stream()
                .map(FailoverVertex::getInputEdges)
                .flatMap(edges -> StreamSupport.stream(edges.spliterator(), 
false))
                .map(FailoverEdge::getSourceVertex)
                .filter(vertex -> !executionVertices.contains(vertex))
                .collect(Collectors.toSet());
   }
   ```

----------------------------------------------------------------
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