[ 
https://issues.apache.org/jira/browse/HDFS-11430?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16958493#comment-16958493
 ] 

Lisheng Sun commented on HDFS-11430:
------------------------------------

{code:java}
@Override
public Node getLeaf(int leafIndex, Node excludedNode) {
  int count=0;
  // check if the excluded node a leaf
  boolean isLeaf = !(excludedNode instanceof InnerNode);
  // calculate the total number of excluded leaf nodes
  int numOfExcludedLeaves =
      isLeaf ? 1 : ((InnerNode)excludedNode).getNumOfLeaves();
  if (isLeafParent()) { // children are leaves
    if (isLeaf) { // excluded node is a leaf node
      if (excludedNode != null &&
          childrenMap.containsKey(excludedNode.getName())) {
        int excludedIndex = children.indexOf(excludedNode);
        if (excludedIndex != -1 && leafIndex >= 0) {
          // excluded node is one of the children so adjust the leaf index
          leafIndex = leafIndex>=excludedIndex ? leafIndex+1 : leafIndex;
        }
      }
    }
    // range check
    if (leafIndex<0 || leafIndex>=this.getNumOfChildren()) {
      return null;
    }
    return children.get(leafIndex);
  } 
...
}{code}
[~szetszwo] [~vagarychen] [~ayushtkn] [~elgoiri]

the code InnerNodeImpl#getLeaf() as above 

i think it has two problems:

1.if childrenMap.containsKey(excludedNode.getName()) return true, 
children.indexOf(excludedNode) must return > -1, so if (excludedIndex != -1) is 
it necessary?

2. if excludedindex = children.size() -1 

as current code:

leafIndex = leafIndex>=excludedIndex ? leafIndex+1 : leafIndex;

leafIndex will be out of index and return null. Actually there are nodes that 
can be returned.

i think it should add the judgement excludedIndex == children.size() -1 

 Please correct me if i was wrong. Thank you.

> Separate class InnerNode from class NetworkTopology and make it extendable
> --------------------------------------------------------------------------
>
>                 Key: HDFS-11430
>                 URL: https://issues.apache.org/jira/browse/HDFS-11430
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: namenode
>            Reporter: Chen Liang
>            Assignee: Tsz-wo Sze
>            Priority: Major
>             Fix For: 2.9.0, 3.0.0-alpha4
>
>         Attachments: HDFS-11430-branch-2.001.patch, h11430_20170217.patch, 
> h11430_20170218.patch
>
>
> The approach we will take in HDFS-11419 is to annotate topology's inner node 
> with more information, such that it chooses a subtree that meets storage type 
> requirement. However, {{InnerNode}} is not specific to HDFS, so our change 
> should affect other components using this class.
> This JIRA separates {{InnerNode}} out of {{NetworkTopology}} and makes it 
> extendable. Therefore HDFS can have it's own customized inner node class, 
> while other services can still have inner node as what it is right now.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to