Kaynağa Gözat

HADOOP-9673. NetworkTopology: When a node cannot be added, print out its location for diagnostic purposes

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1497180 13f79535-47bb-0310-9956-ffa450edef68
Colin McCabe 12 yıl önce
ebeveyn
işleme
7edc5f5456

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -31,6 +31,9 @@ Release 2.2.0 - UNRELEASED
     HADOOP-9355.  Abstract symlink tests to use either FileContext or
     FileSystem.  (Andrew Wang via Colin Patrick McCabe)
 
+    HADOOP-9673.  NetworkTopology: when a node can't be added, print out its
+    location for diagnostic purposes.  (Colin Patrick McCabe)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 4 - 4
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java

@@ -397,10 +397,10 @@ public class NetworkTopology {
     netlock.writeLock().lock();
     try {
       if ((depthOfAllLeaves != -1) && (depthOfAllLeaves != newDepth)) {
-        LOG.error("Error: can't add leaf node at depth " +
-            newDepth + " to topology:\n" + oldTopoStr);
-        throw new InvalidTopologyException("Invalid network topology. " +
-            "You cannot have a rack and a non-rack node at the same " +
+        LOG.error("Error: can't add leaf node " + NodeBase.getPath(node) +
+            " at depth " + newDepth + " to topology:\n" + oldTopoStr);
+        throw new InvalidTopologyException("Failed to add " + NodeBase.getPath(node) +
+            ": You cannot have a rack and a non-rack node at the same " +
             "level of the network topology.");
       }
       Node rack = getNodeForNetworkLocation(node);

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java

@@ -91,9 +91,10 @@ public class TestNetworkTopology {
       invalCluster.add(invalDataNodes[2]);
       fail("expected InvalidTopologyException");
     } catch (NetworkTopology.InvalidTopologyException e) {
-      assertEquals(e.getMessage(), "Invalid network topology. " +
+      assertTrue(e.getMessage().startsWith("Failed to add "));
+      assertTrue(e.getMessage().contains(
           "You cannot have a rack and a non-rack node at the same " +
-          "level of the network topology.");
+          "level of the network topology."));
     }
   }