echauchot commented on a change in pull request #13040:
URL: https://github.com/apache/flink/pull/13040#discussion_r492131145



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CompletedCheckpoint.java
##########
@@ -210,6 +221,21 @@ public void 
registerSharedStatesAfterRestored(SharedStateRegistry sharedStateReg
        //  Discard and Dispose
        // 
------------------------------------------------------------------------
 
+       /**
+        * Asynchronously call a discard on the ioExecutor
+        * (FixedThreadPool of configurable size of default 4*CPU cores)
+        * and count the number of checkpoints that are waiting to clean.
+        */
+       void 
asyncDiscardCheckpointAndCountCheckpoint(ThrowingConsumer<CompletedCheckpoint, 
Exception> discardCallback, Executor executor){
+               cleanCallback.accept(() -> {
+                       try {
+                               discardCallback.accept(this);

Review comment:
       This is the code you gave at the end of [your 
comment](https://github.com/apache/flink/pull/13040#issuecomment-686639977) I 
just reused it. But anyway no problem about trying to improve it.
   
   Regarding your proposed refactoring: I understand that in place of passing 
callbacks `CompletedCheckpoint::discardOnSubsume` and 
`CompletedCheckpoint::discardOnShutdown`, as they both call 
`CompletedCheckpoint.doDiscard()` you prefer calling it directly. But it would 
require to evaluate the conditions inside ZooKeeperStore:
   
   - for `CompletedCheckpoint::discardOnSubsume`: means moving condition `if 
(props.discardOnSubsumed()) `
   
   - for `CompletedCheckpoint::discardOnShutdown`: means moving conditions `if 
(jobStatus == JobStatus.FINISHED && props.discardOnJobFinished() ||
                                jobStatus == JobStatus.CANCELED && 
props.discardOnJobCancelled() ||
                                jobStatus == JobStatus.FAILED && 
props.discardOnJobFailed() ||
                                jobStatus == JobStatus.SUSPENDED && 
props.discardOnJobSuspended()) `
   => I'm not sure it's worth it, violating the integrity of 
CompletedCheckpoint object for the sake a readable 
`asyncDiscardCheckpointAndCountCheckpoint` method.




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


Reply via email to