hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r1486150 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java
Date Fri, 24 May 2013 18:26:33 GMT
Author: suresh
Date: Fri May 24 18:26:33 2013
New Revision: 1486150

URL: http://svn.apache.org/r1486150
Log:
HDFS-3131. Merge r1305688 from trunk

Modified:
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1486150&r1=1486149&r2=1486150&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri May 24
18:26:33 2013
@@ -620,6 +620,8 @@ Release 2.0.3-alpha - 2013-02-06
 
     HDFS-4053. Increase the default block size. (eli)
 
+    HDFS-3131. Improve TestStorageRestore. (Brandon Li via atm)
+
   OPTIMIZATIONS
 
     HDFS-3429. DataNode reads checksums even if client does not need them (todd)

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java?rev=1486150&r1=1486149&r2=1486150&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java
Fri May 24 18:26:33 2013
@@ -362,4 +362,72 @@ public class TestStorageRestore {
       }
     }
   }
+  
+  /**
+   * 1. create DFS cluster with 3 storage directories
+   *    - 2 EDITS_IMAGE(name1, name2), 1 EDITS(name3)
+   * 2. create a file
+   * 3. corrupt/disable name2 and name3 by removing rwx permission
+   * 4. run doCheckpoint
+   *    - will fail on removed dirs (which invalidates them)
+   * 5. write another file
+   * 6. check there is only one healthy storage dir
+   * 7. run doCheckpoint - recover should fail but checkpoint should succeed
+   * 8. check there is still only one healthy storage dir
+   * 9. restore the access permission for name2 and name 3, run checkpoint again
+   * 10.verify there are 3 healthy storage dirs.
+   */
+  @Test
+  public void testStorageRestoreFailure() throws Exception {
+
+    SecondaryNameNode secondary = null;
+    try {
+      cluster = new MiniDFSCluster.Builder(config).numDataNodes(0)
+          .manageNameDfsDirs(false).build();
+      cluster.waitActive();
+
+      secondary = new SecondaryNameNode(config);
+      printStorages(cluster.getNameNode().getFSImage());
+
+      FileSystem fs = cluster.getFileSystem();
+      Path path = new Path("/", "test");
+      assertTrue(fs.mkdirs(path));
+
+      // invalidate storage by removing rwx permission from name2 and name3
+      FileUtil.chmod(path2.toString(), "000");
+      FileUtil.chmod(path3.toString(), "000");
+      secondary.doCheckpoint(); // should remove name2 and name3
+
+      printStorages(cluster.getNameNode().getFSImage());
+
+      path = new Path("/", "test1");
+      assertTrue(fs.mkdirs(path));
+      assert (cluster.getNameNode().getFSImage().getStorage()
+          .getNumStorageDirs() == 1);
+
+      secondary.doCheckpoint(); // shouldn't be able to restore name 2 and 3
+      assert (cluster.getNameNode().getFSImage().getStorage()
+          .getNumStorageDirs() == 1);
+
+      FileUtil.chmod(path2.toString(), "755");
+      FileUtil.chmod(path3.toString(), "755");
+      secondary.doCheckpoint(); // should restore name 2 and 3
+      assert (cluster.getNameNode().getFSImage().getStorage()
+          .getNumStorageDirs() == 3);
+
+    } finally {
+      if (path2.exists()) {
+        FileUtil.chmod(path2.toString(), "755");
+      }
+      if (path3.exists()) {
+        FileUtil.chmod(path3.toString(), "755");
+      }
+      if (cluster != null) {
+        cluster.shutdown();
+      }
+      if (secondary != null) {
+        secondary.shutdown();
+      }
+    }
+  }
 }



Mime
View raw message