lokeshj1703 commented on a change in pull request #3153:
URL: https://github.com/apache/ozone/pull/3153#discussion_r839146685



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -946,37 +935,48 @@ private void stopBalancingThread() {
         Thread.currentThread().interrupt();
       }
     }
-    currentBalancingThread = null;
+    lock.lock();
+    try {
+      currentBalancingThread = null;

Review comment:
       Can we move this inside the first lock itself? You can use a temporary 
variable to close the thread.

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -874,36 +868,31 @@ private void startBalancingThread() {
     LOG.info("Starting Container Balancer... {}", this);
   }
 
-  private boolean canRun() {
-    if (!checkLeaderAndSafeMode()) {
-      return false;
-    }
-    lock.lock();
-    try {
-      if (isBalancerRunning() || currentBalancingThread != null) {
-        LOG.warn("Cannot run ContainerBalancer because it's already running");
-        return false;
-      }
-    } finally {
-      lock.unlock();
-    }
-    return true;
-  }
-
   /**
-   * Used to check if SCM is leader ready and not in safe mode.
-   * @return true if SCM is leader ready and not in safe mode, false otherwise
+   * Checks if ContainerBalancer can start.
+   * @throws IllegalContainerBalancerStateException if ContainerBalancer is
+   * already running, SCM is in safe mode, or SCM is not leader ready
    */
-  private boolean checkLeaderAndSafeMode() {
+  private void canStart() throws IllegalContainerBalancerStateException {

Review comment:
       Rename to validateState.




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