You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sz...@apache.org on 2009/04/18 02:03:28 UTC
svn commit: r766182 - in /hadoop/core/trunk: CHANGES.txt
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Author: szetszwo
Date: Sat Apr 18 00:03:28 2009
New Revision: 766182
URL: http://svn.apache.org/viewvc?rev=766182&view=rev
Log:
HADOOP-5650. Fix safemode messages in the Namenode log. Contributed by Suresh Srinivas
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=766182&r1=766181&r2=766182&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Sat Apr 18 00:03:28 2009
@@ -418,6 +418,9 @@
HADOOP-5704. Fix compilation problems in TestFairScheduler and
TestCapacityScheduler. (Chris Douglas via szetszwo)
+ HADOOP-5650. Fix safemode messages in the Namenode log. (Suresh Srinivas
+ via szetszwo)
+
Release 0.20.0 - Unreleased
INCOMPATIBLE CHANGES
Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=766182&r1=766181&r2=766182&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Sat Apr 18 00:03:28 2009
@@ -4053,6 +4053,8 @@
int blockTotal;
/** Number of safe blocks. */
private int blockSafe;
+ /** Number of blocks needed to satisfy safe mode threshold condition */
+ private int blockThreshold;
/** time of the last status printout */
private long lastStatusReport = 0;
@@ -4172,15 +4174,7 @@
* if DFS is empty or {@link #threshold} == 0
*/
boolean needEnter() {
- return getSafeBlockRatio() < threshold;
- }
-
- /**
- * Ratio of the number of safe blocks to the total number of blocks
- * to be compared with the threshold.
- */
- private float getSafeBlockRatio() {
- return (blockTotal == 0 ? 1 : (float)blockSafe/blockTotal);
+ return threshold != 0 && blockSafe < blockThreshold;
}
/**
@@ -4213,7 +4207,8 @@
* Set total number of blocks.
*/
synchronized void setBlockTotal(int total) {
- this.blockTotal = total;
+ this.blockTotal = total;
+ this.blockThreshold = (int) (blockTotal * threshold);
checkMode();
}
@@ -4257,9 +4252,9 @@
* A tip on how safe mode is to be turned off: manually or automatically.
*/
String getTurnOffTip() {
- String leaveMsg = "Safe mode will be turned off automatically";
if(reached < 0)
return "Safe mode is OFF.";
+ String leaveMsg = "Safe mode will be turned off automatically";
if(isManual()) {
if(getDistributedUpgradeState())
return leaveMsg + " upon completion of " +
@@ -4269,15 +4264,24 @@
}
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) + leaveMsg;
- if(reached == 0 || isManual()) // threshold is not reached or manual
- return safeBlockRatioMsg + ".";
+
+ String msg = null;
+ if (reached == 0) {
+ msg = String.format("The reported blocks %d needs additional %d"
+ + " blocks to reach the threshold %.4f of total blocks %d. %s",
+ blockSafe, (blockThreshold - blockSafe), threshold, blockTotal,
+ leaveMsg);
+ } else {
+ msg = String.format("The reported blocks %d has reached the threshold"
+ + " %.4f of total blocks %d. %s", blockSafe, threshold,
+ blockTotal, leaveMsg);
+ }
+ if(reached == 0 || isManual()) { // threshold is not reached or manual
+ return msg + ".";
+ }
// extension period is in progress
- return safeBlockRatioMsg + " in "
- + Math.abs(reached + extension - now())/1000 + " seconds.";
+ return msg + " in " + Math.abs(reached + extension - now()) / 1000
+ + " seconds.";
}
/**
@@ -4295,9 +4299,9 @@
* Returns printable state of the class.
*/
public String toString() {
- String resText = "Current safe block ratio = "
- + getSafeBlockRatio()
- + ". Target threshold = " + threshold
+ String resText = "Current safe blocks = "
+ + blockSafe
+ + ". Target blocks = " + blockThreshold + " for threshold = %" + threshold
+ ". Minimal replication = " + safeReplication + ".";
if (reached > 0)
resText += " Threshold was reached " + new Date(reached) + ".";