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
This commit is contained in:
Colin McCabe 2013-06-27 01:40:05 +00:00
parent b7e4aae320
commit 7edc5f5456
3 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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);

View File

@ -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."));
}
}