This is an automated email from the ASF dual-hosted git repository.

sodonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e60009bc2 HDDS-9315. Fix comparison logic for 
SCMContainerPlacementCapacity. (#5320)
8e60009bc2 is described below

commit 8e60009bc2444cf95694f361bb28c8f9d8610070
Author: Hongbing Wang <[email protected]>
AuthorDate: Mon Oct 2 19:47:43 2023 +0800

    HDDS-9315. Fix comparison logic for SCMContainerPlacementCapacity. (#5320)
---
 .../scm/container/placement/metrics/SCMNodeMetric.java     | 14 +++++++-------
 .../ozone/container/placement/TestDatanodeMetrics.java     |  4 ++++
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java
index a886084b98..2f5c6f33f7 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java
@@ -51,7 +51,7 @@ public class SCMNodeMetric  implements 
DatanodeMetric<SCMNodeStat, Long> {
   /**
    *
    * @param o - Other Object
-   * @return - True if *this* object is greater than argument.
+   * @return - True if *this* object used space weight is greater than 
argument.
    */
   @Override
   public boolean isGreater(SCMNodeStat o) {
@@ -73,16 +73,16 @@ public class SCMNodeMetric  implements 
DatanodeMetric<SCMNodeStat, Long> {
     if (Math.abs(thisNodeWeight - oNodeWeight) > 0.000001) {
       return thisNodeWeight > oNodeWeight;
     }
-    // if these nodes are have similar weight then return the node with more
-    // free space as the greater node.
-    return stat.getRemaining().isGreater(o.getRemaining().get());
+    // if these nodes have similar weight then return the node with more
+    // used space as the greater node.
+    return stat.getScmUsed().isGreater(o.getScmUsed().get());
   }
 
   /**
    * Inverse of isGreater.
    *
    * @param o - other object.
-   * @return True if *this* object is Lesser than argument.
+   * @return True if *this* object used space weight is Lesser than argument.
    */
   @Override
   public boolean isLess(SCMNodeStat o) {
@@ -105,8 +105,8 @@ public class SCMNodeMetric  implements 
DatanodeMetric<SCMNodeStat, Long> {
     }
 
     // if these nodes are have similar weight then return the node with less
-    // free space as the lesser node.
-    return stat.getRemaining().isLess(o.getRemaining().get());
+    // used space as the lesser node.
+    return stat.getScmUsed().isLess(o.getScmUsed().get());
   }
 
   /**
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestDatanodeMetrics.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestDatanodeMetrics.java
index 72bfae7440..6ba2fc440a 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestDatanodeMetrics.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestDatanodeMetrics.java
@@ -52,5 +52,9 @@ public class TestDatanodeMetrics {
     // Assert we can handle zero capacity.
     assertTrue(metric.isGreater(zeroMetric.get()));
 
+    // Another case when nodes have similar weight
+    SCMNodeStat stat1 = new SCMNodeStat(10000000L, 50L, 9999950L);
+    SCMNodeStat stat2 = new SCMNodeStat(10000000L, 51L, 9999949L);
+    assertTrue(new SCMNodeMetric(stat2).isGreater(stat1));
   }
 }


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

Reply via email to