hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1130318 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestAllowFormat.java
Date Wed, 01 Jun 2011 21:58:21 GMT
Author: todd
Date: Wed Jun  1 21:58:21 2011
New Revision: 1130318

URL: http://svn.apache.org/viewvc?rev=1130318&view=rev
Log:
HDFS-1636. If dfs.name.dir points to an empty dir, namenode format shouldn't require confirmation.
Contributed by Harsh J Chouraria.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestAllowFormat.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1130318&r1=1130317&r2=1130318&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Wed Jun  1 21:58:21 2011
@@ -465,6 +465,9 @@ Trunk (unreleased changes)
     HDFS-1727. fsck command should display command usage if user passes any
     illegal argument. (Sravan Kumar via todd)
 
+    HDFS-1636. If dfs.name.dir points to an empty dir, namenode format
+    shouldn't require confirmation. (Harsh J Chouraria via todd)
+
   OPTIMIZATIONS
 
     HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=1130318&r1=1130317&r2=1130318&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java Wed Jun
 1 21:58:21 2011
@@ -36,6 +36,7 @@ import org.apache.hadoop.fs.CommonConfig
 import org.apache.hadoop.fs.ContentSummary;
 import org.apache.hadoop.fs.CreateFlag;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.FsServerDefaults;
 import org.apache.hadoop.fs.Options;
 import org.apache.hadoop.fs.Path;
@@ -1483,7 +1484,10 @@ public class NameNode implements Namenod
                  FSNamesystem.getNamespaceEditsDirs(conf);
     for(Iterator<URI> it = dirsToFormat.iterator(); it.hasNext();) {
       File curDir = new File(it.next().getPath());
-      if (!curDir.exists())
+      // Its alright for a dir not to exist, or to exist (properly accessible)
+      // and be completely empty.
+      if (!curDir.exists() ||
+          (curDir.isDirectory() && FileUtil.listFiles(curDir).length == 0))
         continue;
       if (isConfirmationNeeded) {
         if (!confirmPrompt("Re-format filesystem in " + curDir + " ?")) {

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestAllowFormat.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestAllowFormat.java?rev=1130318&r1=1130317&r2=1130318&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestAllowFormat.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestAllowFormat.java
Wed Jun  1 21:58:21 2011
@@ -62,8 +62,20 @@ public class TestAllowFormat {
       throw new IOException("Could not delete hdfs directory '" + hdfsDir +
                             "'");
     }
+
+    // Test has multiple name directories.
+    // Format should not really prompt us if one of the directories exist,
+    // but is empty. So in case the test hangs on an input, it means something
+    // could be wrong in the format prompting code. (HDFS-1636)
     LOG.info("hdfsdir is " + hdfsDir.getAbsolutePath());
-    config.set(DFS_NAMENODE_NAME_DIR_KEY, new File(hdfsDir, "name").getPath());
+    File nameDir1 = new File(hdfsDir, "name1");
+    File nameDir2 = new File(hdfsDir, "name2");
+
+    // To test multiple directory handling, we pre-create one of the name directories.
+    nameDir1.mkdirs();
+
+    // Set multiple name directories.
+    config.set(DFS_NAMENODE_NAME_DIR_KEY, nameDir1.getPath() + "," + nameDir2.getPath());
     config.set(DFS_DATANODE_DATA_DIR_KEY, new File(hdfsDir, "data").getPath());
 
     config.set(DFS_NAMENODE_CHECKPOINT_DIR_KEY,new File(hdfsDir, "secondary").getPath());



Mime
View raw message