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_r191931672
##########
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());
Review comment:
I would suggest to break the logic into two steps:
1. generate the toDelete list.
2. for each one in the list, deleteDir().
The benefit is that you can write a unit test for step 1 easily to make sure
the order is correct.
----------------------------------------------------------------
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