Author: shv
Date: Fri Dec 19 17:23:22 2008
New Revision: 728215
URL: http://svn.apache.org/viewvc?rev=728215&view=rev
Log:
HADOOP-1980. Revert bad commit rev# 728205.
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=728215&r1=728214&r2=728215&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:23:22 2008
@@ -3811,8 +3811,6 @@
/** time of the last status printout */
private long lastStatusReport = 0;
- private boolean isManual = false;
-
/**
* Creates SafeModeInfo when the name node enters
* automatic safe mode at startup.
@@ -3842,7 +3840,6 @@
this.blockTotal = -1;
this.blockSafe = -1;
this.reached = -1;
- this.isManual = true;
enter();
reportStatus("STATE* Safe mode is ON.", true);
}
@@ -3901,7 +3898,6 @@
NameNode.stateChangeLog.info("STATE* Safe mode is OFF.");
}
reached = -1;
- unsetManual();
safeMode = null;
NameNode.stateChangeLog.info("STATE* Network topology has "
+clusterMap.getNumOfRacks()+" racks and "
@@ -3919,7 +3915,7 @@
synchronized boolean canLeave() {
if (reached == 0)
return false;
- if (now() - reached < extension || isManual()) {
+ if (now() - reached < extension) {
reportStatus("STATE* Safe mode ON.", false);
return false;
}
@@ -3939,14 +3935,14 @@
* to be compared with the threshold.
*/
private float getSafeBlockRatio() {
- return (blockTotal <= 0 ? 1 : (float)blockSafe/blockTotal);
+ return (blockTotal == 0 ? 1 : (float)blockSafe/blockTotal);
}
/**
* Check and trigger safe mode if needed.
*/
private void checkMode() {
- if (isManual() || needEnter()) {
+ if (needEnter()) {
enter();
reportStatus("STATE* Safe mode ON.", false);
return;
@@ -4001,18 +3997,10 @@
/**
* Check if safe mode was entered manually or at startup.
*/
- private boolean isManual() {
- return isManual;
+ boolean isManual() {
+ return blockTotal == -1;
}
- private synchronized void setManual() {
- isManual = true;
- }
-
- private synchronized void unsetManual() {
- isManual = false;
- }
-
/**
* A tip on how safe mode is to be turned off: manually or automatically.
*/
@@ -4020,23 +4008,17 @@
final String autoOffMsg = "Safe mode will be turned off automatically";
if(reached < 0)
return "Safe mode is OFF.";
- float ratio = getSafeBlockRatio();
- String safeBlockRatioMsg =
- String.format("The ratio of reported blocks %.4f has " +
- (ratio < threshold ? "not " : "") + "reached the threshold %.4f. ",
- ratio, threshold);
-
if(isManual()) {
if(getDistributedUpgradeState())
return autoOffMsg + " upon completion of " +
"the distributed upgrade: upgrade progress = " +
getDistributedUpgradeStatus() + "%";
- // add block ratio message if it is relevant
- return ((blockTotal >= 0) ? safeBlockRatioMsg : "") +
- "Use \"hadoop dfs -safemode leave\" to turn safe mode off.";
+ return "Use \"hadoop dfs -safemode leave\" to turn safe mode off.";
}
-
- safeBlockRatioMsg += autoOffMsg;
+ 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
return safeBlockRatioMsg + ".";
// extension period is in progress
@@ -4190,7 +4172,6 @@
*/
synchronized void enterSafeMode() throws IOException {
if (isInSafeMode()) {
- safeMode.setManual();
NameNode.stateChangeLog.info("STATE* Safe mode is already ON.");
return;
}
@@ -4209,7 +4190,6 @@
if(getDistributedUpgradeState())
throw new SafeModeException("Distributed upgrade is in progress",
safeMode);
- safeMode.unsetManual();
safeMode.leave(checkForUpgrades);
}