You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "yyqdbngt (via GitHub)" <gi...@apache.org> on 2026/08/07 15:51:35 UTC

[PR] fix(cluster): group brokers by their owning cluster in discovery [rocketmq-dashboard]

yyqdbngt opened a new pull request, #1253:
URL: https://github.com/apache/rocketmq-dashboard/pull/1253

   `RealClusterProvider.discoverClusters` produced a single `ClusterVO` using the first cluster name from `clusterAddrTable` but included *every* broker from `brokerAddrTable`, so a NameServer managing multiple clusters lumped all brokers into one cluster with a misleading name.
   
   Discovery now emits one `ClusterVO` per cluster, grouping brokers by their owning cluster. A unit test covers the multi-cluster case.
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): group brokers by their owning cluster in discovery [rocketmq-dashboard]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on PR #1253:
URL: https://github.com/apache/rocketmq-dashboard/pull/1253#issuecomment-5219694942

   ⚠️ **Merge conflict detected**
   
   This PR has conflicts with the `rocketmq-studio` branch and cannot be merged. Please rebase or merge the base branch into your branch and resolve the conflicts:
   
   ```bash
   git fetch origin
   git checkout fix/cluster-group-by-cluster
   git rebase origin/rocketmq-studio
   # resolve conflicts, then:
   git push --force-with-lease
   ```
   
   This is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved.
   
   ---
   *Automated notification by github-manager-bot*


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): group brokers by their owning cluster in discovery [rocketmq-dashboard]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on code in PR #1253:
URL: https://github.com/apache/rocketmq-dashboard/pull/1253#discussion_r3737331527


##########
server/src/main/java/org/apache/rocketmq/studio/cluster/broker/RealClusterProvider.java:
##########
@@ -67,7 +68,71 @@ public ClusterVO refreshClusterDetail(String clusterId) {
         if (namesrvAddr == null || namesrvAddr.isBlank()) {
             throw new BusinessException(400, "No NameServer configured for cluster " + clusterId);
         }
-        return describeCluster(namesrvAddr);
+        return describeClusters(namesrvAddr).stream()

Review Comment:
   **[Performance]** `refreshClusterDetail()` now calls `describeClusters()` which fetches ALL clusters from the NameServer, then filters by ID. For a dashboard with many clusters, this is less efficient than the previous direct lookup.
   
   Consider keeping a dedicated single-cluster lookup path for `refreshClusterDetail()`, or cache the result if this endpoint is called frequently.
   
   Not blocking — acceptable for a dashboard UI operation.



##########
server/src/main/java/org/apache/rocketmq/studio/cluster/broker/RealClusterProvider.java:
##########
@@ -67,7 +68,71 @@ public ClusterVO refreshClusterDetail(String clusterId) {
         if (namesrvAddr == null || namesrvAddr.isBlank()) {
             throw new BusinessException(400, "No NameServer configured for cluster " + clusterId);
         }
-        return describeCluster(namesrvAddr);
+        return describeClusters(namesrvAddr).stream()
+                .filter(cluster -> clusterId.equals(cluster.getId()))
+                .findFirst()
+                .orElseThrow(() -> new BusinessException(404, "Cluster not found: " + clusterId));
+    }
+
+    /**
+     * Maps the live topology into one {@link ClusterVO} per cluster known to the NameServer.
+     * Brokers are grouped by their owning cluster, so a NameServer that manages several clusters
+     * no longer lumps every broker into a single cluster.
+     */
+    public List<ClusterVO> describeClusters(String namesrvAddr) {
+        return adminFactory.execute(namesrvAddr, null,
+                admin -> toClusterVOs(namesrvAddr, admin.examineBrokerClusterInfo()));
+    }
+
+    private List<ClusterVO> toClusterVOs(String namesrvAddr, ClusterInfo clusterInfo) {
+        Map<String, BrokerData> brokerAddrTable =
+                clusterInfo.getBrokerAddrTable() == null ? Map.of() : clusterInfo.getBrokerAddrTable();
+        Map<String, Set<String>> clusterAddrTable =
+                clusterInfo.getClusterAddrTable() == null ? Map.of() : clusterInfo.getClusterAddrTable();
+        List<NameServerVO> nameServers = Arrays.stream(namesrvAddr.split("[;,]"))
+                .map(String::trim)
+                .filter(addr -> !addr.isEmpty())
+                .map(addr -> NameServerVO.builder().addr(addr).status(ClusterStatus.healthy).build())

Review Comment:
   **[Suggestion]** The broker sorting comparator is duplicated in two places within `toClusterVOs()` (lines 95 and 108). Consider extracting it to a constant:
   
   ```java
   private static final Comparator<BrokerVO> BY_NAME = 
       Comparator.comparing(BrokerVO::getName, Comparator.nullsLast(Comparator.naturalOrder()));
   ```
   
   Then use `.sorted(BY_NAME)` in both places.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): group brokers by their owning cluster in discovery [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #1253: fix(cluster): group brokers by their owning cluster in discovery
URL: https://github.com/apache/rocketmq-dashboard/pull/1253


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): group brokers by their owning cluster in discovery [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #1253:
URL: https://github.com/apache/rocketmq-dashboard/pull/1253#issuecomment-5236387912

   Closing without merging: broker grouping by owning cluster already shipped via #1055 (preserve live multi-cluster topology). Thanks for the contribution! / 关闭未合入:按归属集群分组 broker 的能力已由 #1055 提供。感谢贡献!


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org