Skip to content

[ISSUE #6269]🚀Implement GetBrokerEpoch command in rocketmq-admin-core#6372

Merged
mxsm merged 1 commit intomxsm:mainfrom
WaterWhisperer:feat-6269
Feb 18, 2026
Merged

[ISSUE #6269]🚀Implement GetBrokerEpoch command in rocketmq-admin-core#6372
mxsm merged 1 commit intomxsm:mainfrom
WaterWhisperer:feat-6269

Conversation

@WaterWhisperer
Copy link
Contributor

@WaterWhisperer WaterWhisperer commented Feb 18, 2026

Which Issue(s) This PR Fixes(Closes)

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features
    • Added broker epoch cache retrieval API to access epoch entry information
    • New getBrokerEpoch admin command for querying broker epoch data
    • Support for querying by broker name or cluster name
    • Interval-based polling capability to monitor epoch changes

@rocketmq-rust-bot
Copy link
Collaborator

🔊@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💥.

@rocketmq-rust-bot rocketmq-rust-bot added the AI review first Ai review pr first label Feb 18, 2026
@rocketmq-rust-robot rocketmq-rust-robot added the Difficulty level/Moderate Moderate difficult ISSUE label Feb 18, 2026
@rocketmq-rust-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Feb 18, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Walkthrough

This 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

Cohort / File(s) Summary
EpochEntry Data Structure
rocketmq-remoting/src/protocol/body/epoch_entry_cache.rs
Expanded EpochEntry from empty struct to full structure with epoch, start_offset, end_offset fields; added constructors (new, with_end_offset), accessors/mutators, Display impl, and derived traits (Debug, Clone, PartialEq, Eq). Extended EpochEntryCache with getters/setters for epoch list and max offset. Updated tests accordingly.
Client API Implementation
rocketmq-client/src/implementation/mq_client_api_impl.rs
Added public async method get_broker_epoch_cache that creates GetBrokerEpochCache remoting command, invokes it on broker, and decodes response body as EpochEntryCache; imported EpochEntryCache type.
Admin Interface Implementation
rocketmq-client/src/admin/default_mq_admin_ext_impl.rs, rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/admin/default_mq_admin_ext.rs
Replaced unimplemented placeholders with concrete logic; lower layer routes through client instance with timeout, wrapper delegates to inner implementation. Parameter renamed from _broker_addr to broker_addr.
Command Registration
rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands.rs
Added getBrokerEpoch command entry in Broker category with remark "Fetch broker epoch entries."
Command Execution
rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/broker_commands.rs, rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/broker_commands/get_broker_epoch_sub_command.rs
Introduced GetBrokerEpochSubCommand module and enum variant; implements CommandExecute trait with support for querying by broker name or cluster name, optional interval-based polling, data retrieval via MQAdminExt, and formatted epoch metadata output.
Command Utilities
rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/command_util.rs
Added fetch_master_and_slave_addr_by_broker_name utility function to retrieve and deduplicate all broker addresses for a given broker name from cluster info.

Sequence Diagram

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

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

feature🚀, AI review first, Difficulty level/Moderate

Suggested reviewers

  • mxsm
  • TeslaRustor
  • SpaceXCN

Poem

🐰 Hop, hop! The broker's epoch now speaks,
With intervals and addresses so sleek,
From cluster queries to master slaves found,
Admin tools dance with queries profound,
The GetBrokerEpoch command, our feat!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly references the issue (#6269) and describes the main implementation: adding GetBrokerEpoch command to rocketmq-admin-core.
Linked Issues check ✅ Passed The PR implements all key features from #6269: GetBrokerEpoch command retrieval, epoch history display, support for broker name/cluster queries, and epoch metadata display.
Out of Scope Changes check ✅ Passed All changes directly support GetBrokerEpoch implementation: EpochEntry API expansion, MQClientAPI and MQAdminExt integration, command registration, and utility functions are all in-scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix the copyright year to 2023.

Line 1 uses 2026, but the repo convention requires 2023 for Rust headers.

✏️ Proposed fix
-// Copyright 2026 The RocketMQ Rust Authors
+// Copyright 2023 The RocketMQ Rust Authors
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.
🤖 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
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 18.97436% with 158 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.41%. Comparing base (ea1f3f1) to head (0786367).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ds/broker_commands/get_broker_epoch_sub_command.rs 0.00% 76 Missing ⚠️
...mq-remoting/src/protocol/body/epoch_entry_cache.rs 57.81% 27 Missing ⚠️
...mq-client/src/implementation/mq_client_api_impl.rs 0.00% 22 Missing ⚠️
...n/rocketmq-admin-core/src/commands/command_util.rs 0.00% 18 Missing ⚠️
...etmq-client/src/admin/default_mq_admin_ext_impl.rs 0.00% 7 Missing ⚠️
...rocketmq-admin/rocketmq-admin-core/src/commands.rs 0.00% 5 Missing ⚠️
...ketmq-admin-core/src/admin/default_mq_admin_ext.rs 0.00% 2 Missing ⚠️
...ocketmq-admin-core/src/commands/broker_commands.rs 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mxsm mxsm merged commit 59228ae into mxsm:main Feb 18, 2026
9 of 21 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Feb 18, 2026
@WaterWhisperer WaterWhisperer deleted the feat-6269 branch February 18, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI review first Ai review pr first approved PR has approved auto merge Difficulty level/Moderate Moderate difficult ISSUE feature🚀 Suggest an idea for this project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature🚀] Implement GetBrokerEpoch command in rocketmq-admin-core

4 participants

Comments