RocketMQ Controller
RocketMQ Controller Module - High Availability Controller based on Raft
Introduction
RocketMQ Controller is the core management component of RocketMQ cluster, responsible for:
- Cluster Metadata Management: Broker registration, Topic configuration, cluster configuration, etc.
- High Availability: Master-slave failover based on Raft consensus algorithm
- Leader Election: Automatic leader node election and failover
- Data Consistency: Ensures strong data consistency through Raft log replication
Architecture
┌──────────────────────────────────────────┐
│ Controller Manager │
├──────────────────────────────────────────┤
│ │
│ ┌────────────┐ ┌────────────────────┐ │
│ │ Raft │ │ Metadata Store │ │
│ │ Controller │ │ │ │
│ │ │ │ - Broker Manager │ │
│ │ - Election │ │ - Topic Manager │ │
│ │ - Replica │ │ - Config Manager │ │
│ └────────────┘ └────────────────────┘ │
│ │
│ ┌────────────────────────────────────┐ │
│ │ Processor Manager │ │
│ │ │ │
│ │ - Register Broker │ │
│ │ - Heartbeat │ │
│ │ - Create/Update Topic │ │
│ │ - Query Metadata │ │
│ └────────────────────────────────────┘ │
└──────────────────────────────────────────┘
Features
✅ Implemented
- Basic project structure
- Configuration management (ControllerConfig)
- Error handling (ControllerError)
- Raft controller framework
- Metadata storage (Broker, Topic, Config)
- Processor manager framework
🚧 In Progress
- Complete Raft node implementation
- Network communication layer
- RPC processor implementation
📋 Planned
- Persistent storage (RocksDB/custom logging)
- Snapshot management
- Complete integration tests
- Performance benchmarks
- Monitoring metrics
Quick Start
Basic Usage
use *;
async
Dependencies
Main dependencies:
raft-rs- Raft consensus algorithm implementationtokio- Async runtimedashmap- Concurrent hash mapserde- Serialization/deserializationtracing- Logging and tracing
Development
Build
测试
Benchmark
Comparison with Java Version
| Feature | Java (DLedger) | Rust (raft-rs) |
|---|---|---|
| Consensus Algorithm | DLedger | raft-rs |
| Async Model | Netty | Tokio |
| Concurrency Control | ConcurrentHashMap | DashMap |
| Error Handling | Exceptions | Result<T, E> |
| Type Safety | Runtime | Compile-time |
Performance Goals
- Leader election latency: < 500ms
- Heartbeat throughput: > 10,000 ops/s
- Metadata write latency: < 10ms (p99)
- Metadata read latency: < 1ms (p99)
Contributing
Contributions are welcome! Please see CONTRIBUTING.md.
License
Licensed under Apache License 2.0 or MIT license, at your option.