sodonnel commented on code in PR #4458:
URL: https://github.com/apache/ozone/pull/4458#discussion_r1146894005
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerTask.java:
##########
@@ -162,6 +167,15 @@ public ContainerBalancerTask(StorageContainerManager scm,
*/
public void run() {
try {
+ if (delayStart) {
+ long delayDuration = ozoneConfiguration.getTimeDuration(
+ "hdds.scm.wait.time.after.safemode.exit",
+ HddsConfigKeys.HDDS_SCM_WAIT_TIME_AFTER_SAFE_MODE_EXIT_DEFAULT,
+ TimeUnit.SECONDS);
+ LOG.info("ContainerBalancer will sleep for {} seconds before starting"
+
+ " balancing.", delayDuration);
+ Thread.sleep(Duration.ofSeconds(delayDuration).toMillis());
Review Comment:
I wonder if we could do something better than sleep here. The sleep means
that the tests have to wait for at least the duration of the sleep to pass
which makes them slow.
If we have a clock in here, and we change the sleep to `wait()`, then we
could advance the clock in a test, and notify the thread to wake it up and
check if it should run or not, calculate a new wait time and `wait` again.
Note that #4432 is adding a method to scm to get the clock, so once it is
committed we could use it here if we go with this approach.
--
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]