adoroszlai commented on code in PR #3574:
URL: https://github.com/apache/ozone/pull/3574#discussion_r912097103


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java:
##########
@@ -302,6 +353,35 @@ protected ContainerHealthResult 
processContainer(ContainerInfo containerInfo,
     return health;
   }
 
+  /**
+   * Creates a priority queue of UnderReplicatedHealthResult, where the 
elements
+   * are ordered by the weighted redundancy of the container. This means that
+   * containers with the least remaining redundancy are at the front of the
+   * queue, and will be processed first.
+   * @return An empty instance of a PriorityQueue.
+   */
+  protected PriorityQueue<ContainerHealthResult.UnderReplicatedHealthResult>
+      createUnderReplicatedQueue() {
+    return new PriorityQueue<>(
+        (o1, o2) -> {
+          if (o1.getWeightedRedundancy() < o2.getWeightedRedundancy()) {
+            return -1;
+          } else if (o1.getWeightedRedundancy() > o2.getWeightedRedundancy()) {
+            return 1;
+          } else {
+            // Equal weighted redundancy. Put the one with the lesser retries
+            // first
+            if (o1.getRequeueCount() < o2.getRequeueCount()) {
+              return -1;
+            } else if (o1.getRequeueCount() > o2.getRequeueCount()) {
+              return 1;
+            } else {
+              return 0;
+            }
+          }
+        });

Review Comment:
   Thanks.  Sorry I wrote `getRemainingRedundancy` instead of `getRequeueCount`.



-- 
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