nwangtw commented on a change in pull request #2910: make LocalFSStorage clean 
checkpoints before store
URL: https://github.com/apache/incubator-heron/pull/2910#discussion_r191932377
 
 

 ##########
 File path: 
heron/statefulstorages/src/java/org/apache/heron/statefulstorage/localfs/LocalFileSystemStorage.java
 ##########
 @@ -134,6 +146,23 @@ public void dispose(String topologyName, String 
oldestCheckpointPreserved,
     }
   }
 
+  private void cleanCheckpoints(String path, int remaining) throws 
StatefulStorageException {
+    if (FileUtils.isDirectoryExists(path) && FileUtils.hasChildren(path)) {
+      File[] children = new File(path).listFiles();
+      Arrays.sort(children, Comparator.reverseOrder());
+
+      // only keep the latest N remaining files, delete others
+      for (int i = remaining; i < children.length; i++) {
 
 Review comment:
   if we do:
   for (int i = 0; i < children.length - remaining; ++i) {
   }
   
   we dont need Comparator, and the sorting might be slightly faster because 
the list might be likely to be in the same order already.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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