hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r577860 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/DFSAdmin.java src/java/org/apache/hadoop/dfs/DatanodeInfo.java src/java/org/apache/hadoop/fs/FsShell.java src/webapps/dfs/dfshealth.jsp
Date Thu, 20 Sep 2007 18:37:36 GMT
Author: cutting
Date: Thu Sep 20 11:37:35 2007
New Revision: 577860

URL: http://svn.apache.org/viewvc?rev=577860&view=rev
Log:
HADOOP-1882.  Remove spurious asterisks from decimal number displays.  Contributed by Raghu.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeInfo.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java
    lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=577860&r1=577859&r2=577860&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Thu Sep 20 11:37:35 2007
@@ -167,6 +167,9 @@
     HADOOP-1907.  Fix null pointer exception when getting task diagnostics
     in JobClient. (Christian Kunz via omalley)
 
+    HADOOP-1882.  Remove spurious asterisks from decimal number displays.
+    (Raghu Angadi via cutting)
+
   IMPROVEMENTS
 
     HADOOP-1266. Remove dependency of package org.apache.hadoop.net on 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java?rev=577860&r1=577859&r2=577860&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java Thu Sep 20 11:37:35 2007
@@ -75,7 +75,7 @@
       System.out.println("Used raw bytes: " + rawUsed
                          + " (" + byteDesc(rawUsed) + ")");
       System.out.println("% used: "
-                         + limitDecimal(((1.0 * rawUsed) / raw) * 100, 2)
+                         + limitDecimalTo2(((1.0 * rawUsed) / raw) * 100)
                          + "%");
       System.out.println();
       System.out.println("Total effective bytes: " + used

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeInfo.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeInfo.java?rev=577860&r1=577859&r2=577860&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeInfo.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeInfo.java Thu Sep 20 11:37:35
2007
@@ -160,7 +160,7 @@
     buffer.append("Total raw bytes: "+c+" ("+FsShell.byteDesc(c)+")"+"\n");
     buffer.append("Remaining raw bytes: " +r+ "("+FsShell.byteDesc(r)+")"+"\n");
     buffer.append("Used raw bytes: "+u+" ("+FsShell.byteDesc(u)+")"+"\n");
-    buffer.append("% used: "+FsShell.limitDecimal(((1.0*u)/c)*100, 2)+"%"+"\n");
+    buffer.append("% used: "+FsShell.limitDecimalTo2(((1.0*u)/c)*100)+"%"+"\n");
     buffer.append("Last contact: "+new Date(lastUpdate)+"\n");
     return buffer.toString();
   }
@@ -184,7 +184,7 @@
     }
     buffer.append(" " + c + "(" + FsShell.byteDesc(c)+")");
     buffer.append(" " + u + "(" + FsShell.byteDesc(u)+")");
-    buffer.append(" " + FsShell.limitDecimal(((1.0*u)/c)*100, 2)+"%");
+    buffer.append(" " + FsShell.limitDecimalTo2(((1.0*u)/c)*100)+"%");
     buffer.append(" " + r + "(" + FsShell.byteDesc(r)+")");
     buffer.append(" " + new Date(lastUpdate));
     return buffer.toString();

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java?rev=577860&r1=577859&r2=577860&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java Thu Sep 20 11:37:35 2007
@@ -45,8 +45,7 @@
   }
   static final String SETREP_SHORT_USAGE="-setrep [-R] [-w] <rep> <path/file>";
   static final String TAIL_USAGE="-tail [-f] <file>";
-  private static final DecimalFormat decimalFormat = 
-    new DecimalFormat("#*0.0#*");
+  private static final DecimalFormat decimalFormat = new DecimalFormat("#.##");
 
   /**
    */
@@ -951,16 +950,11 @@
       val = (1.0 * len) / (1024L * 1024 * 1024 * 1024 * 1024);
       ending = " PB";
     }
-    return limitDecimal(val, 2) + ending;
+    return limitDecimalTo2(val) + ending;
   }
 
-  public static String limitDecimal(double d, int placesAfterDecimal) {
-    String strVal = decimalFormat.format(d);
-    int decpt = strVal.indexOf(".");
-    if (decpt >= 0) {
-      strVal = strVal.substring(0, Math.min(strVal.length(), decpt + 1 + placesAfterDecimal));
-    }
-    return strVal;
+  public static synchronized String limitDecimalTo2(double d) {
+    return decimalFormat.format(d);
   }
 
   private void printHelp(String cmd) {

Modified: lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp?rev=577860&r1=577859&r2=577860&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp (original)
+++ lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp Thu Sep 20 11:37:35 2007
@@ -87,7 +87,7 @@
     
     String percentUsed;
     if (c > 0) 
-      percentUsed = FsShell.limitDecimal(((1.0 * u)/c)*100, 2);
+      percentUsed = FsShell.limitDecimalTo2(((1.0 * u)/c)*100);
     else
       percentUsed = "100";
 
@@ -102,10 +102,10 @@
 	      "<td class=\"adminstate\">" +
               adminState +
 	      "<td class=\"size\">" +
-              FsShell.limitDecimal(c*1.0/diskBytes, 2) +
+              FsShell.limitDecimalTo2(c*1.0/diskBytes) +
 	      "<td class=\"pcused\">" + percentUsed +
 	      "<td class=\"size\">" +
-              FsShell.limitDecimal(d.getRemaining()*1.0/diskBytes, 2) +
+              FsShell.limitDecimalTo2(d.getRemaining()*1.0/diskBytes) +
           "<td class=\"blocks\">" + d.numBlocks() + "\n");
   }
 
@@ -153,8 +153,8 @@
 	       rowTxt() + colTxt() + "DFS Used" + colTxt() + ":" + colTxt() +
 	       FsShell.byteDesc( fsn.totalDfsUsed() ) +
 	       rowTxt() + colTxt() + "DFS Used%" + colTxt() + ":" + colTxt() +
-	       FsShell.limitDecimal((fsn.totalDfsUsed())*100.0/
-				     (fsn.totalCapacity() + 1e-10), 2) + " %" +
+	       FsShell.limitDecimalTo2((fsn.totalDfsUsed())*100.0/
+				       (fsn.totalCapacity() + 1e-10)) + " %" +
 	       rowTxt() + colTxt() +
                "<a href=\"#LiveNodes\">Live Nodes</a> " +
                colTxt() + ":" + colTxt() + live.size() +



Mime
View raw message