greenwich commented on code in PR #11840:
URL: https://github.com/apache/ozone/pull/11840#discussion_r4765918798


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/net/NetworkTopologyImpl.java:
##########
@@ -823,6 +827,51 @@ public <N extends Node> List<N> sortByDistanceCost(Node 
reader,
     return ret;
   }
 
+  /**
+   * Distance cost for a node that is not linked into the tree, such as a 
datanode deserialized
+   * from RPC, computed from network locations and the schema's per-level 
costs, like HDFS
+   * {@code NetworkTopology#getWeightUsingNetworkLocation}. Inner nodes take 
their level's schema
+   * cost, so this equals {@link #getDistanceCost(Node, Node)} for linked 
nodes, without the lock.
+   */
+  private int getDistanceCostByLocation(Node reader, String[] readerPath, Node 
node) {
+    if (Objects.equals(reader, node)) {
+      return 0;
+    }
+    final String[] nodePath = getLocationPath(node);
+    if (readerPath == null || nodePath == null) {
+      return Integer.MAX_VALUE;
+    }
+    int commonDepth = 0;
+    while (commonDepth < readerPath.length && 
readerPath[commonDepth].equals(nodePath[commonDepth])) {

Review Comment:
   @ChenSammi thanks, done in the latest commit. As in getDistanceCost, each 
node adds the cost of its ancestors from its parent up to the common ancestor, 
so nodes at different levels get a real cost.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to