sumitagrawl commented on code in PR #3782:
URL: https://github.com/apache/ozone/pull/3782#discussion_r990393214


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -892,34 +79,38 @@ private void resetState() {
    */
   @Override
   public void notifyStatusChanged() {
-    boolean shouldStop = false;
-    boolean shouldRun = false;
+    if (!scmContext.isLeader() || scmContext.isInSafeMode()) {
+      boolean shouldStop;
+      lock.lock();
+      try {
+        shouldStop = canBalancerStop();
+      } finally {
+        lock.unlock();
+      }
+      if (shouldStop) {
+        LOG.info("Stopping ContainerBalancer in this scm on status change");
+        stop();
+      }
+      return;
+    }
+
     lock.lock();
     try {
-      if (!scmContext.isLeader() || scmContext.isInSafeMode()) {
-        shouldStop = isBalancerRunning();
-      } else {
-        shouldRun = shouldRun();
+      // else check for start
+      boolean shouldRun = shouldRun();
+      if (shouldRun && canBalancerStart()) {

Review Comment:
   Logic is same as old, just additional memory check of balancer.
   1. check for if balancer can run by checking persistent
   2. then check if already running in memory
   And then decide if can start.



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