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


##########
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();

Review Comment:
   There is no change in logic for this,
   1. Earlier within first lock, its decided if stop or start. Stop is called 
outside lock. And also start
   
   2.  Now, 2 different check, first for stop, if its stop, check within lock, 
then call stop outside
       Next start check within lock and continue to perform start within lock 
to avoid concurrency.
   



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