This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 515bbb7dbec HDDS-15628. [DiskBalancer] Preserve output order for 
datanodes with the same density (#10562)
515bbb7dbec is described below

commit 515bbb7dbecccbb5d2f6e244a4fc3717622132cb
Author: slfan1989 <[email protected]>
AuthorDate: Sun Jun 21 17:49:14 2026 +0800

    HDDS-15628. [DiskBalancer] Preserve output order for datanodes with the 
same density (#10562)
---
 .../cli/datanode/DiskBalancerReportSubcommand.java |  4 +++-
 .../cli/datanode/TestDiskBalancerSubCommands.java  | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DiskBalancerReportSubcommand.java
 
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DiskBalancerReportSubcommand.java
index a098d7a30e7..16a91d45e28 100644
--- 
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DiskBalancerReportSubcommand.java
+++ 
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DiskBalancerReportSubcommand.java
@@ -86,7 +86,9 @@ protected void displayResults(List<String> successNodes, 
List<String> failedNode
 
     // Display consolidated report for successful nodes
     if (!successNodes.isEmpty() && !reports.isEmpty()) {
-      List<DatanodeDiskBalancerInfoProto> reportList = new 
ArrayList<>(reports.values());
+      List<DatanodeDiskBalancerInfoProto> reportList = successNodes.stream()
+          .map(reports::get)
+          .collect(toList());
       System.out.println(generateReport(reportList));
     }
   }
diff --git 
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestDiskBalancerSubCommands.java
 
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestDiskBalancerSubCommands.java
index d7133a3216a..1f935973468 100644
--- 
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestDiskBalancerSubCommands.java
+++ 
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestDiskBalancerSubCommands.java
@@ -697,6 +697,30 @@ public void testReportDiskBalancerWithMultipleNodes() 
throws Exception {
     }
   }
 
+  @Test
+  public void testReportDiskBalancerWithSameDensityKeepsInputOrder() throws 
Exception {
+    DiskBalancerReportSubcommand cmd = new DiskBalancerReportSubcommand();
+
+    DatanodeDiskBalancerInfoProto reportProto1 = createReportProto("host-1", 
0.5, 10.0);
+    DatanodeDiskBalancerInfoProto reportProto2 = createReportProto("host-2", 
0.5, 10.0);
+
+    when(mockProtocol.getDiskBalancerInfo())
+        .thenReturn(reportProto2, reportProto1);
+
+    try (DiskBalancerMocks mocks = setupAllMocks()) {
+
+      CommandLine c = new CommandLine(cmd);
+      c.parseArgs("host-2", "host-1");
+      cmd.call();
+
+      String output = outContent.toString(DEFAULT_ENCODING);
+      int host2Index = output.indexOf("host-2");
+      int host1Index = output.indexOf("host-1");
+      assertThat(host2Index).isGreaterThanOrEqualTo(0);
+      assertThat(host1Index).isGreaterThan(host2Index);
+    }
+  }
+
   @Test
   public void testReportDiskBalancerWithStdin() throws Exception {
     DiskBalancerReportSubcommand cmd = new DiskBalancerReportSubcommand();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to