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 cu...@apache.org on 2006/10/31 23:42:21 UTC

svn commit: r469690 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/DFSShell.java src/java/org/apache/hadoop/dfs/FSDataset.java src/java/org/apache/hadoop/dfs/JspHelper.java src/webapps/dfs/dfshealth.jsp src/webapps/static/hadoop.css

Author: cutting
Date: Tue Oct 31 14:42:20 2006
New Revision: 469690

URL: http://svn.apache.org/viewvc?view=rev&rev=469690
Log:
HADOOP-599.  Fix web ui and command line to correctly report DFS filesystem size statistics.  Contributed by Raghu.

Added:
    lucene/hadoop/trunk/src/webapps/static/hadoop.css
Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.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?view=diff&rev=469690&r1=469689&r2=469690
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue Oct 31 14:42:20 2006
@@ -107,6 +107,10 @@
 
 29. HADOOP-399.  Fix javadoc warnings.  (Nigel Daley via cutting)
 
+30. HADOOP-599.  Fix web ui and command line to correctly report DFS
+    filesystem size statistics.  Also improve web layout.
+    (Raghu Angadi via cutting)
+
 
 Release 0.7.2 - 2006-10-18
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java?view=diff&rev=469690&r1=469689&r2=469690
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java Tue Oct 31 14:42:20 2006
@@ -520,10 +520,16 @@
             ending = " k";
         } else if (len < 1024 * 1024 * 1024) {
             val = (1.0 * len) / (1024 * 1024);
-            ending = " Mb";
-        } else {
+            ending = " MB";
+        } else if (len < 128L * 1024 * 1024 * 1024 ) {
             val = (1.0 * len) / (1024 * 1024 * 1024);
-            ending = " Gb";
+            ending = " GB";
+        } else if (len < 1024L * 1024 * 1024 * 1024 * 1024) {
+            val = (1.0 * len) / (1024L * 1024 * 1024 * 1024);
+            ending = " TB";
+        } else {
+            val = (1.0 * len) / (1024L * 1024 * 1024 * 1024 * 1024);
+            ending = " PB";
         }
         return limitDecimal(val, 2) + ending;
     }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java?view=diff&rev=469690&r1=469689&r2=469690
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java Tue Oct 31 14:42:20 2006
@@ -261,7 +261,6 @@
     class FSVolumeSet {
       FSVolume[] volumes = null;
       int curVolume = 0;
-      HashMap<String,Long> mountMap = new HashMap<String,Long>();
       
       FSVolumeSet(FSVolume[] volumes) {
         this.volumes = volumes;
@@ -280,27 +279,17 @@
       }
       
       synchronized long getCapacity() throws IOException {
-        for (int idx = 0; idx < volumes.length; idx++) {
-          String mount = volumes[idx].getMount();
-          Long capacity = new Long(volumes[idx].getCapacity());
-          mountMap.put(mount, capacity);
-        }
         long capacity = 0L;
-        for (Iterator<Long> iter = mountMap.values().iterator(); iter.hasNext();) {
-          capacity += iter.next().longValue();
+        for (int idx = 0; idx < volumes.length; idx++) {
+            capacity += volumes[idx].getCapacity();
         }
         return capacity;
       }
       
       synchronized long getRemaining() throws IOException {
-        for (int idx = 0; idx < volumes.length; idx++) {
-          String mount = volumes[idx].getMount();
-          Long remaining = new Long(volumes[idx].getCapacity());
-          mountMap.put(mount, remaining);
-        }
         long remaining = 0L;
-        for (Iterator<Long> iter = mountMap.values().iterator(); iter.hasNext();) {
-          remaining += iter.next().longValue();
+        for (int idx = 0; idx < volumes.length; idx++) {
+          remaining += volumes[idx].getAvailable();
         }
         return remaining;
       }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java?view=diff&rev=469690&r1=469689&r2=469690
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java Tue Oct 31 14:42:20 2006
@@ -170,6 +170,6 @@
     public String getSafeModeText() {
       if( ! fsn.isInSafeMode() )
         return "";
-      return "Safe mode is ON. <em>" + fsn.getSafeModeTip() + "<em>";
+      return "Safe mode is ON. <em>" + fsn.getSafeModeTip() + "</em>";
     }
 }

Modified: lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp?view=diff&rev=469690&r1=469689&r2=469690
==============================================================================
--- lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp (original)
+++ lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp Tue Oct 31 14:42:20 2006
@@ -7,6 +7,7 @@
   import="org.apache.hadoop.dfs.*"
   import="org.apache.hadoop.util.*"
   import="java.text.DateFormat"
+  import="java.lang.Math"    
 %>
 <%!
   FSNamesystem fsn = FSNamesystem.getFSNamesystem();
@@ -19,108 +20,110 @@
     long c = d.getCapacity();
     long r = d.getRemaining();
     long u = c - r;
-    String cGb = DFSShell.limitDecimal((1.0 * c)/(1024*1024*1024), 2);
-    String uGb = DFSShell.limitDecimal((1.0 * u)/(1024*1024*1024), 2);
+    
     String percentUsed;
     if (c > 0) 
       percentUsed = DFSShell.limitDecimal(((1.0 * u)/c)*100, 2);
     else
-      percentUsed = "100"; 
-    out.print("<td style=\"vertical-align: top;\"> <b>" + 
-              d.getName() +
-              "</b>&nbsp;<br><i><b>LastContact:</b>&nbsp;" + 
-             (currentTime - d.getLastUpdate())/1000 + " second(s) back;&nbsp;");
-    out.print("<b>Total raw bytes:</b>&nbsp;" + c + "(" + cGb + 
-              "&nbsp;GB);&nbsp;");
-    out.print("<b>Percent used:</b>&nbsp;" + percentUsed);
-    out.print("</i></td>");
+      percentUsed = "100";
+    
+    out.print("<tr> <td id=\"col1\">" + d.getName() +
+              "<td>" + ((currentTime - d.getLastUpdate())/1000) +
+	      "<td>" + DFSShell.byteDesc(c) +
+	      "<td>" + percentUsed + "\n");
   }
 
-  public void generateDFSHealthReport(JspWriter out) throws IOException {
+  public void generateDFSHealthReport(JspWriter out,
+                                      HttpServletRequest request)
+                                      throws IOException {
     Vector live = new Vector();
     Vector dead = new Vector();
     jspHelper.DFSNodesStatus(live, dead);
+    
+    out.print( "<div id=\"dfstable\"> <table>\n" +
+	       "<tr> <td id=\"col1\"> Capacity <td> : <td>" +
+	       DFSShell.byteDesc( fsn.totalCapacity() ) +
+	       "<tr> <td id=\"col1\"> Remaining <td> : <td>" +
+	       DFSShell.byteDesc( fsn.totalRemaining() ) +
+	       "<tr> <td id=\"col1\"> Used <td> : <td>" +
+	       DFSShell.limitDecimal((fsn.totalCapacity() -
+				      fsn.totalRemaining())*100.0/
+				     (fsn.totalCapacity() + 1e-10), 2) +
+	       "%<tr> <td id=\"col1\"> Live Nodes <td> : <td>" + live.size() +
+	       "<tr> <td id=\"col1\"> Dead Nodes <td> : <td>" + dead.size() +
+               "</table></div><br><hr>\n" );
+    
     if (live.isEmpty() && dead.isEmpty()) {
-      out.print("There are no datanodes in the cluster");
+	out.print("There are no datanodes in the cluster");
     }
     else {
-      out.print("<br><b>Number of live data stores: " + live.size() + 
-                ", dead datanodes: " + dead.size() + "</b></br>");
-      out.print("<table style=\"width: 100%; text-align: left;\" border=\"1\""+
-                " cellpadding=\"2\" cellspacing=\"2\">");
-      out.print("<tbody>");
-      out.print("<tr>");
-      out.print("<td style=\"vertical-align: top;\"><B>Live Data Stores</B><br></td>");
-      out.print("<td style=\"vertical-align: top;\"><B>Dead Data Stores</B><br></td>");
-      out.print("</tr>");
-      int i = 0;
-      int min = (live.size() > dead.size()) ? dead.size() : live.size();
-      int max = (live.size() > dead.size()) ? live.size() : dead.size();
-      currentTime = System.currentTimeMillis();
-      for (i = 0; i < min; i++) {
-        DatanodeInfo l = (DatanodeInfo)live.elementAt(i);
-        DatanodeInfo d = (DatanodeInfo)dead.elementAt(i);
-        out.print("<tr>");
-        generateLiveNodeData(out, l);
-        out.print("<td style=\"vertical-align: top;\">" + 
-                  d.getName() +
-                  "<br></td>");
-        out.print("</tr>");
-      }
-      int type = (live.size() > dead.size()) ? 1 : 0;
-      for (i = min; i < max; i++) {
-        out.print("<tr>");
-        if (type == 1) {
-          DatanodeInfo l = (DatanodeInfo)live.elementAt(i);
-          generateLiveNodeData(out, l);
-          out.print("<td style=\"vertical-align: top;\"><br></td>");
-        }
-        else if (type == 0) {
-          DatanodeInfo d = (DatanodeInfo)dead.elementAt(i);
-          out.print("<td style=\"vertical-align: top;\"><br></td>");
-          out.print("<td style=\"vertical-align: top;\">" + 
-                    d.getName() +
-                    "<br></td>");
-        }
-        out.print("</tr>");
-      }
-      out.print("</tbody></table>");
+	
+        currentTime = System.currentTimeMillis();
+	out.print( "<div id=\"dfsnodetable\"> "+
+                   "<a id=\"title\">" +
+                   "Live Datanodes: " + live.size() + "</a>" +
+                   "<br><br>\n<table border=\"1\">\n" );
+
+	if ( live.size() > 0 ) {
+
+	    out.print( "<tr id=\"row1\">" +
+		       "<td> Node <td> Last Contact <td> Size " +
+		       "<td> Used (%)\n" );
+            
+	    for ( int i=0; i < live.size(); i++ ) {
+		DatanodeInfo d = ( DatanodeInfo ) live.elementAt(i);
+		generateLiveNodeData( out, d );
+	    }
+	}
+        out.print("</table>\n");
+	
+	out.print("<br> <a id=\"title\"> " +
+                  " Dead Datanodes : " +dead.size() + "</a><br><br>\n");
+
+	if ( dead.size() > 0 ) {
+	    out.print( "<table border=\"1\"> <tr id=\"row1\"> " +
+		       "<td> Node \n" );
+	    
+	    for ( int i=0; i < dead.size() ; i++ ) {
+		DatanodeInfo d = ( DatanodeInfo ) dead.elementAt(i);
+		out.print( "<tr> <td> " + d.getName() + "\n" );
+	    }
+	    
+	    out.print("</table>\n");
+	}
+	out.print("</div>");
     }
   }
-  public String totalCapacity() {
-    return fsn.totalCapacity() + "(" + DFSShell.limitDecimal((1.0 * fsn.totalCapacity())/(1024*1024*1024), 2) + " GB)";
-  }
-  public String totalRemaining() {
-    return fsn.totalRemaining() + "(" +  DFSShell.limitDecimal(fsn.totalRemaining()/(1024*1024*1024), 2) + " GB)";
-  }
 %>
 
 <html>
 
+<link rel="stylesheet" type="text/css" href="/static/hadoop.css">
 <title>Hadoop NameNode <%=namenodeLabel%></title>
-
+    
 <body>
 <h1>NameNode '<%=namenodeLabel%>'</h1>
 
-<b>Started:</b> <%= fsn.getStartTime()%><br>
-<b>Version:</b> <%= VersionInfo.getVersion()%>,
-                r<%= VersionInfo.getRevision()%><br>
-<b>Compiled:</b> <%= VersionInfo.getDate()%> by 
-                 <%= VersionInfo.getUser()%><br>
+
+<div id="dfstable"> <table>	  
+<tr> <td id="col1"> Started: <td> <%= fsn.getStartTime()%>
+<tr> <td id="col1"> Version: <td> <%= VersionInfo.getVersion()%>,
+                r<%= VersionInfo.getRevision()%>
+<tr> <td id="col1"> Compiled: <td> <%= VersionInfo.getDate()%> by
+                 <%= VersionInfo.getUser()%>
+</table></div><br>				      
 
 <b><a href="/nn_browsedfscontent.jsp">Browse the filesystem</a></b>
 <hr>
-<h2>Cluster Summary</h2>
+<h3>Cluster Summary</h3>
 <b> <%= jspHelper.getSafeModeText()%> </b>
-<p>
-The capacity of this cluster is <%= totalCapacity()%> and remaining is <%= totalRemaining()%>.
-<br>
+
 <% 
-   generateDFSHealthReport(out); 
+    generateDFSHealthReport(out, request); 
 %>
 <hr>
 
-<h2>Local logs</h2>
+<h3>Local logs</h3>
 <a href="/logs/">Log</a> directory
 
 <hr>

Added: lucene/hadoop/trunk/src/webapps/static/hadoop.css
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/static/hadoop.css?view=auto&rev=469690
==============================================================================
--- lucene/hadoop/trunk/src/webapps/static/hadoop.css (added)
+++ lucene/hadoop/trunk/src/webapps/static/hadoop.css Tue Oct 31 14:42:20 2006
@@ -0,0 +1,22 @@
+
+div#dfsnodetable tr#row1, div#dfstable td#col1 {
+	font-weight : bolder;
+}
+
+div#dfsnodetable caption {
+	text-align : left;
+}
+
+div#dfsnodetable a#title {
+	font-size : larger;
+	font-weight : bolder;
+}
+
+div#dfstable table {
+	width : 40%;
+}
+
+div#dfsnodetable td, div#dfstable td {
+	padding-left : 10px;
+	padding-right : 10px;
+}