chihsuan opened a new pull request, #10519: URL: https://github.com/apache/ozone/pull/10519
## What changes were proposed in this pull request? `CapacityVolumeChoosingPolicy` is the default datanode volume-choosing policy. Per its documentation in `ozone-default.xml`, it should randomly pick two volumes with remaining space and then choose the one with **lower utilization**. The implementation instead compared the **absolute available bytes** (`available - committed`) and picked the volume with more free bytes. On a homogeneous datanode (all volumes the same capacity) the two orderings coincide, so there is no visible issue. On a heterogeneous datanode whose volumes differ in capacity (e.g. a 24TB HDD next to a 2TB NVMe SSD) the large volume almost always has more free bytes, so it is selected repeatedly and fills up sooner than the small one, causing imbalance. This change makes `chooseVolume` compare the free-space ratio `(available - committed) / capacity` and prefer the higher ratio (= lower utilization). `capacity` already excludes reserved space, so the ratio is the correct utilization signal. The existing "pick 2 random volumes, choose the better one" algorithm is otherwise unchanged. A small `freeSpaceRatio` helper guards against `capacity <= 0` and uses double division to avoid overflow. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-15091 ## How was this patch tested? Added a unit test `TestCapacityVolumeChoosingPolicy#choosesLowerUtilizationAcrossDifferentCapacities` covering the heterogeneous case: a big volume (capacity 1000, 100 free, 90% full) and a small volume (capacity 200, 80 free, 60% full). The big volume has more free bytes but higher utilization; the test asserts the less-utilized small volume is chosen more often over 1000 rounds. The old logic fails this (big chosen ~756/1000); the new logic passes (small chosen ~750/1000). - `mvn -pl :hdds-container-service test -Dtest=TestCapacityVolumeChoosingPolicy` → 5 tests, 0 failures, 0 errors. Existing equal-capacity tests still pass (ratio and absolute-byte ordering coincide there). - `mvn -pl :hdds-container-service checkstyle:check` → 0 violations. -- 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]
