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

   # PR-5: Implement client connection examination (Producer / Consumer)
   
   ## Summary
   
   The cluster client-connection feature was previously scaffolded but not wired
   up: `ClientProviderStub.findConnections` threw 
`UnsupportedOperationException`
   (HTTP 501) and the `examineProducerConnectionInfo` / 
`examineConsumerConnectionInfo`
   methods did not exist on the provider interface at all. This PR implements 
the
   provider end-to-end and exposes a full producer/consumer connection 
examination
   experience on the cluster **Clients** page.
   
   The implementation is backed by an in-memory seed store inside 
`ClientProviderStub`
   so the feature is runnable locally without a live NameServer/broker. 
Swapping the
   stub's internal data source for a real cloud-control-plane call is the only 
change
   needed to go to production.
   
   ## Changes
   
   ### Backend (`server/.../cluster/client`)
   
   - **`ClientProvider.java`** — added two method contracts:
     - `ProducerConnectionResultVO examineProducerConnectionInfo(String 
producerGroup)`
     - `ConsumerConnectionResultVO examineConsumerConnectionInfo(String 
consumerGroup)`
   - **`ClientProviderStub.java`** — implemented:
     - `findConnections(clusterId, type)` — now returns seeded connections 
filtered by
       cluster / client type (previously threw 501).
     - `examineProducerConnectionInfo(producerGroup)` — returns the producer 
clients
       connected to the given group (empty result when the group is unknown).
     - `examineConsumerConnectionInfo(consumerGroup)` — returns the consumer 
clients
       connected to the given group (empty result when the group is unknown).
   - **`ClientService.java`** — added `examineProducerConnectionInfo` /
     `examineConsumerConnectionInfo`, trimming and normalizing blank group 
filters the
     same way `listConnections` normalizes filters.
   - **`ClientController.java`** — exposed two new REST endpoints under 
`/api/clients`.
   - **`ConsumerConnectionVO`** (new) — mirrors `ProducerConnectionVO`
     (`clientId`, `clientAddr`, `language`, `versionDesc`).
   - **`ConsumerConnectionResultVO`** (new) — mirrors 
`ProducerConnectionResultVO`
     (`connectionSet: List<ConsumerConnectionVO>`).
   - **Unit tests** — expanded `ClientProviderStubTest` (seeded data, filters, 
both
     examine methods, empty-group guard) and `ClientServiceTest` (filter 
normalization,
     delegation to provider).
   
   ### Frontend (`web`)
   
   - **`api/connections.ts`** — added `examineProducerConnectionInfo(group)` and
     `examineConsumerConnectionInfo(group)` calling the new endpoints.
   - **`services/connectionsService.ts`** — added the two examine functions with
     `USE_MOCK` support (mock data sourced from `mock/clients.ts`).
   - **`pages/cluster/clients.tsx`** — added a **connection examination** card
     (select Producer/Consumer + enter group) and a result dialog listing the 
connected
     clients; empty-result and loading states handled. Interaction is lazily 
triggered
     so existing list behaviour / tests are unaffected.
   - **`i18n/translations.ts`** — added `clients.examine*` keys (zh + en).
   - **Unit tests** — added `api/connections.test.ts`, 
`services/connectionsService.test.ts`,
     and `pages/cluster/__tests__/ClientsExamine.test.tsx` covering 
producer/consumer
     examination, empty-group guard, and empty-result state.
   
   ## API changes
   
   | Method | Path | Description |
   | --- | --- | --- |
   | `GET` | `/api/clients` | List client connections (existing; now actually 
implemented) |
   | `GET` | `/api/clients/examine/producer/{producerGroup}` | Producer clients 
connected to the group |
   | `GET` | `/api/clients/examine/consumer/{consumerGroup}` | Consumer clients 
connected to the group |
   
   ### Response shapes
   
   **`GET /api/clients/examine/producer/{producerGroup}`**
   ```json
   {
     "code": 0,
     "data": {
       "connectionSet": [
         { "clientId": "[email protected]:49152",
           "clientAddr": "10.0.1.12:49152",
           "language": "JAVA",
           "versionDesc": "V5_0_0" }
       ]
     }
   }
   ```
   
   **`GET /api/clients/examine/consumer/{consumerGroup}`**
   ```json
   {
     "code": 0,
     "data": {
       "connectionSet": [
         { "clientId": "[email protected]:50110",
           "clientAddr": "10.0.2.21:50110",
           "language": "JAVA",
           "versionDesc": "V5_0_0" }
       ]
     }
   }
   ```
   
   An unknown group returns `connectionSet: []` (HTTP 200) rather than an error.
   
   ## Verification
   
   **Backend**
   - `mvn compile` with **JDK 21** — success (project targets Java 21; the 
sandbox
     default JDK 17 is insufficient).
   - `mvn test -Dtest='org.apache.rocketmq.studio.cluster.**'` — **164 tests 
pass**
     (includes `ClientProviderStubTest`, `ClientServiceTest`, 
`ClientControllerTest`).
   - `checkstyle:check` — **0 violations** (Apache checkstyle forbids non-ASCII 
in Java
     sources, so all backend user-facing strings are in English).
   
   **Frontend**
   - `tsc -b` — no type errors.
   - `vitest run` for the changed areas — **16/16 pass** (including the existing
     `ClientsPage.test.tsx`, confirming no regression).
   
   ## Notes
   
   - The two `examine` endpoints accept the group **name** as a path variable; 
blank /
     whitespace-only groups are normalized server-side and return an empty 
connection set.
   - `ClientProviderStub` is the demo implementation. To integrate with a real 
cluster,
     replace the stub's data source (or add a concrete `ClientProvider` bean) — 
the
     interface, service, controller, and frontend are already production-shaped.
   - This PR targets the **`feature/studio-client-connections`** branch, 
created from the
     updated `rocketmq-studio` (apache upstream).
   
   ## Checklist
   
   - [x] Backend provider + service + controller implemented
   - [x] New REST endpoints documented above
   - [x] Frontend API client + service (with mock) implemented
   - [x] Cluster Clients page exposes producer/consumer examination UI
   - [x] Backend unit tests added/extended
   - [x] Frontend unit tests added/extended
   - [x] `checkstyle` clean / `tsc -b` clean / tests green
   - [x] Committed and pushed to `origin/feature/studio-client-connections`
   


-- 
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]

Reply via email to