瀏覽代碼

HADOOP-4610. Always calculate mis-replicated blocks when safe-mode is turned off. Contributed by Konstantin Shvachko.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@712247 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Shvachko 16 年之前
父節點
當前提交
d69ab8bab4

+ 4 - 0
CHANGES.txt

@@ -1060,11 +1060,15 @@ Release 0.19.0 - Unreleased
     HADOOP-4498. Ensure that JobHistory correctly escapes the job name so that
     regex patterns work. (Chris Wensel via acmurthy)
 
+    HADOOP-4610. Always calculate mis-replicated blocks when safe-mode is 
+    turned off. (shv)
+
 Release 0.18.3 - Unreleased
 
   BUG FIXES
 
     HADOOP-4499. DFSClient should invoke checksumOk only once. (Raghu Angadi)
+
     HADOOP-4597. Calculate mis-replicated blocks when safe-mode is turned
     off manually. (shv)
 

+ 8 - 12
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

@@ -3917,8 +3917,7 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
      * Switch to manual safe mode if distributed upgrade is required.<br>
      * Check for invalid, under- & over-replicated blocks in the end of startup.
      */
-    synchronized void leave(boolean checkForUpgrades,
-                            boolean checkBlockReplication) {
+    synchronized void leave(boolean checkForUpgrades) {
       if(checkForUpgrades) {
         // verify whether a distributed upgrade needs to be started
         boolean needUpgrade = false;
@@ -3933,9 +3932,8 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
           return;
         }
       }
-      if(checkBlockReplication)
-        // verify blocks replications
-        processMisReplicatedBlocks();
+      // verify blocks replications
+      processMisReplicatedBlocks();
       long timeInSafemode = now() - systemStart;
       NameNode.stateChangeLog.info("STATE* Leaving safe mode after " 
                                     + timeInSafemode/1000 + " secs.");
@@ -3997,7 +3995,7 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
       // the threshold is reached
       if (!isOn() ||                           // safe mode is off
           extension <= 0 || threshold <= 0) {  // don't need to wait
-        this.leave(true, false); // leave safe mode
+        this.leave(true); // leave safe mode
         return;
       }
       if (reached > 0) {  // threshold has already been reached before
@@ -4135,7 +4133,7 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
       }
       // leave safe mode and stop the monitor
       if(safeMode != null)
-        safeMode.leave(true, true);
+        safeMode.leave(true);
       smmthread = null;
     }
   }
@@ -4153,7 +4151,7 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
       checkSuperuserPrivilege();
       switch(action) {
       case SAFEMODE_LEAVE: // leave safe mode
-        leaveSafeMode(false, true);
+        leaveSafeMode(false);
         break;
       case SAFEMODE_ENTER: // enter safe mode
         enterSafeMode();
@@ -4224,9 +4222,7 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
    * Leave safe mode.
    * @throws IOException
    */
-  synchronized void leaveSafeMode(boolean checkForUpgrades,
-                                  boolean checkBlockReplication
-                                 ) throws IOException {
+  synchronized void leaveSafeMode(boolean checkForUpgrades) throws IOException {
     if (!isInSafeMode()) {
       NameNode.stateChangeLog.info("STATE* Safe mode is already OFF."); 
       return;
@@ -4234,7 +4230,7 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
     if(getDistributedUpgradeState())
       throw new SafeModeException("Distributed upgrade is in progress",
                                   safeMode);
-    safeMode.leave(checkForUpgrades, checkBlockReplication);
+    safeMode.leave(checkForUpgrades);
   }
     
   String getSafeModeTip() {

+ 1 - 1
src/hdfs/org/apache/hadoop/hdfs/server/namenode/UpgradeManagerNamenode.java

@@ -109,7 +109,7 @@ class UpgradeManagerNamenode extends UpgradeManager {
     FSNamesystem.getFSNamesystem().getFSImage().writeAll();
     currentUpgrades = null;
     broadcastCommand = null;
-    FSNamesystem.getFSNamesystem().leaveSafeMode(false, true);
+    FSNamesystem.getFSNamesystem().leaveSafeMode(false);
   }
 
   UpgradeStatusReport distributedUpgradeProgress(UpgradeAction action