zhaohai666 opened a new pull request, #768:
URL: https://github.com/apache/rocketmq-dashboard/pull/768
# feat: Implement Topic metadata provider and topic CRUD
## Summary
The Topic management feature was previously scaffolded on the frontend, but
the
backend `CloudMetadataProvider` and `NameSrvAdminClient` were stubs that
threw
`UnsupportedOperationException`. This PR wires them to a shared in-memory
`TopicStore` so the Topic feature works end-to-end, and adds two new
capabilities: **route health diagnostics** (`examineTopicRouteInfo`) and a
**global topic list** (`fetchAllTopicList`).
## Changes
### Backend (`server`)
- **`TopicStore`** (new): a single in-memory store backing both reads
(metadata
provider) and writes (admin client), keeping `create`/`list`/`delete`
consistent. It acts as a stand-in for the real cloud control plane — swap
its
internals to integrate the actual backend.
- **`TopicRouteExaminationVO`** (new): DTO returned by the route-diagnosis
endpoint.
- **`CloudMetadataProvider`**: implemented `listTopics`, `getTopicRoutes`,
`getTopicConsumers`; added `examineTopicRouteInfo` and `fetchAllTopicList`.
- **`NameSrvAdminClient`**: implemented `createTopic`, `updateTopic`,
`deleteTopic`, `getTopic` via the shared store.
- **`MetadataProvider`**: interface extended with `examineTopicRouteInfo` and
`fetchAllTopicList`.
- **`MetadataService`** / **`TopicController`**: exposed two new endpoints:
- `GET /api/topics/examine/{name}` → `TopicRouteExaminationVO` (broker
count,
total read/write queues, read/write balance flag, health status, and
human-readable findings).
- `GET /api/topics/all` → all topics across clusters.
### Frontend (`web`)
- **`api/metadata.ts`**: added `examineTopicRouteInfo` / `fetchAllTopicList`
and
the `TopicRouteExamination` type.
- **`services/topicService.ts`**: mock-aware wrappers with the same
signatures.
- **`pages/instance/topic.tsx`**: added a route-diagnosis panel inside the
topic
detail modal and a "Load all topics" action in the list toolbar. Both are
lazily triggered and do not alter existing interactions.
- **`i18n/translations.ts`**: added zh/en keys for the new UI text.
## API changes
| Method | Path | Description |
| --- | --- | --- |
| GET | `/api/topics` | list topics (clusterId / type / search) |
| POST | `/api/topics/create` | create topic |
| POST | `/api/topics/update` | update topic |
| POST | `/api/topics/delete` | delete topic |
| GET | `/api/topics/{name}/routes` | topic route info |
| GET | `/api/topics/examine/{name}` | **NEW** route health diagnostics |
| GET | `/api/topics/all` | **NEW** all topics across clusters |
| GET | `/api/topics/{name}/consumers` | topic consumers |
| POST | `/api/topics/send` | send test message |
## Route diagnostics (`examineTopicRouteInfo`)
The endpoint inspects a topic's route distribution and reports:
- `brokerCount` — number of brokers hosting the topic
- `totalWriteQueues` / `totalReadQueues` — aggregate queue counts
- `readWriteBalanced` — whether read/write queues match per broker
- `health` — `HEALTHY` / `WARNING` / `ERROR`
- `findings` — actionable, human-readable diagnostics (e.g. read/write queue
mismatch, broker queue imbalance, single-broker availability risk, zero
queues)
## Verification
- **Backend**: `mvn -o compile` passes with **JDK 21** (the project's
`release`
target is 21); Checkstyle is clean.
- **Frontend**: `tsc -b` reports no type errors; `vitest` topic/metadata
suites
pass. The existing `TopicPage.test.tsx` remains green because the new
features
are lazily triggered.
## Notes
- The in-memory `TopicStore` is a demo/integration stand-in. Connecting to
the
real cloud control plane only requires replacing its data-access internals.
- Apache Checkstyle forbids non-ASCII characters in Java sources, so
backend-facing strings are written in English.
## Checklist
- [ ] Backend compiles and Checkstyle passes (JDK 21)
- [ ] Frontend type-checks and tests pass
- [ ] New API endpoints documented above
- [ ] UI strings covered by i18n (zh/en)
--
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]