sodonnel commented on code in PR #5588:
URL: https://github.com/apache/ozone/pull/5588#discussion_r1392523250
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/net/NetworkTopologyImpl.java:
##########
@@ -695,27 +695,33 @@ private Node chooseNodeInternal(String scope, int
leafIndex,
*/
@Override
public int getDistanceCost(Node node1, Node node2) {
- if ((node1 != null && node2 != null && node1.equals(node2)) ||
+ if ((node1 != null && node1.equals(node2)) ||
(node1 == null && node2 == null)) {
return 0;
}
if (node1 == null || node2 == null) {
LOG.warn("One of the nodes is a null pointer");
return Integer.MAX_VALUE;
}
+
+ // verify levels are in range
+ int level1 = node1.getLevel();
+ int level2 = node2.getLevel();
+ if (level1 < NetConstants.ROOT_LEVEL || level2 < NetConstants.ROOT_LEVEL) {
+ return Integer.MAX_VALUE;
+ }
+ if (level1 > maxLevel || level2 > maxLevel) {
+ return Integer.MAX_VALUE;
+ }
+
int cost = 0;
netlock.readLock().lock();
try {
- if ((node1.getAncestor(maxLevel - 1) != clusterTree) ||
- (node2.getAncestor(maxLevel - 1) != clusterTree)) {
+ if ((node1.getAncestor(level1 - 1) != clusterTree) ||
+ (node2.getAncestor(level2 - 1) != clusterTree)) {
Review Comment:
I don't understand this bit - if we have a topology like:
```
ROOT
Node1
Node2
Node3
```
Is ROOT stored in cluster tree, so level1 -1 will be cluster tree?
--
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]