hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject hadoop git commit: HDFS-14028. HDFS OIV temporary dir deletes folder. Contributed by Adam Antal.
Date Fri, 26 Oct 2018 23:46:32 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 1851d06eb -> 4f10d7e23


HDFS-14028. HDFS OIV temporary dir deletes folder.
Contributed by Adam Antal.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4f10d7e2
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4f10d7e2
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4f10d7e2

Branch: refs/heads/trunk
Commit: 4f10d7e23fc0b757a9e94bc448187a6211b90f10
Parents: 1851d06
Author: Anu Engineer <aengineer@apache.org>
Authored: Fri Oct 26 16:41:23 2018 -0700
Committer: Anu Engineer <aengineer@apache.org>
Committed: Fri Oct 26 16:41:23 2018 -0700

----------------------------------------------------------------------
 .../offlineImageViewer/PBImageTextWriter.java    |  4 ++--
 .../TestOfflineImageViewer.java                  | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/4f10d7e2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/PBImageTextWriter.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/PBImageTextWriter.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/PBImageTextWriter.java
index 5a1644c..ee78395 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/PBImageTextWriter.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/PBImageTextWriter.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hdfs.tools.offlineImageViewer;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
-import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.PermissionStatus;
@@ -298,7 +297,8 @@ abstract class PBImageTextWriter implements Closeable {
     LevelDBMetadataMap(String baseDir) throws IOException {
       File dbDir = new File(baseDir);
       if (dbDir.exists()) {
-        FileUtils.deleteDirectory(dbDir);
+        throw new IOException("Folder " + dbDir + " already exists! Delete " +
+            "manually or provide another (not existing) directory!");
       }
       if (!dbDir.mkdirs()) {
         throw new IOException("Failed to mkdir on " + dbDir);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/4f10d7e2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
index 5574d7b..8c8d404 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
@@ -669,6 +669,25 @@ public class TestOfflineImageViewer {
     }
   }
 
+  @Test(expected = IOException.class)
+  public void testDelimitedWithExistingFolder() throws IOException,
+      InterruptedException {
+    File tempDelimitedDir = null;
+    try {
+      String tempDelimitedDirName = "tempDirDelimited";
+      String tempDelimitedDirPath = new FileSystemTestHelper().
+          getTestRootDir() + "/" + tempDelimitedDirName;
+      tempDelimitedDir = new File(tempDelimitedDirPath);
+      Assert.assertTrue("Couldn't create temp directory!",
+          tempDelimitedDir.mkdirs());
+      testPBDelimitedWriter(tempDelimitedDirPath);
+    } finally {
+      if (tempDelimitedDir != null) {
+        FileUtils.deleteDirectory(tempDelimitedDir);
+      }
+    }
+  }
+
   private void testPBDelimitedWriter(String db)
       throws IOException, InterruptedException {
     final String DELIMITER = "\t";


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message