adoroszlai commented on code in PR #4458:
URL: https://github.com/apache/ozone/pull/4458#discussion_r1147200664


##########
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",

Review Comment:
   ```suggestion
               HddsConfigKeys.HDDS_SCM_WAIT_TIME_AFTER_SAFE_MODE_EXIT,
   ```



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerTask.java:
##########
@@ -211,6 +225,8 @@ private void balance() {
           // one for sending command , one for running du, and one for
           // reporting back make it like this for now, a more suitable
           // value. can be set in the future if needed
+          LOG.info("ContainerBalancer will sleep for some time while waiting " 
+
+              "for updated usage information from Datanodes.");
           Thread.sleep(3 * nodeReportInterval);

Review Comment:
   Would it make sense to log sleep duration, like the one before start?



##########
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:
   Possible improvement for test:
   
   * extract method `delayStart()`
   * override the method in the instance being tested to update an 
`AtomicBoolean` instead of actual sleep
   * assert value of the `AtomicBoolean` depending on whether sleep is expected 
or not
   (or maybe even `AtomicLong` to assert the duration of the sleep if you want 
to confirm it is using the right config value)
   
   The extracted method also improves `run()`, to keep abstraction at the same 
level.  (Compare detailed steps of delaying the start to a `balance()` call 
that hides complexity.)



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