wolfboys commented on code in PR #2268:
URL: 
https://github.com/apache/incubator-streampark/pull/2268#discussion_r1112051673


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/task/CheckpointProcessor.java:
##########
@@ -52,30 +66,30 @@ public class CheckpointProcessor {
 
   @Autowired private SavePointService savePointService;
 
-  public void process(Long appId, CheckPoints checkPoints) {
-    CheckPoints.Latest latest = checkPoints.getLatest();
-    if (latest == null || latest.getCompleted() == null) {
-      return;
-    }
-    CheckPoints.CheckPoint checkPoint = latest.getCompleted();
-    Application application = applicationService.getById(appId);
+  public void process(Application application, @Nonnull CheckPoints 
checkPoints) {
+    checkPoints.getLatestCheckpoint().forEach(checkPoint -> 
process(application, checkPoint));
+  }
+
+  private void process(Application application, @Nonnull 
CheckPoints.CheckPoint checkPoint) {
+    String jobID = application.getJobId();
+    Long appId = application.getId();
     CheckPointStatus status = checkPoint.getCheckPointStatus();
 
     if (CheckPointStatus.COMPLETED.equals(status)) {
-      String cacheId = appId + "_" + application.getJobId();
-      Long latestId =
-          checkPointCache.get(
-              cacheId,
-              key -> {
-                SavePoint savePoint = savePointService.getLatest(appId);
-                return 
Optional.ofNullable(savePoint).map(SavePoint::getChkId).orElse(null);
-              });
-
-      if (latestId == null || latestId < checkPoint.getId()) {
-        saveSavepoint(checkPoint, application);
+      if (shouldStoreAsSavepoint(appId, jobID, checkPoint)) {

Review Comment:
   I suggest new create a bean to store these values(appId, jobId, checkid), 
the readability will be better. e.g:
   ```
   @Data
       public static class CheckPointKey {
           private Long appId;
           private String jobId;
           private Long checkId;
          
           public CheckPointKey(Long appId, String jobId, Long checkId) {
               this.appId = appId;
               this.jobId = jobId;
               this.checkId = checkId;
           }
           
           public String getSavePointId() {
               return String.format("%s_%s_%s", appId, jobId, checkId);
           }
   
         public String getCheckPointId() {
             return String.format("%s_%s", appId, jobId);
         }
       }
   
   ```
   what you think?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to