HADOOP-12772. NetworkTopologyWithNodeGroup.getNodeGroup() can loop infinitely for invalid 'loc' values. Contributed by Kuhu Shukla.
This commit is contained in:
parent
9086dd58c3
commit
49e176c29f
|
@ -1718,6 +1718,9 @@ Release 2.7.3 - UNRELEASED
|
||||||
|
|
||||||
HADOOP-12761. incremental maven build is not really incremental (sjlee)
|
HADOOP-12761. incremental maven build is not really incremental (sjlee)
|
||||||
|
|
||||||
|
HADOOP-12772. NetworkTopologyWithNodeGroup.getNodeGroup() can loop
|
||||||
|
infinitely for invalid 'loc' values (Kuhu Shukla via kihwal)
|
||||||
|
|
||||||
Release 2.7.2 - 2016-01-25
|
Release 2.7.2 - 2016-01-25
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -101,7 +101,12 @@ public class NetworkTopologyWithNodeGroup extends NetworkTopology {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
// may be a leaf node
|
// may be a leaf node
|
||||||
|
if(!(node.getNetworkLocation() == null ||
|
||||||
|
node.getNetworkLocation().isEmpty())) {
|
||||||
return getNodeGroup(node.getNetworkLocation());
|
return getNodeGroup(node.getNetworkLocation());
|
||||||
|
} else {
|
||||||
|
return NodeBase.ROOT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not in cluster map, don't handle it
|
// not in cluster map, don't handle it
|
||||||
|
|
|
@ -127,7 +127,14 @@ public class NodeBase implements Node {
|
||||||
* is not {@link #PATH_SEPARATOR}
|
* is not {@link #PATH_SEPARATOR}
|
||||||
*/
|
*/
|
||||||
public static String normalize(String path) {
|
public static String normalize(String path) {
|
||||||
if (path == null || path.length() == 0) return ROOT;
|
if (path == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Network Location is null ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.length() == 0) {
|
||||||
|
return ROOT;
|
||||||
|
}
|
||||||
|
|
||||||
if (path.charAt(0) != PATH_SEPARATOR) {
|
if (path.charAt(0) != PATH_SEPARATOR) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
|
@ -179,6 +179,19 @@ public class TestNetworkTopologyWithNodeGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNodeGroup() throws Exception {
|
||||||
|
String res = cluster.getNodeGroup("");
|
||||||
|
assertTrue("NodeGroup should be NodeBase.ROOT for empty location",
|
||||||
|
res.equals(NodeBase.ROOT));
|
||||||
|
try {
|
||||||
|
cluster.getNodeGroup(null);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
assertTrue("Null Network Location should throw exception!",
|
||||||
|
e.getMessage().contains("Network Location is null"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test checks that adding a node with invalid topology will be failed
|
* This test checks that adding a node with invalid topology will be failed
|
||||||
* with an exception to show topology is invalid.
|
* with an exception to show topology is invalid.
|
||||||
|
|
Loading…
Reference in New Issue