zhaohai666 opened a new pull request, #694:
URL: https://github.com/apache/rocketmq-dashboard/pull/694
feat(cluster): connect to real RocketMQ clusters via MQAdminExt
Summary
Introduces the foundation for talking to a real RocketMQ cluster instead of
serving hard-coded sample data. This wires up the rocketmq-tools admin client,
replaces the stub cluster provider with a live topology reader, and adds a
connectivity test endpoint that the Cluster page can call before onboarding a
cluster.
Motivation
Previously ClusterProviderStub returned canned ClusterVO sample data and was
never actually invoked by ClusterService — a dead seam with no path to real
broker topology. The "New Cluster" button on the Cluster page was a
work-in-progress placeholder (message.info). This PR turns that seam into a
working connection layer.
Changes
Backend
pom.xml: add rocketmq-tools (5.3.3) with a logback exclusion to avoid
logging conflicts.
MqAdminExtFactory: centralized connection lifecycle. Caches one
DefaultMQAdminExt per NameServer address, exposes execute(namesrvAddr, rpcHook,
action), and shuts admin clients down on @PreDestroy. Maps failures to
meaningful HTTP status (blank addr → 400, closed → 503, start/RPC error → 502).
newAdmin(RPCHook) is protected for test overrides.
RealClusterProvider (replaces ClusterProviderStub, now the single
ClusterProvider bean): reads live topology through examineBrokerClusterInfo()
and maps ClusterInfo → ClusterVO/BrokerVO (master address resolved via
MixAll.MASTER_ID, brokers sorted by name).
ClusterConnectionService + TestConnectionDTO + ClusterProbeResult: POST
/api/clusters/test-connection validates the NameServer address (@NotBlank),
probes the cluster, and returns connectivity status, resolved cluster name,
broker count/names, and elapsed time.
MqAdminProperties: @ConfigurationProperties(prefix = "studio.cluster.admin")
for the configured NameServer address.
Frontend
api/cluster.ts: add ClusterProbeResult type and
testClusterConnection(namesrvAddr).
services/clusterService.ts: testClusterConnection passthrough (mock-aware
under USE_MOCK).
pages/cluster/index.tsx: the "New Cluster" placeholder button now opens a
Test Connection modal that submits a NameServer address and renders the probe
result (cluster name, broker count, brokers, latency).
i18n/translations.ts: add cluster connection-test keys (zh/en); remove the
obsolete createClusterWip placeholder key.
API
POST /api/clusters/test-connectionRequest:
{ "namesrvAddr": "10.0.1.1:9876" }
Response (Result<ClusterProbeResult>):
{
"code": 0,
"data": {
"connected": true,
"namesrvAddr": "10.0.1.1:9876",
"clusterName": "DefaultCluster",
"brokerCount": 2,
"brokerNames": ["broker-a", "broker-b"],
"elapsedMillis": 128,
"message": "Connected to 2 broker(s) in 128ms"
}
}
Tests
Backend (new/updated): MqAdminExtFactoryTest (4), RealClusterProviderTest
(3), ClusterConnectionServiceTest (2), ClusterControllerTest (+2 for
test-connection); removed ClusterProviderStubTest. Cluster suite: 59 tests, 0
failures; full mvn test green; checkstyle:check clean.
Frontend: ClusterPage.test.tsx mock extended with testClusterConnection; tsc
--noEmit, ESLint, and vitest run all green (260 tests).
Notes / Follow-ups
This PR delivers the connection foundation (ARCH-01 + BASE-01): connectivity
probe and live topology mapping. Persisting probed clusters through the
onboarding flow and richer health/status mapping are left for a follow-up PR.
No breaking API changes; existing /api/clusters behavior is unchanged.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]