You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by nl...@apache.org on 2018/05/04 20:24:54 UTC

[incubator-heron] branch master updated: check checkpoint file exists before deleting it (#2883)

This is an automated email from the ASF dual-hosted git repository.

nlu90 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git


The following commit(s) were added to refs/heads/master by this push:
     new 2008084  check checkpoint file exists before deleting it (#2883)
2008084 is described below

commit 20080841b831f342ad0338bcf490252a3a30653d
Author: Neng Lu <fr...@gmail.com>
AuthorDate: Fri May 4 13:24:51 2018 -0700

    check checkpoint file exists before deleting it (#2883)
---
 .../localfs/LocalFileSystemStorage.java            | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

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 f32a114..6e40053 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
@@ -114,17 +114,21 @@ public class LocalFileSystemStorage implements IStatefulStorage {
       }
     } 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);
+          }
         }
       }
     }

-- 
To stop receiving notification emails like this one, please contact
nlu90@apache.org.