From 7edc5f545669cf1081d9f08abb71c6c52f8f5008 Mon Sep 17 00:00:00 2001 From: Colin McCabe Date: Thu, 27 Jun 2013 01:40:05 +0000 Subject: [PATCH] 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 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../main/java/org/apache/hadoop/net/NetworkTopology.java | 8 ++++---- .../java/org/apache/hadoop/net/TestNetworkTopology.java | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index ce4f0e9a047..de6f34fa1a2 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/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 diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java index 1c468d2ad20..a09eaf2973a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java +++ b/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); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java index 83d5a88cb23..af09595ff50 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java +++ b/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.")); } }