[studio] feat: expose gRPC client connection diagnostics in proxy GrpcChannelManager#10611
[studio] feat: expose gRPC client connection diagnostics in proxy GrpcChannelManager#10611btlqql wants to merge 1 commit into
Conversation
…cChannelManager GrpcChannelManager is the proxy-side source of truth for connected gRPC clients (clientIdChannelMap) and for pending relay response futures (resultNonceFutureMap), yet it exposed no way to observe either. Without read-only accessors, client connection management and runtime diagnosis are impossible for the Studio management platform and admin tooling. Add three read-only diagnostic methods. They are purely additive and do not change any gRPC/proto API or protocol contract, honoring the Track 2 "discuss before changing the protocol" guideline from issue apache#10600: - getChannelCount(): number of active gRPC client channels - getActiveClientIdSet(): unmodifiable snapshot of connected client ids - getPendingResponseFutureCount(): number of pending relay futures These form the foundation for the client-connection-management and runtime diagnostic capabilities highlighted by Track 2 of the RocketMQ Studio call for contributors. Add GrpcChannelManagerTest covering channel create/get/remove, idempotent creation, active-client-id snapshot and unmodifiable semantics, and pending response-future accounting. Relates to apache#10600 Signed-off-by: btlqql <2977859784@qq.com>
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Adds three read-only diagnostic methods to GrpcChannelManager (getChannelCount, getActiveClientIdSet, getPendingResponseFutureCount) to support the RocketMQ Studio Track 2 client connection observability goal. Purely additive, no protocol changes.
Findings
- [Info]
GrpcChannelManager.java:83—getActiveClientIdSet()correctly creates a defensive copy vianew HashSet<>(keySet())before wrapping inunmodifiableSet. Thread-safe snapshot for diagnostic use. - [Info]
GrpcChannelManager.java:77,87—.size()onConcurrentHashMapreturns a weakly-consistent count, which is appropriate for diagnostics (no locking overhead). - [Info]
GrpcChannelManagerTest.java— Good test coverage: idempotent creation, snapshot independence, unmodifiable enforcement (UnsupportedOperationException), and future accounting. Tests follow existing patterns (InitConfigTest, JUnit 4 + Mockito).
Suggestions
- [Info] Consider adding brief Javadoc to the three new public methods explaining their diagnostic purpose and thread-safety guarantees (weakly-consistent for counts, snapshot for client IDs). This helps future consumers understand the semantics without reading the implementation.
Verdict
Clean, well-tested, purely additive change. LGTM.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
PR: [studio] feat: expose gRPC client connection diagnostics in proxy GrpcChannelManager
Verdict: ✅ Approved
Summary
Adds three diagnostic methods to GrpcChannelManager for monitoring active gRPC client connections:
getChannelCount()— number of active client channelsgetActiveClientIdSet()— set of active client IDs (defensive copy, unmodifiable)getPendingResponseFutureCount()— number of pending response futures
Analysis
Correctness ✅
getActiveClientIdSet()creates a defensive copy (new HashSet<>(clientIdChannelMap.keySet())) wrapped inCollections.unmodifiableSet()— prevents external modification of internal state. Good practice.- All three methods are simple read-throughs to the underlying
ConcurrentHashMap, thread-safe.
Performance ✅
getActiveClientIdSet()copies the key set, which is O(n) in the number of active clients. Acceptable for diagnostics/monitoring use cases. If called frequently in hot paths, consider caching, but for monitoring this is fine.
Compatibility ✅
- Additive API — new public methods only, no existing behavior changed.
Tests ✅
- New test class
GrpcChannelManagerTestwith 164 lines covering:- Empty state diagnostics
- Adding/removing channels and verifying counts
- Verifying the returned client ID set is unmodifiable
- Pending response future tracking
- Good test coverage for the new functionality.
Verdict
Clean, well-tested diagnostic addition. Useful for operational monitoring of proxy connections.
[studio] feat: expose gRPC client connection diagnostics in proxy GrpcChannelManager
Relates to #10600 (RocketMQ Studio: AI-Native Management Platform — Track 2: Proxy Admin management capability upgrade).
Background
GrpcChannelManageris the proxy-side source of truth for connected gRPCclients (
clientIdChannelMap) and for pending relay response futures(
resultNonceFutureMap). Until now it exposed no way to observe either,which makes client connection management and runtime diagnosis impossible for
the Studio management platform and for admin/diagnostic tooling — the exact
capabilities called out by Track 2 of issue #10600 ("client connection
management and runtime diagnostic capabilities").
What this PR does
Adds three read-only, purely additive diagnostic methods to
org.apache.rocketmq.proxy.grpc.v2.channel.GrpcChannelManager:getChannelCount()getActiveClientIdSet()getPendingResponseFutureCount()These methods do not alter any gRPC/proto API or protocol contract, so they
respect the Track 2 guideline that protocol/interface changes must be discussed
in an issue first. They are the foundation on which the Studio platform and
admin tooling can build standardized client-connection observation.
Why no protocol change here
Issue #10600 explicitly requires that Track 2 protocol/admin interface changes
be discussed and reach community consensus before code is submitted. This PR
intentionally avoids touching the proxy admin gRPC contract; it only opens up
read-only access to existing in-memory state so it can be consumed later by the
standardized admin layer once that design is agreed upon.
Tests
Adds
GrpcChannelManagerTest(extendsInitConfigTest, JUnit 4 + Mockito),mirroring the existing
GrpcClientChannelTest, covering:getChannelCounttrackinggetActiveClientIdSet()returns an unmodifiable snapshot (independent oflater channel removal)
getPendingResponseFutureCount()accounting throughaddResponseFuture/getAndRemoveResponseFuture@AfterSelf-check
[studio]