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

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionGraph.java
 ##########
 @@ -1630,6 +1627,79 @@ public boolean updateState(TaskExecutionState state) {
                }
        }
 
+       private boolean updateStateInternal(final TaskExecutionState state, 
final Execution attempt) {
+               Map<String, Accumulator<?, ?>> accumulators;
+
+               switch (state.getExecutionState()) {
+                       case RUNNING:
+                               return attempt.switchToRunning();
+
+                       case FINISHED:
+                               // this deserialization is exception-free
+                               accumulators = deserializeAccumulators(state);
+                               attempt.markFinished(accumulators, 
state.getIOMetrics());
+                               return true;
+
+                       case CANCELED:
+                               // this deserialization is exception-free
+                               accumulators = deserializeAccumulators(state);
+                               attempt.completeCancelling(accumulators, 
state.getIOMetrics());
+                               return true;
+
+                       case FAILED:
+                               // this deserialization is exception-free
+                               accumulators = deserializeAccumulators(state);
+                               
attempt.markFailed(state.getError(userClassLoader), accumulators, 
state.getIOMetrics());
+                               return true;
+
+                       default:
+                               // we mark as failed and return false, which 
triggers the TaskManager
+                               // to remove the task
+                               attempt.fail(new Exception("TaskManager sent 
illegal state update: " + state.getExecutionState()));
+                               return false;
+               }
+       }
+
+       private void maybeReleasePartitions(final TaskExecutionState state, 
final Execution attempt) {
+               final ExecutionVertexID finishedExecutionVertex = 
attempt.getVertex().getID();
+
+               if (state.getExecutionState() == ExecutionState.FINISHED) {
+                       final List<IntermediateResultPartitionID> 
releasablePartitions = 
partitionReleaseStrategy.vertexFinished(finishedExecutionVertex);
+                       releasePartitions(releasablePartitions);
 
 Review comment:
   I still felt the following `createResultPartitionId` method seems complex 
because of involving in many components, I tried to find a way for constructing 
it easily.
   
   Another options is that `IntermediateResultPartition` could get 
`ResultPartitionID` directly via internal `IntermediateResultPartitionID` and 
producer `ExecutionVertex`. Further `SchedulingResultPartition` could also 
provide the getter method for `ResultPartitionID` via constructing from 
`IntermediateResultPartition`. I am not sure whether it is worth doing so.

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