mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-19 14:30:43 +00:00
refactor: migrate region failover implementation to region migration (#4172)
* refactor: migrate region failover implementation to region migration * fix: use HEARTBEAT_INTERVAL_MILLIS as lease secs * fix: return false if leader is downgraded * fix: only remove failure detector after submitting procedure successfully * feat: ignore dropped region * refactor: retrieve table routes in batches * refactor: disable region failover on local WAL implementation * fix: move the guard into procedure * feat: use real peer addr * feat: use interval instead of sleep * chore: rename `HeartbeatSender` to `HeartbeatAcceptor` * chore: apply suggestions from CR * chore: reduce duplicate code * chore: apply suggestions from CR * feat: lookup peer addr * chore: add comments * chore: apply suggestions from CR * chore: apply suggestions from CR
This commit is contained in:
@@ -135,7 +135,7 @@ use crate::rpc::store::BatchDeleteRequest;
|
||||
use crate::DatanodeId;
|
||||
|
||||
pub const NAME_PATTERN: &str = r"[a-zA-Z_:-][a-zA-Z0-9_:\-\.]*";
|
||||
pub const MAINTENANCE_KEY: &str = "maintenance";
|
||||
pub const MAINTENANCE_KEY: &str = "__maintenance";
|
||||
|
||||
const DATANODE_TABLE_KEY_PREFIX: &str = "__dn_table";
|
||||
pub const TABLE_INFO_KEY_PREFIX: &str = "__table_info";
|
||||
|
||||
@@ -33,10 +33,11 @@ use crate::kv_backend::KvBackendRef;
|
||||
use crate::node_manager::{
|
||||
Datanode, DatanodeRef, Flownode, FlownodeRef, NodeManager, NodeManagerRef,
|
||||
};
|
||||
use crate::peer::{Peer, StandalonePeerLookupService};
|
||||
use crate::peer::{Peer, PeerLookupService, StandalonePeerLookupService};
|
||||
use crate::region_keeper::MemoryRegionKeeper;
|
||||
use crate::sequence::SequenceBuilder;
|
||||
use crate::wal_options_allocator::WalOptionsAllocator;
|
||||
use crate::{ClusterId, DatanodeId, FlownodeId};
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait MockDatanodeHandler: Sync + Send + Clone {
|
||||
@@ -183,3 +184,16 @@ pub fn new_ddl_context_with_kv_backend(
|
||||
peer_lookup_service: Arc::new(StandalonePeerLookupService::new()),
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NoopPeerLookupService;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl PeerLookupService for NoopPeerLookupService {
|
||||
async fn datanode(&self, _cluster_id: ClusterId, id: DatanodeId) -> Result<Option<Peer>> {
|
||||
Ok(Some(Peer::empty(id)))
|
||||
}
|
||||
|
||||
async fn flownode(&self, _cluster_id: ClusterId, id: FlownodeId) -> Result<Option<Peer>> {
|
||||
Ok(Some(Peer::empty(id)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,11 @@ impl WalOptionsAllocator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if it's the remote WAL.
|
||||
pub fn is_remote_wal(&self) -> bool {
|
||||
matches!(&self, WalOptionsAllocator::Kafka(_))
|
||||
}
|
||||
}
|
||||
|
||||
/// Allocates a wal options for each region. The allocated wal options is encoded immediately.
|
||||
|
||||
Reference in New Issue
Block a user