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

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 8985fe1de fix(cluster): drop the resource counts no cluster path 
measures (#6853)
8985fe1de is described below

commit 8985fe1de890cd8a5db5f41e1a6e2ede47d5fe61
Author: bai mengxuan <[email protected]>
AuthorDate: Fri Nov 27 12:25:14 2026 +0800

    fix(cluster): drop the resource counts no cluster path measures (#6853)
---
 docs/api-spec.md                                   |  2 -
 .../cluster/broker/ClusterRepositoryImpl.java      |  6 --
 .../rocketmq/studio/cluster/broker/ClusterVO.java  |  6 +-
 .../provider/apache/RocketMQClusterProvider.java   |  2 -
 .../cluster/broker/ClusterControllerTest.java      |  2 -
 .../cluster/broker/ClusterResourceCountsTest.java  | 69 ++++++++++++++++++++++
 .../studio/cluster/broker/ClusterServiceTest.java  |  2 -
 web/src/api/cluster.ts                             |  2 -
 web/src/api/clusterContract.test.ts                |  2 -
 web/src/mock/clusters.ts                           |  6 --
 .../pages/cluster/__tests__/ClientsPage.test.tsx   |  4 --
 .../pages/cluster/__tests__/ClusterPage.test.tsx   |  2 -
 web/src/pages/cluster/clusterStats.test.ts         |  2 -
 .../pages/studio/__tests__/BrokerCluster.test.tsx  |  2 -
 .../__tests__/BrokerClusterInstanceScope.test.tsx  |  2 -
 web/src/services/clusterService.ts                 |  2 -
 16 files changed, 73 insertions(+), 40 deletions(-)

diff --git a/docs/api-spec.md b/docs/api-spec.md
index e719d4a2a..ef71759f9 100644
--- a/docs/api-spec.md
+++ b/docs/api-spec.md
@@ -611,8 +611,6 @@ GET /api/clusters
 | `proxies` | `ProxyInfo[]` | Proxy 节点列表 |
 | `nameServers` | `NameServerInfo[]` | NameServer 节点列表 |
 | `config` | `ClusterConfig` | 集群配置 |
-| `topicCount` | `number` | Topic 数量 |
-| `groupCount` | `number` | 消费组数量 |
 | `tpsHistory` | `number[]` | TPS 历史数据 |
 
 #### BrokerInfo
diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterRepositoryImpl.java
 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterRepositoryImpl.java
index 3a5731c05..704c0c919 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterRepositoryImpl.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterRepositoryImpl.java
@@ -99,8 +99,6 @@ public class ClusterRepositoryImpl implements 
ClusterRepository {
                         .map(this::copyNameServer)
                         .toList()))
                 .config(copyConfig(cluster.getConfig()))
-                .topicCount(cluster.getTopicCount())
-                .groupCount(cluster.getGroupCount())
                 .tpsHistory(cluster.getTpsHistory() == null ? null : new 
ArrayList<>(cluster.getTpsHistory()))
                 .build();
         copy.setId(cluster.getId());
@@ -235,8 +233,6 @@ public class ClusterRepositoryImpl implements 
ClusterRepository {
                                 .build()
                 ))
                 .config(config)
-                .topicCount(128)
-                .groupCount(45)
                 .tpsHistory(List.of(1200, 1350, 1100, 1450, 1280, 1500, 1380, 
1420, 1300, 1550))
                 .build();
         cluster1.setId("cluster-001");
@@ -288,8 +284,6 @@ public class ClusterRepositoryImpl implements 
ClusterRepository {
                         .flushDiskType(FlushDiskType.SYNC_FLUSH)
                         .brokerPermission(6)
                         .build())
-                .topicCount(32)
-                .groupCount(12)
                 .tpsHistory(List.of(320, 280, 350, 310, 290, 340, 300, 330, 
310, 350))
                 .build();
         cluster2.setId("cluster-002");
diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java
index 4b85de579..7049dd7f2 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java
@@ -35,6 +35,10 @@ import java.util.List;
  * Clusters are discovered from live broker state and cached by cluster name; 
they are not
  * backed by a database table, so the identifier stays a String instead of the 
numeric
  * auto-increment primary key used by persisted entities.
+ *
+ * <p>Carries no topic or consumer-group count: no cluster path measures them, 
so a number here
+ * would be read as measured. The measured per-cluster counts are served by 
GET /api/dashboard,
+ * which walks each master broker for them.
  */
 @Data
 @Builder
@@ -58,7 +62,5 @@ public class ClusterVO {
     private List<ProxyVO> proxies;
     private List<NameServerVO> nameServers;
     private ClusterConfigVO config;
-    private int topicCount;
-    private int groupCount;
     private List<Integer> tpsHistory;
 }
diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQClusterProvider.java
 
