siddhantsangwan commented on a change in pull request #2441:
URL: https://github.com/apache/ozone/pull/2441#discussion_r676317453
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -113,49 +130,50 @@ public boolean start(
lock.lock();
try {
if (!balancerRunning.compareAndSet(false, true)) {
- LOG.info("Container Balancer is already running.");
+ LOG.error("Container Balancer is already running.");
return false;
}
-
+
+ ozoneConfiguration = new OzoneConfiguration();
this.config = balancerConfiguration;
- this.idleIteration = config.getIdleIteration();
- this.threshold = config.getThreshold();
- this.maxDatanodesToBalance = config.getMaxDatanodesToBalance();
- this.maxSizeToMoveInGB = config.getMaxSizeToMove();
- this.unBalancedNodes = new ArrayList<>();
LOG.info("Starting Container Balancer...{}", this);
+
//we should start a new balancer thread async
//and response to cli as soon as possible
//TODO: this is a temporary implementation
//modify this later
- currentBalancingThread = new Thread(() -> balance());
+ currentBalancingThread = new Thread(this::balance);
currentBalancingThread.start();
////////////////////////
} finally {
lock.unlock();
}
-
return true;
}
/**
* Balances the cluster.
*/
private void balance() {
- for (int i = 0; i < idleIteration; i++) {
- if (!initializeIteration()) {
+ countDatanodesBalanced = 0;
+ totalSizeMoved = 0;
+ int i = 0;
+ do {
+ this.idleIteration = config.getIdleIteration();
+ this.threshold = config.getThreshold();
+ this.maxDatanodesToBalance = config.getMaxDatanodesToBalance();
+ this.maxSizeToMove = config.getMaxSizeToMove();
Review comment:
`idleIteration` should be moved out, but the rest should stay inside the
loop, right? `threshold` and other parameters can be changed while balancer is
running. So their values should be checked before every iteration.
--
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]