sumitagrawl commented on code in PR #3782:
URL: https://github.com/apache/ozone/pull/3782#discussion_r990380331
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -950,10 +141,41 @@ public boolean shouldRun() {
/**
* Checks if ContainerBalancer is currently running in this SCM.
*
- * @return true if the currentBalancingThread is not null, otherwise false
+ * @return true if balancer started, otherwise false
*/
public boolean isBalancerRunning() {
- return currentBalancingThread != null;
+ return (null != task
+ && task.getBalancerStatus() == ContainerBalancerTask.Status.RUNNING);
+ }
+
+ /**
+ * Checks if ContainerBalancer in valid state and can be started.
+ *
+ * @return true if balancer can be started, otherwise false
+ */
+ private boolean canBalancerStart() {
+ return (null == task
+ || task.getBalancerStatus() == ContainerBalancerTask.Status.STOPPED);
+ }
+
+ /**
+ * get the Container Balancer state.
+ *
+ * @return true if balancer started, otherwise false
+ */
+ public ContainerBalancerTask.Status getBalancerStatus() {
+ return null != task ? task.getBalancerStatus()
+ : ContainerBalancerTask.Status.STOPPED;
+ }
+
+ /**
+ * Checks if ContainerBalancer is in valid state to call stop.
+ *
+ * @return true if balancer can be stopped, otherwise false
+ */
+ private boolean canBalancerStop() {
+ return null != task
+ && task.getBalancerStatus() == ContainerBalancerTask.Status.RUNNING;
}
Review Comment:
There is a state machine,
--
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]