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

   # [RIP-1] Proxy config hot-reload, topology and health view (BASE-01 C)
   
   ## Background
   
   The RocketMQ Studio `rocketmq-studio` branch exposes Proxy management only 
through a thin
   compatibility controller (`/api/proxy/*`) plus a `ProxyController` whose 
single `POST /restart`
   endpoint delegates to `ClusterService.restartProxy`, which throws `501 Not 
implemented`. Proxy
   nodes also never appear in cluster discovery because `RealClusterProvider` 
always sets
   `ClusterVO.proxies` to an empty list.
   
   This change delivers the BASE-01 item C scope: concrete, unit-tested Proxy 
management endpoints
   (`list`, `config reload`, `topology`, `health`) and a dashboard view that 
renders topology and
   per-node health status with a working "Reload Config" action. The live Proxy 
transport is modelled
   as a **pluggable seam** — the default implementation is a no-op that returns 
success so the command
   path is fully exercisable end-to-end and in tests, while a real HTTP 
transport can be enabled
   without touching call sites.
   
   **Base branch:** `upstream/rocketmq-studio` at `a8d263e`. The branch was 
rebased onto the latest
   `rocketmq-studio`; it has zero file overlap with the latest upstream commits 
(including #1025), so
   no merge conflict arises.
   
   ## Commits
   
   ```
   3826050 feat: add Proxy config reload and topology endpoints (#RIP-1 T3)
   6b7b058 feat: extend Proxy page with topology, health and config reload 
(#RIP-1 T3)
   305ff1b docs: add PR doc for Proxy config hot-reload, topology and health 
view (#RIP-1 T3)
   ```
   
   ## Feature table
   
   | Endpoint | Method | Purpose | Files | Tests |
   | --- | --- | --- | --- | --- |
   | `/api/proxies?clusterId=` | GET | List configured proxies (merged from 
`ProxyAddressService`) | `ProxyController`, `ProxyService.listProxies` | 
`ProxyControllerTest`, `ProxyServiceTest` |
   | `/api/proxies/config/reload` | POST | Trigger proxy config hot-reload 
(`{clusterId, addr}`) | `ProxyController`, `ProxyService.reloadProxyConfig`, 
`ProxyConfigReloader` (+ `Noop`/`Http` impls) | `ProxyControllerTest`, 
`ProxyServiceTest`, `ProxyConfigReloaderTest` |
   | `/api/proxies/topology?clusterId=` | GET | Topology: proxies linked to 
brokers / name servers | `ProxyController`, `ProxyService.getProxyTopology`, 
`ProxyTopologyVO`/`ProxyTopologyNode` | `ProxyControllerTest`, 
`ProxyServiceTest` |
   | `/api/proxies/health?clusterId=&addr=` | GET | Health snapshot for one 
proxy node | `ProxyController`, `ProxyService.getProxyHealth`, `ProxyHealthVO` 
| `ProxyControllerTest`, `ProxyServiceTest` |
   | `RealClusterProvider` discovery | n/a | Populate `ClusterVO.proxies` from 
`ProxyAddressService` (read-only) | `RealClusterProvider` | 
`RealClusterProviderTest` |
   | Frontend: API + Proxy page | n/a | `listProxies`, `reloadProxyConfig`, 
`getProxyTopology`, `getProxyHealth`; topology section, health tags, Reload 
Config button | `web/src/api/proxy.ts`, `web/src/pages/studio/Proxy.tsx`, 
`web/src/i18n/translations.ts` | 
`web/src/pages/studio/__tests__/Proxy.test.tsx`, `web/src/api/proxy.test.ts` |
   
   Input validation: `clusterId` is required for all four GET/POST management 
endpoints (HTTP 400
   otherwise); the reload body also requires `addr`.
   
   ## Testing
   
   ### Backend (offline, JDK 21)
   
   ```
   cd server && 
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home \
     mvn -o test 
-Dtest='ProxyControllerTest,ProxyServiceTest,ProxyConfigReloaderTest,RealClusterProviderTest,ProxyAddressServiceTest,ProxyCompatControllerTest'
   ```
   
   Result: **32 tests, 32 passed** (ProxyControllerTest 11, ProxyServiceTest 4,
   ProxyConfigReloaderTest 2, RealClusterProviderTest 3, 
ProxyAddressServiceTest 9,
   ProxyCompatControllerTest 3).
   
   ### Frontend
   
   ```
   cd web && node_modules/.bin/tsc -b        # exits 0
   cd web && node_modules/.bin/vitest run 
src/pages/studio/__tests__/Proxy.test.tsx src/api/proxy.test.ts
   ```
   
   Result: **11 tests, 11 passed** (Proxy.test.tsx 6, proxy.test.ts 5); `tsc 
-b` exits 0.
   
   ## Design notes
   
   - **Pluggable reload seam.** `ProxyConfigReloader` is an interface. 
`NoopProxyConfigReloader`
     (`@Primary`) returns `success` without contacting a live proxy. 
`HttpProxyConfigReloader` best-effort
     `POST`s to `http://<addr>/admin/reloadConfig` and captures any failure in 
the result VO (never
     throws). Switching transports requires no change to `ProxyService` or the 
controller.
   - **Safe defaults.** Live metrics (`cpu`, `memory`, `tps`, `uptime`) and 
broker/name-server links
     are reported as `null` / empty when unavailable, so the UI renders 
explicit "N/A" instead of
     fabricated values. `RealClusterProvider` changes are read-only.
   - **No unrelated refactors.** Only Proxy-related code and the Proxy 
dashboard page were touched.
   
   ## Items not done (and why)
   
   - **Live proxy transport wiring** is intentionally left as a seam (`Noop` 
default). Pointing at a
     real proxy admin endpoint requires deployment-specific addressing/config 
that is out of scope for
     this change; the `HttpProxyConfigReloader` implementation is ready and can 
be enabled by qualifier.
   - **`ProxyController` restart endpoint** remains a guarded seam delegating 
to the existing
     `ClusterService.restartProxy` (still `501`), per the instruction to keep 
it but not implement live
     restart here.
   


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