hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [1/2] hadoop git commit: HDFS-11112. Journal Nodes should refuse to format non-empty directories. Contributed by Yiqun Lin.
Date Thu, 02 Feb 2017 01:02:19 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 2f4cf07fb -> b64d9093e
  refs/heads/trunk b6f290d5b -> 6aa09dc28


HDFS-11112. Journal Nodes should refuse to format non-empty directories. Contributed by Yiqun
Lin.


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

Branch: refs/heads/trunk
Commit: 6aa09dc28adc3e7c81258568ac08996eee0356da
Parents: b6f290d
Author: Arpit Agarwal <arp@apache.org>
Authored: Wed Feb 1 16:51:58 2017 -0800
Committer: Arpit Agarwal <arp@apache.org>
Committed: Wed Feb 1 16:51:58 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hdfs/qjournal/server/JNStorage.java     |  7 +++++++
 .../apache/hadoop/hdfs/server/common/Storage.java  |  2 +-
 .../hadoop/hdfs/qjournal/server/TestJournal.java   | 17 +++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/6aa09dc2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java
index 77171a1..07c9286 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java
@@ -180,7 +180,14 @@ class JNStorage extends Storage {
   }
 
   void format(NamespaceInfo nsInfo) throws IOException {
+    unlockAll();
+    try {
+      sd.analyzeStorage(StartupOption.FORMAT, this, true);
+    } finally {
+      sd.unlock();
+    }
     setStorageInfo(nsInfo);
+
     LOG.info("Formatting journal " + sd + " with nsid: " + getNamespaceID());
     // Unlock the directory before formatting, because we will
     // re-analyze it after format(). The analyzeStorage() call

http://git-wip-us.apache.org/repos/asf/hadoop/blob/6aa09dc2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java
index 519c28f..1af7877 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java
@@ -550,7 +550,7 @@ public abstract class Storage extends StorageInfo {
           Files.newDirectoryStream(currentDir.toPath())) {
         if (dirStream.iterator().hasNext()) {
           throw new InconsistentFSStateException(root,
-              "Can't format the storage directory because the current/ "
+              "Can't format the storage directory because the current "
                   + "directory is not empty.");
         }
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/6aa09dc2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournal.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournal.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournal.java
index 5cdc1a3..4c36bcb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournal.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournal.java
@@ -204,6 +204,9 @@ public class TestJournal {
     
     // Close the journal in preparation for reformatting it.
     journal.close();
+    // Clear the storage directory before reformatting it
+    journal.getStorage().getJournalManager()
+        .getStorageDirectory().clearDirectory();
     journal.format(FAKE_NSINFO_2);
     
     assertEquals(0, journal.getLastPromisedEpoch());
@@ -417,4 +420,18 @@ public class TestJournal {
     }
   }
 
+  @Test
+  public void testFormatNonEmptyStorageDirectories() throws Exception {
+    try {
+      // Format again here and to format the non-empty directories in
+      // journal node.
+      journal.format(FAKE_NSINFO);
+      fail("Did not fail to format non-empty directories in journal node.");
+    } catch (IOException ioe) {
+      GenericTestUtils.assertExceptionContains(
+          "Can't format the storage directory because the current "
+              + "directory is not empty.", ioe);
+    }
+  }
+
 }


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