pnowojski commented on a change in pull request #8133: [FLINK-12146][network] 
Remove unregister task from NetworkEnvironment to simplify the interface of 
ShuffleService
URL: https://github.com/apache/flink/pull/8133#discussion_r276146502
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java
 ##########
 @@ -882,6 +878,47 @@ else if (transitionState(current, ExecutionState.FAILED, 
t)) {
                }
        }
 
+       private void releaseNetworkResources() {
+               LOG.debug("Release task {} network resources (state: {}).", 
taskNameWithSubtask, getExecutionState());
+
+               for (ResultPartition partition : producedPartitions) {
+                       
taskEventDispatcher.unregisterPartition(partition.getPartitionId());
+               }
+
+               closeOrFailNetworkResources(isCanceledOrFailed(), 
getFailureCause());
+       }
+
+       /**
+        * There are two scenarios to release the network resources. One is 
from {@link TaskCanceler} to early
+        * release partitions and gates. Another is from task thread during 
task exiting.
+        *
+        * @param isFailed true if the task has failed.
+        * @param cause the exception that caused the task to fail, or null, if 
the task has not failed.
+        */
+       private void closeOrFailNetworkResources(boolean isFailed, @Nullable 
Throwable cause) {
 
 Review comment:
   Oh... ok, sorry by doing quick review I missed one that you have already 
deduplicated `TaskCanceler` code 😳 I thought that those are two separate issues 
that I'm commenting on, but clearly this is just one thing, so responding to 
both threads here in single comment:
   
   Yes, passing `invokable` is also not the pretties thing, but it looks like 
this issue is beside the scope of this PR, right?
   
   I haven't thought it through but passing `Runnable closeNetworkResources` 
seems fine to me as well. It has a drawback of being more or less the same 
thing, but with more vague name/type in an exchange of less overhead code. With 
simple class `TaskCloser` we could better specify concurrency contracts 
(`@ThreadSafe`) etc, but I think I would be fine both way.

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