hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r728216 - /hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Date Sat, 20 Dec 2008 01:25:50 GMT
Author: shv
Date: Fri Dec 19 17:25:50 2008
New Revision: 728216

URL: http://svn.apache.org/viewvc?rev=728216&view=rev
Log:
HADOOP-1980. Apply correct merge -r 728194:728195 from trunk to branch 0.20.

Modified:
    hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Modified: hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=728216&r1=728215&r2=728216&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
(original)
+++ hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Fri Dec 19 17:25:50 2008
@@ -3835,7 +3835,7 @@
      */
     private SafeModeInfo() {
       this.threshold = 1.5f;  // this threshold can never be reached
-      this.extension = 0;
+      this.extension = Integer.MAX_VALUE;
       this.safeReplication = Short.MAX_VALUE + 1; // more than maxReplication
       this.blockTotal = -1;
       this.blockSafe = -1;
@@ -3993,33 +3993,42 @@
         this.blockSafe--;
       checkMode();
     }
-      
+
     /**
      * Check if safe mode was entered manually or at startup.
      */
     boolean isManual() {
-      return blockTotal == -1;
+      return extension == Integer.MAX_VALUE;
     }
-      
+
+    /**
+     * Set manual safe mode.
+     */
+    void setManual() {
+      extension = Integer.MAX_VALUE;
+    }
+
     /**
      * A tip on how safe mode is to be turned off: manually or automatically.
      */
     String getTurnOffTip() {
-      final String autoOffMsg = "Safe mode will be turned off automatically";
+      String leaveMsg = "Safe mode will be turned off automatically";
       if(reached < 0)
         return "Safe mode is OFF.";
       if(isManual()) {
         if(getDistributedUpgradeState())
-          return autoOffMsg + " upon completion of " + 
+          return leaveMsg + " upon completion of " + 
             "the distributed upgrade: upgrade progress = " + 
             getDistributedUpgradeStatus() + "%";
-        return "Use \"hadoop dfs -safemode leave\" to turn safe mode off.";
+        leaveMsg = "Use \"hadoop dfs -safemode leave\" to turn safe mode off";
       }
+      if(blockTotal < 0)
+        return leaveMsg + ".";
       String safeBlockRatioMsg = 
         String.format("The ratio of reported blocks %.4f has " +
           (reached == 0 ? "not " : "") + "reached the threshold %.4f. ",
-          getSafeBlockRatio(), threshold) + autoOffMsg;
-      if(reached == 0)  // threshold is not reached 
+          getSafeBlockRatio(), threshold) + leaveMsg;
+      if(reached == 0 || isManual())  // threshold is not reached or manual
         return safeBlockRatioMsg + ".";
       // extension period is in progress
       return safeBlockRatioMsg + " in " 
@@ -4171,13 +4180,15 @@
    * @throws IOException
    */
   synchronized void enterSafeMode() throws IOException {
-    if (isInSafeMode()) {
-      NameNode.stateChangeLog.info("STATE* Safe mode is already ON."); 
+    if (!isInSafeMode()) {
+      safeMode = new SafeModeInfo();
       return;
     }
-    safeMode = new SafeModeInfo();
+    safeMode.setManual();
+    NameNode.stateChangeLog.info("STATE* Safe mode is ON. " 
+                                + safeMode.getTurnOffTip());
   }
-    
+
   /**
    * Leave safe mode.
    * @throws IOException



Mime
View raw message