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

Junjie Chen commented on HDDS-699:
----------------------------------

Thanks Sammi, 

Just finish basic first round, some comments below:

{code:java}
+    // Remove any trailing NetConf.PATH_SEPARATOR
+    int len = path.length();
+    while (len > 0 && path.charAt(len-1) == NetConf.PATH_SEPARATOR) {
+      path = path.substring(0, len-1);
+      len = path.length();
+    }
+    return path;
+  }
{code}

this could be replaced by :
{code:java}
 path.replaceAll(NetConf.PATH_SEPARATOR_STR+ "+$", "");
{code}

Please also add doc for public APIs:

{code:java}
+  public static int locationToDepth(String location) {
+    String normalizedLocation = normalize(location);
+    return normalizedLocation.split(NetConf.PATH_SEPARATOR_STR).length;
+  }

{code}


For choosing a node (randomly or not), do we really need ancestor parameter?  
The scope should already contain the branch level info. Isn't it? 

{code:java}
+  /**
+   * Randomly choose a leaf node.
+   *
+   * @param scope range from which a node will be chosen, cannot start with ~
+   * @param excludedNodes nodes to be excluded
+   * @param excludedScope excluded node range. Cannot start with ~
+   * @param ancestorGen matters when excludeNodes is not null. It means the
+   * ancestor generation that's not allowed to share between chosen node and 
the
+   * excludedNodes. For example, if ancestorGen is 1, means chosen node
+   * cannot share the same parent with excludeNodes. If value is 2, cannot
+   * share the same grand parent, and so on. If ancestorGen is 0, then no
+   * effect.
+   *
+   * @return the chosen node
+   */
+  public Node chooseRandom(String scope, String excludedScope,
+      Collection<Node> excludedNodes, int ancestorGen) {

{code}


typo availabel->available.
{code:java}
+      int availabelCount = scopeNode instanceof InnerNode ?
+          ((InnerNode)scopeNode).getNumOfLeaves() - excludedCount :
+          1 - excludedCount;
+      Preconditions.checkState(availabelCount >= 0);
+      return availabelCount;

{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
>
>
> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to