From 59eb544744f87aaa8966e30568dff9e8e183f342 Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Thu, 15 Mar 2012 05:36:03 +0000 Subject: [PATCH] HDFS-3093. Fix bug where namenode -format interpreted the -force flag in reverse. Contributed by Todd Lipcon. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1300814 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/namenode/NameNode.java | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 3d4b57fb4f6..51531e879eb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -295,6 +295,9 @@ Release 0.23.3 - UNRELEASED HDFS-1765. Block Replication should respect under-replication block priority. (Uma Maheswara Rao G via eli) + HDFS-3093. Fix bug where namenode -format interpreted the -force flag in + reverse. (todd) + BREAKDOWN OF HDFS-1623 SUBTASKS HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index d67984939d6..c53a374dcfd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -207,7 +207,7 @@ public class NameNode { /** Format a new filesystem. Destroys any filesystem that may already * exist at this location. **/ public static void format(Configuration conf) throws IOException { - format(conf, false); + format(conf, true); } static NameNodeMetrics metrics; @@ -644,12 +644,12 @@ public class NameNode { * for each existing directory and format them. * * @param conf - * @param isConfirmationNeeded + * @param force * @return true if formatting was aborted, false otherwise * @throws IOException */ private static boolean format(Configuration conf, - boolean isConfirmationNeeded) + boolean force) throws IOException { String nsId = DFSUtil.getNamenodeNameServiceId(conf); String namenodeId = HAUtil.getNameNodeId(conf, nsId); @@ -659,7 +659,7 @@ public class NameNode { Collection dirsToFormat = FSNamesystem.getNamespaceDirs(conf); List editDirsToFormat = FSNamesystem.getNamespaceEditsDirs(conf); - if (!confirmFormat(dirsToFormat, isConfirmationNeeded, true)) { + if (!confirmFormat(dirsToFormat, force, true)) { return true; // aborted } @@ -868,7 +868,7 @@ public class NameNode { switch (startOpt) { case FORMAT: - boolean aborted = format(conf, true); + boolean aborted = format(conf, false); System.exit(aborted ? 1 : 0); return null; // avoid javac warning case GENCLUSTERID: