You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2026/10/15 10:14:46 UTC
(rocketmq-dashboard) branch rocketmq-studio updated: fix(dashboard): order overview clusters by name (#6387)
This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new f3b0e6f36 fix(dashboard): order overview clusters by name (#6387)
f3b0e6f36 is described below
commit f3b0e6f36d768e66cb396f6482decae083c63d67
Author: 0 <19...@qq.com>
AuthorDate: Thu Oct 15 18:14:40 2026 +0800
fix(dashboard): order overview clusters by name (#6387)
* fix(dashboard): order overview clusters by name
* test(dashboard): end the overview-order test with Test and align the rationale
---
.../provider/apache/RocketMQDashboardProvider.java | 8 +++++--
.../apache/RocketMQDashboardProviderTest.java | 28 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProvider.java b/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProvider.java
index 5fdfd41a5..f49f3fbe4 100644
--- a/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProvider.java
+++ b/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProvider.java
@@ -363,8 +363,12 @@ public class RocketMQDashboardProvider implements DashboardProvider {
totalTopics = allTopics.size();
totalGroups = allGroups.size();
- // Build per-cluster overview
- for (Map.Entry<String, Set<String>> clusterEntry : clusterAddrTable.entrySet()) {
+ // Build per-cluster overview. A HashMap iterates deterministically for a given key
+ // set, but the cluster list view sorts by name; sort here too so the two views agree.
+ List<Map.Entry<String, Set<String>>> sortedClusters =
+ new ArrayList<>(clusterAddrTable.entrySet());
+ sortedClusters.sort(Map.Entry.comparingByKey());
+ for (Map.Entry<String, Set<String>> clusterEntry : sortedClusters) {
String clusterName = clusterEntry.getKey();
Set<String> brokerNames = clusterEntry.getValue() == null ? Set.of() : clusterEntry.getValue();
int clusterBrokers = 0;
diff --git a/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProviderTest.java b/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProviderTest.java
index 4e848406a..cf90c994f 100644
--- a/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProviderTest.java
+++ b/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQDashboardProviderTest.java
@@ -18,6 +18,7 @@ package org.apache.rocketmq.studio.provider.apache;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -862,6 +863,33 @@ class RocketMQDashboardProviderTest {
when(instanceRepository.findAll()).thenReturn(instances);
return new RocketMQDashboardProvider(adminFactory, properties, resolver, instanceRepository);
}
+
+ @Test
+ void dashboardClusterOverviewShouldOrderClustersByNameTest() throws Exception {
+ DefaultMQAdminExt adminExt = mock(DefaultMQAdminExt.class);
+ ClusterInfo info = new ClusterInfo();
+ HashMap<Long, String> addrs = new HashMap<>();
+ addrs.put(0L, "10.0.0.11:10911");
+ HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
+ brokerAddrTable.put("broker-a", new BrokerData("zeta-cluster", "broker-a", new HashMap<>(addrs)));
+ info.setBrokerAddrTable(brokerAddrTable);
+ HashMap<String, Set<String>> clusterAddrTable = new LinkedHashMap<>();
+ // Reverse insertion order so the table's iteration order differs from name order.
+ clusterAddrTable.put("zeta-cluster", Set.of("broker-a"));
+ clusterAddrTable.put("alpha-cluster", Set.of("broker-a"));
+ info.setClusterAddrTable(clusterAddrTable);
+ when(adminExt.examineBrokerClusterInfo()).thenReturn(info);
+ when(adminExt.getAllTopicConfig("10.0.0.11:10911", 5000)).thenReturn(topicConfig("order-topic"));
+ when(adminExt.getAllSubscriptionGroup("10.0.0.11:10911", 5000)).thenReturn(subscriptionGroups());
+ when(adminExt.fetchBrokerRuntimeStats("10.0.0.11:10911")).thenReturn(runtimeStats());
+
+ DashboardDataVO dashboard = newProvider(adminExt).getDashboardData();
+
+ // The overview list must be stable across snapshots like the cluster list is.
+ assertThat(dashboard.getClusters()).extracting(ClusterOverviewVO::getId)
+ .containsExactly("alpha-cluster", "zeta-cluster");
+ }
+
private ClusterInfo clusterInfo() {
ClusterInfo info = new ClusterInfo();
HashMap<Long, String> addrs = new HashMap<>();