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

Surendra Singh Lilhore commented on HDFS-14909:
-----------------------------------------------

Below code it decreasing count for {{excludedScope}}.
{code:java}
    if (excludeRoot != null && root.isAncestor(excludeRoot)) {
      if (excludeRoot instanceof DFSTopologyNodeImpl) {
        availableCount -= ((DFSTopologyNodeImpl)excludeRoot)
            .getSubtreeStorageCount(type);
      } else {
        availableCount -= ((DatanodeDescriptor)excludeRoot)
            .hasStorageType(type) ? 1 : 0;
      }
    } {code}
Again this code decreasing count for {{excludedNodes}}, but is excluded node is 
part of {{excludedScope}} then no need to decrease the count.
{code:java}
    if (excludedNodes != null) {
      for (Node excludedNode : excludedNodes) {
        if (excludedNode instanceof DatanodeDescriptor) {
          availableCount -= ((DatanodeDescriptor) excludedNode)
              .hasStorageType(type) ? 1 : 0;
        } else if (excludedNode instanceof DFSTopologyNodeImpl) {
          availableCount -= ((DFSTopologyNodeImpl) excludedNode)
              .getSubtreeStorageCount(type);
        } else if (excludedNode instanceof DatanodeInfo) {
         ...................
      }
    }{code}
Because of this {{availableCount}} is in negative value which is not expected
{code:java}
    if (availableCount <= 0) {
      // should never be <0 in general, adding <0 check for safety purpose
      return null;
    }{code}

> DFSNetworkTopology#chooseRandomWithStorageType() should not decrese storage 
> count for excluded node which is already part of excluded scope 
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HDFS-14909
>                 URL: https://issues.apache.org/jira/browse/HDFS-14909
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: namenode
>    Affects Versions: 3.1.1
>            Reporter: Surendra Singh Lilhore
>            Assignee: Surendra Singh Lilhore
>            Priority: Major
>




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