hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r428860 - in /lucene/hadoop/trunk/src: java/org/apache/hadoop/dfs/FSNamesystem.java java/org/apache/hadoop/dfs/JspHelper.java webapps/dfs/dfshealth.jsp
Date Fri, 04 Aug 2006 19:58:11 GMT
Author: cutting
Date: Fri Aug  4 12:58:10 2006
New Revision: 428860

URL: http://svn.apache.org/viewvc?rev=428860&view=rev
Log:
HADOOP-415.  Fix a potential namenode performance issue introduced by HADOOP-392.  Contributed
by Devaraj.

Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java
    lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java?rev=428860&r1=428859&r2=428860&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java Fri Aug  4 12:58:10
2006
@@ -61,11 +61,6 @@
     //
     TreeMap datanodeMap = new TreeMap();
 
-    // 
-    // Stores the datanode.name-->datanodeInfo map. Used for getting a sorted
-    // list of datanodes sorted by their names
-    TreeMap datanodeMapByName = new TreeMap();
-
     //
     // Stores the set of dead datanodes
     TreeMap deaddatanodeMap = new TreeMap();
@@ -1088,10 +1083,8 @@
               + "new storageID " + nodeReg.getStorageID() + " assigned." );
         }
         // register new datanode
-        DatanodeDescriptor dinfo;
         datanodeMap.put(nodeReg.getStorageID(), 
-                        (dinfo = new DatanodeDescriptor( nodeReg )));
-        datanodeMapByName.put(nodeReg.getName(), dinfo);
+                        new DatanodeDescriptor( nodeReg ));
         NameNode.stateChangeLog.debug(
             "BLOCK* NameSystem.registerDatanode: "
             + "node registered." );
@@ -1159,7 +1152,6 @@
                     +"brand-new heartbeat from "+nodeID.getName() );
             nodeinfo = new DatanodeDescriptor(nodeID, capacity, remaining, xceiverCount);
             datanodeMap.put(nodeinfo.getStorageID(), nodeinfo);
-            datanodeMapByName.put(nodeinfo.getName(), nodeinfo);
             capacityDiff = capacity;
             remainingDiff = remaining;
           } else {
@@ -1216,7 +1208,6 @@
     private void removeDatanode( DatanodeDescriptor nodeInfo ) {
       heartbeats.remove(nodeInfo);
       datanodeMap.remove(nodeInfo.getStorageID());
-      datanodeMapByName.remove(nodeInfo.getName());
       deaddatanodeMap.put(nodeInfo.getName(), nodeInfo);
       NameNode.stateChangeLog.debug("BLOCK* NameSystem.removeDatanode: "
               + nodeInfo.getName() + " is removed from datanodeMap");
@@ -1552,7 +1543,7 @@
     public void DFSNodesStatus(Vector live, Vector dead) {
         synchronized (heartbeats) {
             synchronized (datanodeMap) {
-                live.addAll(datanodeMapByName.values());
+                live.addAll(datanodeMap.values());
                 dead.addAll(deaddatanodeMap.values());
             }
         }

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?rev=428860&r1=428859&r2=428860&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java Fri Aug  4 12:58:10
2006
@@ -27,6 +27,7 @@
 import org.apache.hadoop.conf.*;
 
 public class JspHelper {
+    static FSNamesystem fsn = null;
     static InetSocketAddress nameNodeAddr;
     static Configuration conf = new Configuration();
 
@@ -39,7 +40,7 @@
         nameNodeAddr = DataNode.getDataNode().getNameNodeAddr();
       }
       else {
-        FSNamesystem fsn = FSNamesystem.getFSNamesystem();
+        fsn = FSNamesystem.getFSNamesystem();
         nameNodeAddr = new InetSocketAddress(fsn.getDFSNameNodeMachine(),
                   fsn.getDFSNameNodePort()); 
       }      
@@ -136,6 +137,17 @@
       s.close();
       in.close();
       out.print(new String(buf));
+    }
+    public void DFSNodesStatus(Vector live, Vector dead) {
+      if (fsn == null) return;
+      TreeMap nodesSortedByName = new TreeMap();
+      fsn.DFSNodesStatus(live, dead);
+      for (int num = 0; num < live.size(); num++) {
+        DatanodeDescriptor d = (DatanodeDescriptor)live.elementAt(num);
+        nodesSortedByName.put(d.getName(), d);
+      }
+      live.clear();
+      live.addAll(nodesSortedByName.values());
     }
     public void addTableHeader(JspWriter out) throws IOException {
       out.print("<table border=\"1\""+

Modified: lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp?rev=428860&r1=428859&r2=428860&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp (original)
+++ lucene/hadoop/trunk/src/webapps/dfs/dfshealth.jsp Fri Aug  4 12:58:10 2006
@@ -11,15 +11,20 @@
   FSNamesystem fsn = FSNamesystem.getFSNamesystem();
   String namenodeLabel = fsn.getDFSNameNodeMachine() + ":" + fsn.getDFSNameNodePort();
   long currentTime;
+  JspHelper jspHelper = new JspHelper();
 
-  public void generateLiveNodeData(JspWriter out, DatanodeInfo d) 
+  public void generateLiveNodeData(JspWriter out, DatanodeDescriptor d) 
     throws IOException {
     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 = DFSShell.limitDecimal(((1.0 * u)/c)*100, 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;"
+ 
@@ -33,7 +38,7 @@
   public void generateDFSHealthReport(JspWriter out) throws IOException {
     Vector live = new Vector();
     Vector dead = new Vector();
-    fsn.DFSNodesStatus(live, dead);
+    jspHelper.DFSNodesStatus(live, dead);
     if (live.isEmpty() && dead.isEmpty()) {
       out.print("There are no datanodes in the cluster");
     }
@@ -52,8 +57,8 @@
       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);
+        DatanodeDescriptor l = (DatanodeDescriptor)live.elementAt(i);
+        DatanodeDescriptor d = (DatanodeDescriptor)dead.elementAt(i);
         out.print("<tr>");
         generateLiveNodeData(out, l);
         out.print("<td style=\"vertical-align: top;\">" + 
@@ -65,12 +70,12 @@
       for (i = min; i < max; i++) {
         out.print("<tr>");
         if (type == 1) {
-          DatanodeInfo l = (DatanodeInfo)live.elementAt(i);
+          DatanodeDescriptor l = (DatanodeDescriptor)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);
+          DatanodeDescriptor d = (DatanodeDescriptor)dead.elementAt(i);
           out.print("<td style=\"vertical-align: top;\"><br></td>");
           out.print("<td style=\"vertical-align: top;\">" + 
                     d.getName() +



Mime
View raw message