|
@@ -2954,7 +2954,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
this.replQueueThreshold = 1.5f; // can never be reached
|
|
|
this.blockTotal = -1;
|
|
|
this.blockSafe = -1;
|
|
|
- this.reached = -1;
|
|
|
this.resourcesLow = resourcesLow;
|
|
|
enter();
|
|
|
reportStatus("STATE* Safe mode is ON.", true);
|
|
@@ -3150,11 +3149,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Check if safe mode was entered manually or automatically (at startup, or
|
|
|
- * when disk space is low).
|
|
|
+ * Check if safe mode was entered manually
|
|
|
*/
|
|
|
private boolean isManual() {
|
|
|
- return extension == Integer.MAX_VALUE && !resourcesLow;
|
|
|
+ return extension == Integer.MAX_VALUE;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -3190,7 +3188,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
} else {
|
|
|
leaveMsg = "Safe mode will be turned off automatically";
|
|
|
}
|
|
|
- if(isManual()) {
|
|
|
+ if(isManual() && !areResourcesLow()) {
|
|
|
if(upgradeManager.getUpgradeState())
|
|
|
return leaveMsg + " upon completion of " +
|
|
|
"the distributed upgrade: upgrade progress = " +
|
|
@@ -3232,7 +3230,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
}
|
|
|
msg += " " + leaveMsg;
|
|
|
}
|
|
|
- if(reached == 0 || isManual()) { // threshold is not reached or manual
|
|
|
+ // threshold is not reached or manual or resources low
|
|
|
+ if(reached == 0 || (isManual() && !areResourcesLow())) {
|
|
|
return msg + ".";
|
|
|
}
|
|
|
// extension period is in progress
|
|
@@ -3349,7 +3348,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
SafeModeInfo safeMode = this.safeMode;
|
|
|
if (safeMode == null)
|
|
|
return false;
|
|
|
- return !safeMode.isManual() && safeMode.isOn();
|
|
|
+ // If the NN is in safemode, and not due to manual / low resources, we
|
|
|
+ // assume it must be because of startup. If the NN had low resources during
|
|
|
+ // startup, we assume it came out of startup safemode and it is now in low
|
|
|
+ // resources safemode
|
|
|
+ return !safeMode.isManual() && !safeMode.areResourcesLow()
|
|
|
+ && safeMode.isOn();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -3437,7 +3441,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Enter safe mode manually.
|
|
|
+ * Enter safe mode. If resourcesLow is false, then we assume it is manual
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
void enterSafeMode(boolean resourcesLow) throws IOException {
|
|
@@ -3453,8 +3457,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
}
|
|
|
if (resourcesLow) {
|
|
|
safeMode.setResourcesLow();
|
|
|
+ } else {
|
|
|
+ safeMode.setManual();
|
|
|
}
|
|
|
- safeMode.setManual();
|
|
|
getEditLog().logSyncAll();
|
|
|
NameNode.stateChangeLog.info("STATE* Safe mode is ON. "
|
|
|
+ safeMode.getTurnOffTip());
|