[ https://issues.apache.org/jira/browse/HDDS-699?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16791051#comment-16791051 ]
Tsz Wo Nicholas Sze commented on HDDS-699: ------------------------------------------ Thanks [~Sammi] for the 06 patch. The example in the javadoc of getLeaf is very useful! {code} * / --- root * / \ * / \ * / \ * / \ * dc1 dc2 * / \ / \ * / \ / \ * / \ / \ * rack1 rack2 rack1 rack2 * / \ / \ / \ / \ * n1 n2 n3 n4 n5 n6 n7 n8 {code} Consider the following two sets of input: # leafIndex = 2, excludedScope = /dc1/rack1, excludedNodes = \{/dc1/rack1/n1}, ancestorGen = 0 # leafIndex = 2, excludedScope = /dc1/rack1, excludedNodes = \{/dc1/rack1/n1}, ancestorGen = 2 In #1, the entire /dc1/rack1 is excluded so that the output is n4. In #2, the entire /dc1 is excluded so that the output is n6. Therefore, we should calculate the overlap and remove it, if there is any. {code} public Node getLeaf(int leafIndex, String excludedScope, Collection<Node> excludedNodes, int ancestorGen) { ... // build an ancestor(children) to exclude node count map Map<Node, Integer> countMap = getAncestorCountMap(excludedNodes, ancestorGen, currentGen); // check overlap between excludedScope and countMap if (excludedScope != null) { for(Iterator<Map.Entry<Node, Integer>> i = countMap.entrySet().iterator(); i.hasNext(); ) { final Map.Entry<Node, Integer> entry = i.next(); final String path = entry.getKey().getNetworkFullPath(); if (path.startsWith(excludedScope)) { // this node is a part of the excludedScope i.remove(); } else if (excludedScope.startsWith(path)) { // the excludedScope is already excluded by the this node excludedScope = null; } } } // nodes covered by excluded scope int excludedNodeCount = getExcludedScopeNodeCount(excludedScope); ... } {code} > Detect Ozone Network topology > ----------------------------- > > Key: HDDS-699 > URL: https://issues.apache.org/jira/browse/HDDS-699 > Project: Hadoop Distributed Data Store > Issue Type: Sub-task > Reporter: Xiaoyu Yao > Assignee: Sammi Chen > Priority: Major > Attachments: HDDS-699.00.patch, HDDS-699.01.patch, HDDS-699.02.patch, > HDDS-699.03.patch, HDDS-699.04.patch, HDDS-699.05.patch, HDDS-699.06.patch > > > Traditionally this has been implemented in Hadoop via script or customizable > java class. One thing we want to add here is the flexible multi-level support > instead of fixed levels like DC/Rack/NG/Node. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org