Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-15343

NetworkTopology#getLoc should exit loop earlier rather than traverse all children

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 2.7.6
    • None
    • performance

    Description

      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.

          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;
            }
          }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hexiaoqiao Xiaoqiao He
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: