From c3e2c20c9907d106e1cb9da0562c06de4975bc09 Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Tue, 24 Mar 2015 12:12:01 +0530 Subject: [PATCH] HDFS-3325. When configuring 'dfs.namenode.safemode.threshold-pct' to a value greater or equal to 1 there is mismatch in the UI report (Contributed by J.Andreina) (cherry picked from commit c6c396fcd69514ba93583268b2633557c3d74a47) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 4 ++++ .../org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 2 +- .../src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java | 2 +- .../apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 17adae81b1f..897790437bd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -25,6 +25,10 @@ Release 2.8.0 - UNRELEASED HDFS-7867. Update action param from "start" to "prepare" in rolling upgrade javadoc (J.Andreina via vinayakumarb) + HDFS-3325. When configuring "dfs.namenode.safemode.threshold-pct" to a value + greater or equal to 1 there is mismatch in the UI report + (J.Andreina via vinayakumarb) + Release 2.7.0 - UNRELEASED INCOMPATIBLE CHANGES 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 ad0c3442b34..697b975c27a 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 @@ -5417,7 +5417,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, msg += String.format( "The reported blocks %d needs additional %d" + " blocks to reach the threshold %.4f of total blocks %d.%n", - blockSafe, (blockThreshold - blockSafe) + 1, threshold, blockTotal); + blockSafe, (blockThreshold - blockSafe), threshold, blockTotal); thresholdsMet = false; } else { msg += String.format("The reported blocks %d has reached the threshold" diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java index 2d5bef2b6ab..80fe9eead54 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java @@ -198,7 +198,7 @@ public class TestSafeMode { String status = nn.getNamesystem().getSafemode(); assertEquals("Safe mode is ON. The reported blocks 0 needs additional " + - "15 blocks to reach the threshold 0.9990 of total blocks 15." + NEWLINE + + "14 blocks to reach the threshold 0.9990 of total blocks 15." + NEWLINE + "The number of live datanodes 0 has reached the minimum number 0. " + "Safe mode will be turned off automatically once the thresholds " + "have been reached.", status); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java index c5aad9c1bc4..86f3e7b6147 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java @@ -498,7 +498,7 @@ public class TestHASafeMode { + nodeThresh + ". In safe mode extension. " + "Safe mode will be turned off automatically")); } else { - int additional = total - safe; + int additional = (int) (total * 0.9990) - safe; assertTrue("Bad safemode status: '" + status + "'", status.startsWith( "Safe mode is ON. " +