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



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -185,7 +185,9 @@ private void balance() {
     for (int i = 0; i < idleIteration && balancerRunning; i++) {
       // stop balancing if iteration is not initialized
       if (!initializeIteration()) {
-        stop();
+        if (isBalancerRunning()) {
+          stop();

Review comment:
       Why do we need isBalancerRunning check before calling stop method? It 
should be ok to call stop directly.

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -364,10 +376,15 @@ private IterationResult doIteration() {
 
     // match each overUtilized node with a target
     for (DatanodeUsageInfo datanodeUsageInfo : overUtilizedNodes) {
+      if (!balancerRunning) {
+        checkIterationMoveResults();
+        return IterationResult.ITERATION_INTERRUPTED;
+      }

Review comment:
       I would recommend moving this to a separate function for checking 
balancer status.
   Instead of calling `checkIterationMoveResults` multiple times, maybe throw 
InterruptedException in the new function. 
   ```
     doIteration {
       try {
           checkBalancerStatus();
           ...
       } catch (InterrupedException e) {
           return IterationResult.ITERATION_INTERRUPTED;
       } finally {
           checkIterationMoveResults();
       }
     }
   ```

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -185,7 +185,9 @@ private void balance() {
     for (int i = 0; i < idleIteration && balancerRunning; i++) {
       // stop balancing if iteration is not initialized
       if (!initializeIteration()) {
-        stop();
+        if (isBalancerRunning()) {

Review comment:
       Why would this lead to deadlock? We only have one lock in balancer. 
   If stop is called multiple times, all subsequent calls should be quick to 
execute.

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -185,7 +185,9 @@ private void balance() {
     for (int i = 0; i < idleIteration && balancerRunning; i++) {
       // stop balancing if iteration is not initialized
       if (!initializeIteration()) {
-        stop();
+        if (isBalancerRunning()) {
+          stop();

Review comment:
       This check is made at multiple places. I think we can avoid this check.




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