Author: llu Date: Thu Apr 4 07:04:55 2013 New Revision: 1464300 URL: http://svn.apache.org/r1464300 Log: HADOOP-9451. Fault single-layer config if node group topology is enabled. (Junping Du via llu)
Modified: hadoop/common/branches/branch-1/CHANGES.txt hadoop/common/branches/branch-1/src/core/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java hadoop/common/branches/branch-1/src/test/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java Modified: hadoop/common/branches/branch-1/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1464300&r1=1464299&r2=1464300&view=diff ============================================================================== --- hadoop/common/branches/branch-1/CHANGES.txt (original) +++ hadoop/common/branches/branch-1/CHANGES.txt Thu Apr 4 07:04:55 2013 @@ -229,6 +229,9 @@ Release 1.2.0 - unreleased BUG FIXES + HADOOP-9451. Fault single-layer config if node group topology is enabled. + (Junping Du via llu) + MAPREDUCE-4904. OTHER_LOCAL_MAPS counter is not correct. (Junping Du via llu) Modified: hadoop/common/branches/branch-1/src/core/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/core/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java?rev=1464300&r1=1464299&r2=1464300&view=diff ============================================================================== --- hadoop/common/branches/branch-1/src/core/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java (original) +++ hadoop/common/branches/branch-1/src/core/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java Thu Apr 4 07:04:55 2013 @@ -190,7 +190,12 @@ public class NetworkTopologyWithNodeGrou } rack = getNode(nodeGroup.getNetworkLocation()); - if (rack != null && !(rack instanceof InnerNode)) { + // rack should be an innerNode and with parent. + // note: rack's null parent case is: node's topology only has one layer, + // so rack is recognized as "/" and no parent. + // This will be recognized as a node with fault topology. + if (rack != null && + (!(rack instanceof InnerNode)|| rack.getParent() == null)) { throw new IllegalArgumentException("Unexpected data node " + node.toString() + " at an illegal network location"); Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java?rev=1464300&r1=1464299&r2=1464300&view=diff ============================================================================== --- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java (original) +++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java Thu Apr 4 07:04:55 2013 @@ -39,6 +39,8 @@ public class TestNetworkTopologyWithNode }; private final static NodeBase computeNode = new NodeBase("/d1/r1/n1/h9"); + + private final static NodeBase rackOnlyNode = new NodeBase("h10", "/r1"); static { for(int i=0; i<dataNodes.length; i++) { @@ -159,5 +161,21 @@ public class TestNetworkTopologyWithNode assertTrue(frequency.get(key) > 0 || key == dataNodes[0]); } } + /** + * This test checks that adding a node with invalid topology will be failed + * with an exception to show topology is invalid. + */ + public void testAddNodeWithInvalidTopology() { + // The last node is a node with invalid topology + try { + cluster.add(rackOnlyNode); + fail("Exception should be thrown, so we should not have reached here."); + } catch (Exception e) { + if (!(e instanceof IllegalArgumentException)) { + fail("Expecting IllegalArgumentException, but caught:" + e); + } + assertTrue(e.getMessage().contains("illegal network location")); + } + } }