From fd4a2a6f05c336f253b174d8196e5175b543d292 Mon Sep 17 00:00:00 2001 From: Konstantin Shvachko Date: Tue, 1 Nov 2011 19:24:33 +0000 Subject: [PATCH] HDFS-2002. Incorrect computation of needed blocks in getTurnOffTip(). Contributed by Plamen Jeliazkov. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1196229 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 7 +++++-- .../apache/hadoop/hdfs/server/namenode/TestSafeMode.java | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e6a9563b907..d5a257a0b34 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1760,6 +1760,9 @@ Release 0.22.0 - Unreleased HDFS-2452. OutOfMemoryError in DataXceiverServer takes down the DataNode (Uma Maheswara Rao via cos) + HDFS-2002. Incorrect computation of needed blocks in getTurnOffTip(). + (Plamen Jeliazkov via shv) + Release 0.21.1 - Unreleased HDFS-1466. TestFcHdfsSymlink relies on /tmp/test not existing. (eli) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index c134a2789d0..06705f28411 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -2833,6 +2833,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats, private SafeModeInfo(Configuration conf) { this.threshold = conf.getFloat(DFS_NAMENODE_SAFEMODE_THRESHOLD_PCT_KEY, DFS_NAMENODE_SAFEMODE_THRESHOLD_PCT_DEFAULT); + if(threshold > 1.0) { + LOG.warn("The threshold value should't be greater than 1, threshold: " + threshold); + } this.datanodeThreshold = conf.getInt( DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY, DFS_NAMENODE_SAFEMODE_MIN_DATANODES_DEFAULT); @@ -3120,7 +3123,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, msg += String.format( "The reported blocks %d needs additional %d" + " blocks to reach the threshold %.4f of total blocks %d.", - blockSafe, (blockThreshold - blockSafe), threshold, blockTotal); + blockSafe, (blockThreshold - blockSafe) + 1, threshold, blockTotal); } if (numLive < datanodeThreshold) { if (!"".equals(msg)) { @@ -3129,7 +3132,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, msg += String.format( "The number of live datanodes %d needs an additional %d live " + "datanodes to reach the minimum number %d.", - numLive, datanodeThreshold - numLive, datanodeThreshold); + numLive, (datanodeThreshold - numLive) + 1 , datanodeThreshold); } msg += " " + leaveMsg; } else { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java index da2bf4e22e3..88a1d0d955e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java @@ -58,8 +58,9 @@ public class TestSafeMode { String tipMsg = cluster.getNamesystem().getSafeModeTip(); assertTrue("Safemode tip message looks right", - tipMsg.contains("The number of live datanodes 0 needs an " + - "additional 1 live")); + tipMsg.contains("The number of live datanodes 0 needs an additional " + + "2 live datanodes to reach the minimum number 1. " + + "Safe mode will be turned off automatically.")); // Start a datanode cluster.startDataNodes(conf, 1, true, null, null);