HDDS-15628. [DiskBalancer] Preserve report output order for datanodes with the same density.#10562
Merged
Merged
Conversation
… with the same density.
adoroszlai
approved these changes
Jun 21, 2026
Contributor
|
Thanks @slfan1989 for the patch. |
Contributor
Author
@adoroszlai Thank you very much for helping review the code! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR makes DiskBalancer report output stable when multiple datanodes have the same
currentVolumeDensitySum.Previously, the report command collected successful datanode reports from
ConcurrentHashMap.values()before sorting by density. SinceConcurrentHashMapdoes not preserve insertion order, datanodes with the same density could be displayed in an order different from the user-provided datanode order.This patch builds the report list according to the successful datanode order instead. The existing density sort is stable, so datanodes with different density values are still sorted by
currentVolumeDensitySumin descending order, while datanodes with the same density keep the input order.What is the link to the Apache JIRA
JIRA: HDDS-15628. [DiskBalancer] Preserve report output order for datanodes with the same density.
How was this patch tested?
Add Junit Test.
For example, when running:
and both datanodes have the same density, the output should keep host-2 before host-1.
Before the fix:
After the fix: