incubator-seata
incubator-seata copied to clipboard
feature(server): add ConnectionPoolController
- [x] I have read the CONTRIBUTING.md guidelines.
- [x] I have registered the PR changes.
Ⅰ. Describe what this PR did
Implemented private-protocol-based connection pool metrics reporting and server-side REST APIs.
-
Client (RM) side:
- Enhanced
RmNettyRemotingClientto includeConnectionPoolInfoin heartbeat messages (HeartbeatMessage.PING). - Reports pool metrics periodically (default: 30s) through a private channel without exposing public HTTP endpoints.
- Enhanced
-
Server (TC) side:
-
ServerHeartbeatProcessorparses and cachesConnectionPoolInfofrom incoming heartbeat messages. - Added access methods in
NettyRemotingServerto fetch all or per-client pool info.
-
-
REST endpoints:
- Added
ConnectionPoolControllerunder/api/v1/connection-pool:-
GET /info— Retrieve connection pool info of all clients. -
GET /info/{clientAddress}— Retrieve connection pool info of a specific client. -
GET /all— Retrieve locally collected data source pool metrics viaDataSourceConnectionPoolCollector.
-
- Added
-
Server integration:
- Registered
NettyRemotingServerin Spring context and injected it intoConnectionPoolControllerfor REST access.
- Registered
Backward-compatible: older clients still send standard heartbeat messages, and the server responds normally.
Ⅱ. Does this pull request fix one issue?
Yes, it fixs #7575 .
Ⅲ. Why don't you add test cases (unit test/integration test)?
- The changes involve both network-level heartbeat communication and in-memory caching logic, which are more suitable for integration testing.
- Test cases will be added.
Ⅳ. Describe how to verify it
- Start the Seata server.
- Run an RM client using this version of
RmNettyRemotingClient. - After ~30 seconds:
- Access
GET /api/v1/connection-pool/infoto view all active client pool info. - Access
GET /api/v1/connection-pool/info/{clientAddress}to query a specific client (use_instead of:in path). - Access
GET /api/v1/connection-pool/allto verify locally collected pool metrics.
- Access
- Verify that:
- New clients report valid metrics.
- Old clients work as before (no metrics available but heartbeat succeeds).