sumitagrawl commented on code in PR #3782:
URL: https://github.com/apache/ozone/pull/3782#discussion_r988739541
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -893,32 +80,36 @@ private void resetState() {
@Override
public void notifyStatusChanged() {
boolean shouldStop = false;
- boolean shouldRun = false;
lock.lock();
try {
if (!scmContext.isLeader() || scmContext.isInSafeMode()) {
- shouldStop = isBalancerRunning();
- } else {
- shouldRun = shouldRun();
+ shouldStop = canBalancerStop();
}
} finally {
lock.unlock();
}
-
if (shouldStop) {
LOG.info("Stopping ContainerBalancer in this scm on status change");
stop();
+ return;
}
- if (shouldRun) {
- LOG.info("Starting ContainerBalancer in this scm on status change");
- try {
- start();
- } catch (IllegalContainerBalancerStateException |
- InvalidContainerBalancerConfigurationException e) {
- LOG.warn("Could not start ContainerBalancer on raft/safe-mode " +
- "status change.", e);
+ lock.lock();
Review Comment:
> It is a bit inconsistent that we need to take lock for start but not for
stop call above.
This is done as stop has a blocking call with join, waiting thread to stop,
this may take longer time. Stop lock is done inside at granular level, avoiding
area of join.
--
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]