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

   ## Summary
   Implement cluster and broker management module, providing core APIs 
including cluster list query, cluster detail retrieval, cluster configuration 
update, and broker restart. The module adopts a layered architecture 
(Controller → Service → Repository/Provider), with in-memory stub data 
implementation and full unit test coverage.
   
   ## Files Changed
   12 files modified, total 1141 line insertions
   
   ### Controller Layer
   #### ClusterController.java
   Annotated with `@RestController` and `@RequestMapping("/api/clusters")`, 
exposes 4 API endpoints:
   - `GET /api/clusters`: Query cluster list
   - `GET /api/clusters/{id}`: Get single cluster details
   - `POST /api/clusters/config/update`: Update cluster configurations
   - `POST /api/clusters/{clusterId}/brokers/{name}/restart`: Trigger broker 
restart
   
   ### Service Layer
   #### ClusterService.java
   Annotated with `@Service`, contains core business logic:
   1. Query methods: `listClusters()`, `getCluster(id)`
      - Throws `BusinessException` with 404 code when target cluster cannot be 
found
   2. `updateClusterConfig(UpdateConfigDTO)`
      - Supports incremental update of 8 configuration fields
      - Automatically creates empty config record if incoming config is null
   3. `restartBroker(clusterId, brokerName)`
      - Validates target cluster existence before execution
   4. Reserved methods for NameServer & Proxy operations:
      `createNameServer`, `updateNameServer`, `restartNameServer`, 
`upgradeNameServer`, `deleteNameServer`, `restartProxy`
      - References DTOs from nameserver and proxy packages for future extension
   
   ### Repository Layer
   #### ClusterRepository.java
   Repository interface with methods:
   `findAll()`, `findById(id)`, `updateConfig(id, config)`
   
   #### ClusterRepositoryImpl.java
   Annotated with `@Repository`
   - Uses `ConcurrentHashMap` for in-memory data storage
   - Preloads 2 stub clusters (prod & staging) with complete embedded Broker, 
Proxy, NameServer and configuration data
   
   ### Provider Layer
   #### ClusterProvider.java
   Provider interface with methods:
   `discoverClusters()`, `refreshClusterDetail(id)`
   
   #### ClusterProviderStub.java
   Annotated with `@Component`
   - Returns static single-cluster stub mock data
   
   ### VO & DTO Model Files
   1. `ClusterVO.java`
      - Extends `BaseEntity`
      - Fields: name, type, endpoint, status, brokers, proxies, nameServers, 
config, topicCount, groupCount, tpsHistory
   2. `BrokerVO.java`
      - Fields: name, addr, version, status, diskUsage, tpsIn, tpsOut
   3. `ClusterConfigVO.java`
      - Contains 10 configuration entries: writeQueueNums, readQueueNums, 
maxMessageSize, flushDiskType, etc.
   4. `UpdateConfigDTO.java`
      - Command object for partial config update
      - All fields use wrapped types (Boolean / Integer), optional to support 
incremental patch
   
   ### Test Files
   #### ClusterControllerTest.java
   - Annotated with `@WebMvcTest`
   - 5 test cases: 2 for cluster list query, 1 for cluster detail query, 1 for 
config update, 1 for broker restart
   
   #### ClusterServiceTest.java
   - Annotated with `@ExtendWith(MockitoExtension)`
   - 11 test cases: 2 list queries, 2 detail queries, 5 incremental config 
updates, 2 broker restart logics
   - Uses AssertJ for fluent assertion
   
   ## Key Design
   1. Clear layered architecture: Controller → Service → Repository + Provider 
with separated responsibilities
   2. Incremental configuration update
      All fields in `UpdateConfigDTO` are nullable wrapped types; null fields 
will not overwrite existing values to support partial patch
   3. Stub mock data strategy
      `ClusterRepositoryImpl` and `ClusterProviderStub` provide in-memory mock 
data to facilitate front-end local development and debugging
   4. Unified global exception handling
      Relies on common foundation module: throws `BusinessException` (404 Not 
Found), captured uniformly by `GlobalExceptionHandler`
   5. Cross-module forward compatibility
      `ClusterService` references VO/DTO from nameserver and proxy modules, 
reserving interfaces for follow-up PR development
   
   ## Dependencies
   Depends on branch `feature/studio-common-foundation`:
   Reuses `BaseEntity`, unified response `Result`, `BusinessException`, 
`GlobalExceptionHandler` and business enums (ClusterStatus, ClusterType, 
BrokerStatus, FlushDiskType)
   
   Cross-module reference:
   This module imports VO/DTO classes from nameserver and proxy submodules
   
   ## Test Coverage
   - Controller layer: 5 test cases covering all 4 API endpoints (including 
empty list boundary case)
   - Service layer: 11 test cases covering normal flow, 404 exception flow, 
incremental config patch and empty config creation logic
   - Total: 16 test methods, 417 lines of test code
   
   ## PR Title Specification Reminder
   All PR and Issue titles of this project must start with `[studio]` to help 
community quickly filter and track related work items.
   Example:
   `[studio] feat: implement cluster and broker management module with stub 
data`


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