b/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQClusterProvider.java
index dd463f9ed..e9b2e1a8b 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQClusterProvider.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQClusterProvider.java
@@ -265,8 +265,6 @@ public class RocketMQClusterProvider implements 
ClusterProvider {
                 .proxies(Collections.emptyList())
                 .nameServers(nameServers != null ? nameServers : 
Collections.emptyList())
                 .tpsHistory(Collections.emptyList())
-                .topicCount(0)
-                .groupCount(0)
                 .build();
         cluster.setId(clusterName);
         return cluster;
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
index f3ad000d1..68bc15ea2 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
@@ -475,8 +475,6 @@ class ClusterControllerTest extends WebMvcAuthTestSupport {
                 .brokers(Collections.emptyList())
                 .proxies(Collections.emptyList())
                 .nameServers(Collections.emptyList())
-                .topicCount(10)
-                .groupCount(5)
                 .build();
         cluster.setId(id);
         return cluster;
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterResourceCountsTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterResourceCountsTest.java
new file mode 100644
index 000000000..5b9b7d97c
--- /dev/null
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterResourceCountsTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.studio.cluster.broker;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * A cluster view carries no resource counts, because no cluster path measures 
them:
+ * {@code RocketMQClusterProvider} discovers clusters from the NameServer and 
{@code
+ * RealClusterProvider} from the registry table, and neither counts the topics 
or consumer groups
+ * they hold. A count declared here therefore reached every client as a plain 
{@code 0} that was
+ * indistinguishable from a cluster with no resources at all - while the 
measured per-cluster
+ * numbers are served by {@code GET /api/dashboard}, which walks each master 
broker to collect
+ * them. The two counts stay out of the cluster payload and out of {@code 
docs/api-spec.md};
+ * re-adding one means teaching a cluster path to measure it first.
+ */
+class ClusterResourceCountsTest {
+
+    private static final Set<String> COUNT_FIELDS = Set.of("topicCount", 
"groupCount");
+
+    @Test
+    void clusterViewClaimsNoResourceCountTest() throws Exception {
+        ClusterVO cluster = ClusterVO.builder()
+                .id("DefaultCluster")
+                .name("DefaultCluster")
+                .endpoint("127.0.0.1:9876")
+                .tpsHistory(List.of(1, 2))
+                .build();
+
+        Set<String> keys = serializedFieldNames(cluster);
+
+        assertThat(keys).doesNotContainAnyElementsOf(COUNT_FIELDS);
+        // Keeps the assertion above from passing on a payload that serializes 
nothing at all.
+        assertThat(keys).contains("id", "name", "endpoint", "tpsHistory");
+    }
+
+    private static Set<String> serializedFieldNames(ClusterVO cluster) throws 
Exception {
+        JsonNode wire = new ObjectMapper().registerModule(new 
JavaTimeModule()).valueToTree(cluster);
+        Set<String> keys = new TreeSet<>();
+        for (Iterator<Map.Entry<String, JsonNode>> fields = wire.fields(); 
fields.hasNext(); ) {
+            keys.add(fields.next().getKey());
+        }
+        return keys;
+    }
+}
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
index 53b92463f..b0c276f19 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
@@ -111,8 +111,6 @@ class ClusterServiceTest {
                         .fileReservedTime(72)
                         .brokerPermission(6)
                         .build())
-                .topicCount(10)
-                .groupCount(5)
                 .build();
         sampleCluster.setId("cluster-1");
     }
diff --git a/web/src/api/cluster.ts b/web/src/api/cluster.ts
index 28a8907cc..d4cad96c7 100644
--- a/web/src/api/cluster.ts
+++ b/web/src/api/cluster.ts
@@ -32,8 +32,6 @@ export interface ClusterInfo {
   proxies: ProxyInfo[];
   nameServers: NameServerInfo[];
   config: ClusterConfig;
-  topicCount: number;
-  groupCount: number;
   tpsHistory: number[];
 }
 
diff --git a/web/src/api/clusterContract.test.ts 
b/web/src/api/clusterContract.test.ts
index 7eae15fb3..900b07ed6 100644
--- a/web/src/api/clusterContract.test.ts
+++ b/web/src/api/clusterContract.test.ts
@@ -63,8 +63,6 @@ const cluster: ClusterInfo = {
     brokerPermission: 6,
     deleteWhen: '04',
   },
-  topicCount: 10,
-  groupCount: 4,
   tpsHistory: [1, 2],
 };
 
diff --git a/web/src/mock/clusters.ts b/web/src/mock/clusters.ts
index 0fa858bf0..e8ef42c2e 100644
--- a/web/src/mock/clusters.ts
+++ b/web/src/mock/clusters.ts
@@ -175,8 +175,6 @@ export interface ClusterInfo {
   proxies: ProxyInfo[];
   nameServers: NameServerInfo[];
   config: ClusterConfig;
-  topicCount: number;
-  groupCount: number;
   tpsHistory: number[];
 }
 
@@ -303,8 +301,6 @@ const clusters: ClusterInfo[] = [
       flushDiskType: 'SYNC_FLUSH',
       brokerPermission: 6,
     },
