Gargi-jais11 commented on code in PR #11503:
URL: https://github.com/apache/ozone/pull/11503#discussion_r4254743663


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -240,11 +240,8 @@ private void loadDiskBalancerInfo() throws IOException {
       if (diskBalancerInfoFile.exists()) {
         diskBalancerInfo = readDiskBalancerInfoFile(diskBalancerInfoFile);
       } else {
-        boolean shouldRunDefault =
-            conf.getObject(DiskBalancerConfiguration.class)
-                .getDiskBalancerShouldRun();
-        diskBalancerInfo = new DiskBalancerInfo(shouldRunDefault,
-            new DiskBalancerConfiguration());
+        DiskBalancerConfiguration diskBalancerConf = 
conf.getObject(DiskBalancerConfiguration.class);

Review Comment:
   `getObject `injects fields without calling the validating setters. With this 
patch, **applyDiskBalancerInfo → toConfiguration()** now runs setThreshold / 
setDiskBandwidthInMB / setParallelThread on raw XML values. 
   For example, `hdds.datanode.disk.balancer.parallel.thread=0` throws 
IllegalArgumentException("parallelThread must be a value larger than 0."). 
Nothing between the OzoneContainer constructor and HddsDatanodeService.main() 
catches it, so a new datanode exits . Datanodes with an existing 
diskBalancer.info still start fine.
   
   Could we add a` @PostConstruct validate()` to DiskBalancerConfiguration, the 
same pattern as `ContainerScannerConfiguration#validate?` It would WARN naming 
the key and reset threshold, bandwidth and thread count to their defaults. 
Please also add a test that a bad XML value on first init falls back to the 
default instead of failing.



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