From 9ede5ccfddc02828bafe4a23ae98093d588d5814 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 3 Nov 2016 15:30:57 -0700 Subject: [PATCH] HADOOP-11088. Quash unnecessary safemode WARN message during NameNode startup. Contributed by Yiqun Lin. (cherry picked from commit 5cad93d5c753112931ce97dba966d1ce6b53724b) --- .../hdfs/server/blockmanagement/BlockManagerSafeMode.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java index 760ef8ef858..d0965b544ff 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java @@ -36,6 +36,7 @@ import org.apache.hadoop.net.NetworkTopology; import org.apache.hadoop.util.Daemon; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,8 +128,8 @@ class BlockManagerSafeMode { this.threshold = conf.getFloat(DFS_NAMENODE_SAFEMODE_THRESHOLD_PCT_KEY, DFS_NAMENODE_SAFEMODE_THRESHOLD_PCT_DEFAULT); if (this.threshold > 1.0) { - LOG.warn("The threshold value should't be greater than 1, threshold: {}", - threshold); + LOG.warn("The threshold value shouldn't be greater than 1, " + + "threshold: {}", threshold); } this.datanodeThreshold = conf.getInt( DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY, @@ -171,7 +172,8 @@ class BlockManagerSafeMode { startTime = monotonicNow(); setBlockTotal(total); if (areThresholdsMet()) { - leaveSafeMode(true); + boolean exitResult = leaveSafeMode(false); + Preconditions.checkState(exitResult, "Failed to leave safe mode."); } else { // enter safe mode status = BMSafeModeStatus.PENDING_THRESHOLD;