Explorar o código

HADOOP-1224. Fix "Browse the filesystem" link to no point longer to dead datanodes. Contributed by Enis Soztutar.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@529524 13f79535-47bb-0310-9956-ffa450edef68
Thomas White %!s(int64=18) %!d(string=hai) anos
pai
achega
7c027f0285
Modificáronse 2 ficheiros con 14 adicións e 7 borrados
  1. 3 0
      CHANGES.txt
  2. 11 7
      src/java/org/apache/hadoop/dfs/FSNamesystem.java

+ 3 - 0
CHANGES.txt

@@ -216,6 +216,9 @@ Trunk (unreleased changes)
 65. HADOOP-1251.  Add a method to Reporter to get the map InputSplit.
     (omalley via cutting)
 
+66. HADOOP-1224.  Fix "Browse the filesystem" link to no longer point 
+    to dead datanodes.  (Enis Soztutar via tomwhite)
+
 
 Release 0.12.3 - 2007-04-06
 

+ 11 - 7
src/java/org/apache/hadoop/dfs/FSNamesystem.java

@@ -3628,12 +3628,12 @@ class FSNamesystem implements FSConstants {
   private Host2NodesMap host2DataNodeMap = new Host2NodesMap();
        
   /** Stop at and return the datanode at index (used for content browsing)*/
-  private DatanodeInfo getDatanodeByIndex( int index ) {
+  private DatanodeDescriptor getDatanodeByIndex( int index ) {
     int i = 0;
-    for (Iterator<DatanodeDescriptor> it = datanodeMap.values().iterator(); it.hasNext(); ) {
-      DatanodeInfo node = it.next();
-      if( i == index )
+    for (DatanodeDescriptor node : datanodeMap.values()) {
+      if (i == index) {
         return node;
+      }
       i++;
     }
     return null;
@@ -3644,9 +3644,13 @@ class FSNamesystem implements FSConstants {
     int index = 0;
     if (size != 0) {
       index = r.nextInt(size);
-      DatanodeInfo d = getDatanodeByIndex(index);
-      if (d != null) {
-        return d.getHost() + ":" + d.getInfoPort();
+      for(int i=0; i<size; i++) {
+        DatanodeDescriptor d = getDatanodeByIndex(index);
+        if (d != null && !d.isDecommissioned() && isDatanodeDead(d) &&
+            !d.isDecommissionInProgress()) {
+          return d.getHost() + ":" + d.getInfoPort();
+        }
+        index = (index + 1) % size;
       }
     }
     return null;