You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/09/06 08:01:47 UTC

[GitHub] [flink] gaoyunhaii commented on a diff in pull request #20534: [FLINK-28860] Fix CacheITCase

gaoyunhaii commented on code in PR #20534:
URL: https://github.com/apache/flink/pull/20534#discussion_r963310244


##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java:
##########
@@ -906,27 +906,40 @@ public CompletableFuture<Acknowledge> updatePartitions(
     }
 
     @Override
-    public void releaseOrPromotePartitions(
-            JobID jobId,
-            Set<ResultPartitionID> partitionToRelease,
-            Set<ResultPartitionID> partitionsToPromote) {
+    public void releasePartitions(JobID jobId, Set<ResultPartitionID> partitionIds) {
+        try {
+            partitionTracker.stopTrackingAndReleaseJobPartitions(partitionIds);
+            closeJobManagerConnectionIfNoAllocatedResources(jobId);
+        } catch (Throwable t) {
+            onFatalError(t);
+        }
+    }
+
+    @Override
+    public CompletableFuture<Acknowledge> promotePartitions(
+            JobID jobId, Set<ResultPartitionID> partitionIds) {
+        CompletableFuture<Acknowledge> future = new CompletableFuture<>();
         try {
-            partitionTracker.stopTrackingAndReleaseJobPartitions(partitionToRelease);
-            partitionTracker.promoteJobPartitions(partitionsToPromote);
+            partitionTracker.promoteJobPartitions(partitionIds);
             if (establishedResourceManagerConnection != null) {
                 establishedResourceManagerConnection
                         .getResourceManagerGateway()
                         .reportClusterPartitions(
-                                getResourceID(), partitionTracker.createClusterPartitionReport());
+                                getResourceID(), partitionTracker.createClusterPartitionReport())
+                        .thenAccept(ignore -> future.complete(Acknowledge.get()));
+            } else {
+                future.completeExceptionally(
+                        new RuntimeException(
+                                "Task executor is not connecting to ResourceManager. "
+                                        + "Fail to report cluster partition to ResourceManager"));
             }
             closeJobManagerConnectionIfNoAllocatedResources(jobId);
         } catch (Throwable t) {
-            // TODO: Do we still need this catch branch?
             onFatalError(t);
+            future.completeExceptionally(t);

Review Comment:
   Might move `future.completeExceptionally(t)` before `onFatalError(t)`.



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

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org