zhuzhurk commented on a change in pull request #7255: [FLINK-10945] Use 
InputDependencyConstraint to avoid resource dead…
URL: https://github.com/apache/flink/pull/7255#discussion_r246429640
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionVertex.java
 ##########
 @@ -726,6 +730,41 @@ void sendPartitionInfos() {
                }
        }
 
+       /**
+        * Check whether the InputDependencyConstraint is satisfied for this 
vertex.
+        *
+        * @return whether the input constraint is satisfied
+        */
+       public boolean checkInputDependencyConstraints() {
+               if (getExecutionGraph().getInputDependencyConstraint() == 
InputDependencyConstraint.ANY) {
+                       // InputDependencyConstraint == ANY
+                       return IntStream.range(0, 
inputEdges.length).anyMatch(this::isInputConsumable);
+               } else {
+                       // InputDependencyConstraint == ALL
+                       return IntStream.range(0, 
inputEdges.length).allMatch(this::isInputConsumable);
+               }
+       }
+
+       /**
+        * An input is consumable when
+        * 1. the source result is PIPELINED and one of the result partition 
has produced data.
+        * 2. the source result is BLOCKING and is FINISHED(all partitions are 
FINISHED).
+        *
+        * @return whether the input is consumable
+        */
+       public boolean isInputConsumable(int inputNumber) {
 
 Review comment:
   A vertex `Input` is a bit different from its corresponding 
`IntermediateResult` with `POINTWISE` edge. So we need the `inputEdges` info in 
ExecutionVertex.
   
   I changed it a bit to be more concise here: An input is consumable when when 
any partition in it is consumable. (whether a partition is consumable is 
different for PIPELINED and BLOCKING results)
   
   B.T.W I'm also thinking about a later improvement that we can decide whether 
the input is consumable according to its completeness percentage. It's also a 
configuration related to `inputEdges`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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