-    topicCount: 256,
-    groupCount: 128,
     tpsHistory: [
       18200, 19800, 21400, 20100, 23680, 24100, 22500, 25800, 24600, 23200, 
22800, 24500,
     ],
@@ -387,8 +383,6 @@ const clusters: ClusterInfo[] = [
       flushDiskType: 'ASYNC_FLUSH',
       brokerPermission: 6,
     },
-    topicCount: 48,
-    groupCount: 24,
     tpsHistory: [5200, 5800, 6400, 6000, 7200, 6800, 6200, 7000, 7400, 6800, 
7200, 7600],
   },
 ];
diff --git a/web/src/pages/cluster/__tests__/ClientsPage.test.tsx 
b/web/src/pages/cluster/__tests__/ClientsPage.test.tsx
index 7291f4db5..797feac4d 100644
--- a/web/src/pages/cluster/__tests__/ClientsPage.test.tsx
+++ b/web/src/pages/cluster/__tests__/ClientsPage.test.tsx
@@ -47,8 +47,6 @@ const registryClusters: ClusterInfo[] = [
     proxies: [],
     nameServers: [],
     config: {} as ClusterInfo['config'],
-    topicCount: 0,
-    groupCount: 0,
     tpsHistory: [],
   },
   {
@@ -63,8 +61,6 @@ const registryClusters: ClusterInfo[] = [
     proxies: [],
     nameServers: [],
     config: {} as ClusterInfo['config'],
-    topicCount: 0,
-    groupCount: 0,
     tpsHistory: [],
   },
 ];
diff --git a/web/src/pages/cluster/__tests__/ClusterPage.test.tsx 
b/web/src/pages/cluster/__tests__/ClusterPage.test.tsx
index 3a9bb775a..d4d2f20f4 100644
--- a/web/src/pages/cluster/__tests__/ClusterPage.test.tsx
+++ b/web/src/pages/cluster/__tests__/ClusterPage.test.tsx
@@ -151,8 +151,6 @@ const buildCluster = ({
     brokerPermission: 6,
     deleteWhen: '04',
   },
-  topicCount: 10,
-  groupCount: 5,
   tpsHistory: [tpsIn],
 });
 
diff --git a/web/src/pages/cluster/clusterStats.test.ts 
b/web/src/pages/cluster/clusterStats.test.ts
index 33f605f17..911904f9c 100644
--- a/web/src/pages/cluster/clusterStats.test.ts
+++ b/web/src/pages/cluster/clusterStats.test.ts
@@ -42,8 +42,6 @@ const baseCluster: ClusterInfo = {
     brokerPermission: 6,
     deleteWhen: '04',
   },
-  topicCount: 10,
-  groupCount: 5,
   tpsHistory: [1, 2, 3],
 };
 
diff --git a/web/src/pages/studio/__tests__/BrokerCluster.test.tsx 
b/web/src/pages/studio/__tests__/BrokerCluster.test.tsx
index 2abdb7bba..dacd9f18f 100644
--- a/web/src/pages/studio/__tests__/BrokerCluster.test.tsx
+++ b/web/src/pages/studio/__tests__/BrokerCluster.test.tsx
@@ -117,8 +117,6 @@ const clusterFixture: ClusterInfo[] = [
       brokerPermission: 6,
       deleteWhen: '04',
     },
-    topicCount: 10,
-    groupCount: 5,
     tpsHistory: [],
   },
 ];
diff --git a/web/src/pages/studio/__tests__/BrokerClusterInstanceScope.test.tsx 
b/web/src/pages/studio/__tests__/BrokerClusterInstanceScope.test.tsx
index 182abc1a6..2ce7fa3b0 100644
--- a/web/src/pages/studio/__tests__/BrokerClusterInstanceScope.test.tsx
+++ b/web/src/pages/studio/__tests__/BrokerClusterInstanceScope.test.tsx
@@ -95,8 +95,6 @@ const buildCluster = (id: string, brokerName: string): 
ClusterInfo => ({
     brokerPermission: 6,
     deleteWhen: '04',
   },
-  topicCount: 1,
-  groupCount: 1,
   tpsHistory: [],
 });
 
diff --git a/web/src/services/clusterService.ts 
b/web/src/services/clusterService.ts
index 45c64a565..058d28b7a 100644
--- a/web/src/services/clusterService.ts
+++ b/web/src/services/clusterService.ts
@@ -48,8 +48,6 @@ function copyCluster(cluster: ClusterInfo): ClusterInfo {
     proxies: cluster.proxies.map((proxy) => ({ ...proxy })),
     nameServers: cluster.nameServers.map((nameServer) => ({ ...nameServer })),
     config: { ...cluster.config },
-    topicCount: cluster.topicCount,
-    groupCount: cluster.groupCount,
     tpsHistory: [...cluster.tpsHistory],
   };
 }

Reply via email to