Oscarcheng0312 opened a new pull request, #7696:
URL: https://github.com/apache/incubator-seata/pull/7696
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Please make sure you have read and understood the contributing
guidelines -->
- [x] I have read the
[CONTRIBUTING.md](https://github.com/apache/incubator-seata/blob/2.x/CONTRIBUTING.md)
guidelines.
- [x] I have registered the PR
[changes](https://github.com/apache/incubator-seata/tree/2.x/changes).
### Ⅰ. Describe what this PR did
Implemented private-protocol-based connection pool metrics reporting and
server-side REST APIs.
- **Client (RM) side**:
- Enhanced `RmNettyRemotingClient` to include `ConnectionPoolInfo` in
heartbeat messages (`HeartbeatMessage.PING`).
- Reports pool metrics periodically (default: 30s) through a private
channel without exposing public HTTP endpoints.
- **Server (TC) side**:
- `ServerHeartbeatProcessor` parses and caches `ConnectionPoolInfo` from
incoming heartbeat messages.
- Added access methods in `NettyRemotingServer` to fetch all or per-client
pool info.
- **REST endpoints**:
- Added `ConnectionPoolController` under `/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 via
`DataSourceConnectionPoolCollector`.
- **Server integration**:
- Registered `NettyRemotingServer` in Spring context and injected it into
`ConnectionPoolController` for REST access.
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
1. Start the Seata server.
2. Run an RM client using this version of `RmNettyRemotingClient`.
3. After ~30 seconds:
- Access `GET /api/v1/connection-pool/info` to 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/all` to verify locally collected
pool metrics.
4. Verify that:
- New clients report valid metrics.
- Old clients work as before (no metrics available but heartbeat
succeeds).
### Ⅴ. Special notes for reviews
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]