Skip to content

HDDS-15628. [DiskBalancer] Preserve report output order for datanodes with the same density.#10562

Merged
adoroszlai merged 1 commit into
apache:masterfrom
slfan1989:HDDS-15628
Jun 21, 2026
Merged

HDDS-15628. [DiskBalancer] Preserve report output order for datanodes with the same density.#10562
adoroszlai merged 1 commit into
apache:masterfrom
slfan1989:HDDS-15628

Conversation

@slfan1989

Copy link
Copy Markdown
Contributor

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. Since ConcurrentHashMap does 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 currentVolumeDensitySum in 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:

ozone admin datanode diskbalancer report host-2 host-1

and both datanodes have the same density, the output should keep host-2 before host-1.

Before the fix:

Report result:
Datanode: host-1 (127.0.0.1:19864)
Aggregate VolumeDataDensity: 14.09%

-------

Datanode: host-2 (127.0.0.1:19864)
Aggregate VolumeDataDensity: 14.09%

After the fix:

Report result:
Datanode: host-2 (127.0.0.1:19864)
Aggregate VolumeDataDensity: 14.09%

-------

Datanode: host-1 (127.0.0.1:19864)
Aggregate VolumeDataDensity: 14.09%

@adoroszlai adoroszlai merged commit 515bbb7 into apache:master Jun 21, 2026
47 checks passed
@adoroszlai

Copy link
Copy Markdown
Contributor

Thanks @slfan1989 for the patch.

@slfan1989

Copy link
Copy Markdown
Contributor Author

Thanks @slfan1989 for the patch.

@adoroszlai Thank you very much for helping review the code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants