He Xiaoqiao created HADOOP-15343:
------------------------------------
Summary: NetworkTopology#getLoc should exit loop earlier rather
than traverse all children
Key: HADOOP-15343
URL: https://issues.apache.org/jira/browse/HADOOP-15343
Project: Hadoop Common
Issue Type: Improvement
Components: performance
Affects Versions: 2.7.6
Reporter: He Xiaoqiao
NetworkTopology#getLoc return a proper node after traverse ALL children of
current {{InnerNode}} even if it has found expected result, based on
branch-2.7. This issue may lead some performance loss especially for a large &
busy cluster and many nodes under a rack. I think it should exit loop earlier
rather than traverse all children of {{InnerNode}}.
{code:java}
private Node getLoc(String loc) {
if (loc == null || loc.length() == 0) return this;
String[] path = loc.split(PATH_SEPARATOR_STR, 2);
Node childnode = null;
for(int i=0; i<children.size(); i++) {
if (children.get(i).getName().equals(path[0])) {
childnode = children.get(i);
}
}
if (childnode == null) return null; // non-existing node
if (path.length == 1) return childnode;
if (childnode instanceof InnerNode) {
return ((InnerNode)childnode).getLoc(path[1]);
} else {
return null;
}
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]