[ISSUE #6269]🚀Implement GetBrokerEpoch command in rocketmq-admin-core#6372
[ISSUE #6269]🚀Implement GetBrokerEpoch command in rocketmq-admin-core#6372
Conversation
|
🔊@WaterWhisperer 🚀Thanks for your contribution🎉! 💡CodeRabbit(AI) will review your code first🔥! Note 🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥. |
WalkthroughThis PR implements the GetBrokerEpoch command across multiple RocketMQ crates. It expands the EpochEntry data structure with fields and accessors, adds a broker epoch cache retrieval method to the MQ client API, implements the command interface in admin tools with broker name/cluster name query support and optional interval polling, and provides utility functions for broker address lookup. Changes
Sequence DiagramsequenceDiagram
actor Admin as Admin CLI
participant BrokerCmd as BrokerCommands
participant GetEpochCmd as GetBrokerEpochSubCommand
participant AdminExt as DefaultMQAdminExt
participant AdminExtImpl as DefaultMQAdminExtImpl
participant ClientAPI as MQClientAPIImpl
participant Broker as RocketMQ Broker
Admin->>BrokerCmd: execute GetBrokerEpoch command
BrokerCmd->>GetEpochCmd: execute(rpc_hook)
GetEpochCmd->>AdminExt: start()
AdminExt->>AdminExtImpl: initialize client instance
alt interval specified
loop until terminated
GetEpochCmd->>GetEpochCmd: inner_exec()
GetEpochCmd->>AdminExt: get_broker_epoch_cache(broker_addr)
AdminExt->>AdminExtImpl: get_broker_epoch_cache(broker_addr)
AdminExtImpl->>ClientAPI: get_broker_epoch_cache(broker_addr, timeout)
ClientAPI->>Broker: GetBrokerEpochCache request
Broker-->>ClientAPI: EpochEntryCache response
ClientAPI-->>AdminExtImpl: decoded EpochEntryCache
AdminExtImpl-->>AdminExt: result
AdminExt-->>GetEpochCmd: EpochEntryCache
GetEpochCmd->>GetEpochCmd: print_data()
GetEpochCmd->>Admin: formatted output
GetEpochCmd->>GetEpochCmd: sleep(interval)
end
else no interval
GetEpochCmd->>GetEpochCmd: inner_exec()
GetEpochCmd->>AdminExt: get_broker_epoch_cache(broker_addr)
AdminExt->>AdminExtImpl: get_broker_epoch_cache(broker_addr)
AdminExtImpl->>ClientAPI: get_broker_epoch_cache(broker_addr, timeout)
ClientAPI->>Broker: GetBrokerEpochCache request
Broker-->>ClientAPI: EpochEntryCache response
ClientAPI-->>AdminExtImpl: decoded EpochEntryCache
AdminExtImpl-->>AdminExt: result
AdminExt-->>GetEpochCmd: EpochEntryCache
GetEpochCmd->>GetEpochCmd: print_data()
GetEpochCmd->>Admin: formatted output
end
GetEpochCmd->>AdminExt: shutdown()
AdminExt-->>Admin: command complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/broker_commands.rs (1)
1-1:⚠️ Potential issue | 🟡 MinorFix the copyright year to 2023.
Line 1 uses 2026, but the repo convention requires 2023 for Rust headers.
Based on learnings In Rust source files (*.rs) across the rocketmq-rust repository, enforce using "Copyright 2023" as the year in the header instead of the current calendar year. Audit and update existing headers to follow this convention and ensure all new files include the 2023 year.✏️ Proposed fix
-// Copyright 2026 The RocketMQ Rust Authors +// Copyright 2023 The RocketMQ Rust Authors🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/broker_commands.rs` at line 1, Update the file header year from "2026" to "2023" by replacing the top-line copyright comment in this Rust source (the file's header comment) and then scan other .rs files in the crate to ensure all Rust source headers use "Copyright 2023" so new and existing files follow the repo convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/broker_commands.rs`:
- Line 1: Update the file header year from "2026" to "2023" by replacing the
top-line copyright comment in this Rust source (the file's header comment) and
then scan other .rs files in the crate to ensure all Rust source headers use
"Copyright 2023" so new and existing files follow the repo convention.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6372 +/- ##
==========================================
- Coverage 42.45% 42.41% -0.04%
==========================================
Files 920 921 +1
Lines 129473 129663 +190
==========================================
+ Hits 54968 55001 +33
- Misses 74505 74662 +157 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes(Closes)
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
getBrokerEpochadmin command for querying broker epoch data