Thesharing commented on a change in pull request #15314:
URL: https://github.com/apache/flink/pull/15314#discussion_r603763928



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/failover/flip1/partitionrelease/ConsumerRegionGroupExecutionViewMaintainerTest.java
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.scheduler.strategy.TestingSchedulingExecutionVertex;
+import 
org.apache.flink.runtime.scheduler.strategy.TestingSchedulingPipelinedRegion;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link ConsumerRegionGroupExecutionView} and {@link
+ * ConsumerRegionGroupExecutionViewMaintainer}.
+ */
+public class ConsumerRegionGroupExecutionViewMaintainerTest extends TestLogger 
{
+
+    TestingSchedulingExecutionVertex producer;

Review comment:
       Thanks for reminding. Resolved.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/flip1/partitionrelease/ConsumerRegionGroupExecutionViewMaintainer.java
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.scheduler.strategy.ConsumedPartitionGroup;
+import org.apache.flink.runtime.scheduler.strategy.SchedulingPipelinedRegion;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Track the finished progress of {@link ConsumerRegionGroupExecutionView}s.
+ *
+ * <p>NOTE: It only contains {@link SchedulingPipelinedRegion}s that have 
{@link
+ * ConsumedPartitionGroup}s.
+ */
+class ConsumerRegionGroupExecutionViewMaintainer {
+
+    /**
+     * The list of {@link ConsumerRegionGroupExecutionView}s that a 
SchedulingPipelinedRegion
+     * belongs to.
+     */
+    private final Map<SchedulingPipelinedRegion, 
List<ConsumerRegionGroupExecutionView>>

Review comment:
       Resolved.

##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/failover/flip1/partitionrelease/ConsumerRegionGroupExecutionViewMaintainerTest.java
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.scheduler.strategy.TestingSchedulingExecutionVertex;
+import 
org.apache.flink.runtime.scheduler.strategy.TestingSchedulingPipelinedRegion;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link ConsumerRegionGroupExecutionView} and {@link
+ * ConsumerRegionGroupExecutionViewMaintainer}.
+ */
+public class ConsumerRegionGroupExecutionViewMaintainerTest extends TestLogger 
{
+
+    TestingSchedulingExecutionVertex producer;
+    TestingSchedulingExecutionVertex consumer;
+
+    TestingSchedulingPipelinedRegion producerRegion;
+    TestingSchedulingPipelinedRegion consumerRegion;
+
+    ConsumerRegionGroupExecutionView consumerRegionGroupExecutionView;
+    ConsumerRegionGroupExecutionViewMaintainer 
consumerRegionGroupExecutionViewMaintainer;
+
+    @Before
+    public void setup() {
+        createProducerAndConsumer();
+        createConsumerRegionGroupExecutionViewTracker();
+    }
+
+    @Test
+    public void testRegionFinished() throws Exception {
+        
consumerRegionGroupExecutionViewMaintainer.regionFinished(consumerRegion);
+        assertTrue(consumerRegionGroupExecutionView.isFinished());
+    }
+
+    @Test
+    public void testRegionUnfinished() throws Exception {
+        
consumerRegionGroupExecutionViewMaintainer.regionFinished(consumerRegion);
+        
consumerRegionGroupExecutionViewMaintainer.regionUnfinished(consumerRegion);
+
+        assertFalse(consumerRegionGroupExecutionView.isFinished());
+    }
+
+    @Test
+    public void testRegionFinishedMultipleTimes() throws Exception {
+        
consumerRegionGroupExecutionViewMaintainer.regionFinished(consumerRegion);
+        
consumerRegionGroupExecutionViewMaintainer.regionFinished(consumerRegion);
+
+        assertTrue(consumerRegionGroupExecutionView.isFinished());
+    }
+
+    @Test
+    public void testRegionUnfinishedMultipleTimes() throws Exception {
+        
consumerRegionGroupExecutionViewMaintainer.regionUnfinished(consumerRegion);
+        
consumerRegionGroupExecutionViewMaintainer.regionUnfinished(consumerRegion);
+
+        assertFalse(consumerRegionGroupExecutionView.isFinished());
+
+        
consumerRegionGroupExecutionViewMaintainer.regionFinished(consumerRegion);
+        assertTrue(consumerRegionGroupExecutionView.isFinished());
+    }
+
+    @Test
+    public void testFinishWrongRegion() {
+        
consumerRegionGroupExecutionViewMaintainer.regionFinished(producerRegion);
+        assertFalse(consumerRegionGroupExecutionView.isFinished());
+    }
+
+    @Test
+    public void testUnfinishedWrongRegion() {
+        
consumerRegionGroupExecutionViewMaintainer.regionUnfinished(producerRegion);
+        assertFalse(consumerRegionGroupExecutionView.isFinished());
+    }
+
+    private void createProducerAndConsumer() {
+        producer = TestingSchedulingExecutionVertex.newBuilder().build();
+        consumer = TestingSchedulingExecutionVertex.newBuilder().build();
+
+        producerRegion = new 
TestingSchedulingPipelinedRegion(Collections.singleton(producer));
+        consumerRegion = new 
TestingSchedulingPipelinedRegion(Collections.singleton(consumer));
+    }
+
+    private void createConsumerRegionGroupExecutionViewTracker() {

Review comment:
       Resolved.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/flip1/partitionrelease/RegionPartitionReleaseStrategy.java
##########
@@ -101,27 +128,24 @@ private PipelinedRegionExecutionView 
getPipelinedRegionExecutionViewForVertex(
     }
 
     private List<IntermediateResultPartitionID> filterReleasablePartitions(
-            final Iterable<? extends SchedulingResultPartition> 
schedulingResultPartitions) {
-        return IterableUtils.toStream(schedulingResultPartitions)
-                .distinct()
-                .map(SchedulingResultPartition::getId)
-                .filter(this::areConsumerRegionsFinished)
-                .collect(Collectors.toList());
-    }
-
-    private boolean areConsumerRegionsFinished(
-            final IntermediateResultPartitionID resultPartitionId) {
-        final SchedulingResultPartition resultPartition =
-                schedulingTopology.getResultPartition(resultPartitionId);
-        return IterableUtils.toStream(resultPartition.getConsumers())
-                .map(SchedulingExecutionVertex::getId)
-                .allMatch(this::isRegionOfVertexFinished);
-    }
+            final Iterable<ConsumedPartitionGroup> consumedPartitionGroups) {
+
+        final List<IntermediateResultPartitionID> filteredPartitions = new 
ArrayList<>();

Review comment:
       Resolved.




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


Reply via email to