nlu90 closed pull request #2883: check checkpoint file exists before deleting it
URL: https://github.com/apache/incubator-heron/pull/2883
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/heron/statefulstorages/src/java/org/apache/heron/statefulstorage/localfs/LocalFileSystemStorage.java
 
b/heron/statefulstorages/src/java/org/apache/heron/statefulstorage/localfs/LocalFileSystemStorage.java
index 13f4d5c4bd..7b4735c874 100644
--- 
a/heron/statefulstorages/src/java/org/apache/heron/statefulstorage/localfs/LocalFileSystemStorage.java
+++ 
b/heron/statefulstorages/src/java/org/apache/heron/statefulstorage/localfs/LocalFileSystemStorage.java
@@ -109,17 +109,21 @@ public void dispose(String topologyName, String 
oldestCheckpointPreserved,
       }
     } else {
       String[] names = new File(topologyCheckpointRoot).list();
-      for (String name : names) {
-        if (name.compareTo(oldestCheckpointPreserved) < 0) {
-          FileUtils.deleteDir(new File(topologyCheckpointRoot, name), true);
+      if (names == null) {
+        LOG.warning("There is no such checkpoint root path: " + 
topologyCheckpointRoot);
+      } else {
+        for (String name : names) {
+          if (name.compareTo(oldestCheckpointPreserved) < 0) {
+            FileUtils.deleteDir(new File(topologyCheckpointRoot, name), true);
+          }
         }
-      }
 
-      // Do a double check. Now all checkpoints with smaller checkpoint id 
should be cleaned
-      names = new File(topologyCheckpointRoot).list();
-      for (String name : names) {
-        if (name.compareTo(oldestCheckpointPreserved) < 0) {
-          throw new StatefulStorageException("Failed to delete " + name);
+        // Do a double check. Now all checkpoints with smaller checkpoint id 
should be cleaned
+        names = new File(topologyCheckpointRoot).list();
+        for (String name : names) {
+          if (name.compareTo(oldestCheckpointPreserved) < 0) {
+            throw new StatefulStorageException("Failed to delete " + name);
+          }
         }
       }
     }


 

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