diff --git a/src/common/meta/src/cluster.rs b/src/common/meta/src/cluster.rs index d2ebe8c979f3..75da644fff4f 100644 --- a/src/common/meta/src/cluster.rs +++ b/src/common/meta/src/cluster.rs @@ -56,7 +56,7 @@ pub trait ClusterInfo { #[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct NodeInfoKey { /// The cluster id. - pub cluster_id: u64, + pub cluster_id: ClusterId, /// The role of the node. It can be `[Role::Datanode]` or `[Role::Frontend]`. pub role: Role, /// The node id. diff --git a/src/common/meta/src/ddl.rs b/src/common/meta/src/ddl.rs index 2e67258c77bb..a922ce02d914 100644 --- a/src/common/meta/src/ddl.rs +++ b/src/common/meta/src/ddl.rs @@ -29,6 +29,7 @@ use crate::node_manager::NodeManagerRef; use crate::region_keeper::MemoryRegionKeeperRef; use crate::rpc::ddl::{SubmitDdlTaskRequest, SubmitDdlTaskResponse}; use crate::rpc::procedure::{MigrateRegionRequest, MigrateRegionResponse, ProcedureStateResponse}; +use crate::ClusterId; pub mod alter_logical_tables; pub mod alter_table; @@ -84,7 +85,7 @@ pub trait ProcedureExecutor: Send + Sync { pub type ProcedureExecutorRef = Arc; pub struct TableMetadataAllocatorContext { - pub cluster_id: u64, + pub cluster_id: ClusterId, } /// Metadata allocated to a table. diff --git a/src/common/meta/src/ddl/alter_table.rs b/src/common/meta/src/ddl/alter_table.rs index 31a4fd4af1eb..209ed3812203 100644 --- a/src/common/meta/src/ddl/alter_table.rs +++ b/src/common/meta/src/ddl/alter_table.rs @@ -45,9 +45,9 @@ use crate::instruction::CacheIdent; use crate::key::table_info::TableInfoValue; use crate::key::DeserializedValueWithBytes; use crate::lock_key::{CatalogLock, SchemaLock, TableLock, TableNameLock}; -use crate::metrics; use crate::rpc::ddl::AlterTableTask; use crate::rpc::router::{find_leader_regions, find_leaders}; +use crate::{metrics, ClusterId}; /// The alter table procedure pub struct AlterTableProcedure { @@ -61,7 +61,7 @@ impl AlterTableProcedure { pub const TYPE_NAME: &'static str = "metasrv-procedure::AlterTable"; pub fn new( - cluster_id: u64, + cluster_id: ClusterId, table_id: TableId, task: AlterTableTask, context: DdlContext, @@ -269,7 +269,7 @@ enum AlterTableState { // The serialized data of alter table. #[derive(Debug, Serialize, Deserialize)] pub struct AlterTableData { - cluster_id: u64, + cluster_id: ClusterId, state: AlterTableState, task: AlterTableTask, table_id: TableId, diff --git a/src/common/meta/src/ddl/drop_flow.rs b/src/common/meta/src/ddl/drop_flow.rs index b99084231b3d..1a32781a9ff5 100644 --- a/src/common/meta/src/ddl/drop_flow.rs +++ b/src/common/meta/src/ddl/drop_flow.rs @@ -193,7 +193,7 @@ impl Procedure for DropFlowProcedure { #[derive(Debug, Serialize, Deserialize)] pub(crate) struct DropFlowData { state: DropFlowState, - cluster_id: u64, + cluster_id: ClusterId, task: DropFlowTask, pub(crate) flow_info_value: Option, } diff --git a/src/common/meta/src/ddl/drop_table.rs b/src/common/meta/src/ddl/drop_table.rs index fd2217bd636b..f3840a7d6774 100644 --- a/src/common/meta/src/ddl/drop_table.rs +++ b/src/common/meta/src/ddl/drop_table.rs @@ -252,7 +252,7 @@ impl Procedure for DropTableProcedure { #[derive(Debug, Serialize, Deserialize)] pub struct DropTableData { pub state: DropTableState, - pub cluster_id: u64, + pub cluster_id: ClusterId, pub task: DropTableTask, pub physical_region_routes: Vec, pub physical_table_id: Option, diff --git a/src/common/meta/src/ddl/tests/create_flow.rs b/src/common/meta/src/ddl/tests/create_flow.rs index 1bcc82728e21..415fc12f62a5 100644 --- a/src/common/meta/src/ddl/tests/create_flow.rs +++ b/src/common/meta/src/ddl/tests/create_flow.rs @@ -24,12 +24,12 @@ use crate::ddl::create_flow::CreateFlowProcedure; use crate::ddl::test_util::create_table::test_create_table_task; use crate::ddl::test_util::flownode_handler::NaiveFlownodeHandler; use crate::ddl::DdlContext; -use crate::error; use crate::key::table_route::TableRouteValue; use crate::key::FlowId; use crate::rpc::ddl::CreateFlowTask; use crate::table_name::TableName; use crate::test_util::{new_ddl_context, MockFlownodeManager}; +use crate::{error, ClusterId}; pub(crate) fn test_create_flow_task( name: &str, @@ -72,7 +72,7 @@ async fn test_create_flow_source_table_not_found() { pub(crate) async fn create_test_flow( ddl_context: &DdlContext, - cluster_id: u64, + cluster_id: ClusterId, flow_name: &str, source_table_names: Vec, sink_table_name: TableName, diff --git a/src/common/meta/src/ddl/truncate_table.rs b/src/common/meta/src/ddl/truncate_table.rs index de0316de5179..ce1341c0add2 100644 --- a/src/common/meta/src/ddl/truncate_table.rs +++ b/src/common/meta/src/ddl/truncate_table.rs @@ -38,10 +38,10 @@ use crate::key::table_info::TableInfoValue; use crate::key::table_name::TableNameKey; use crate::key::DeserializedValueWithBytes; use crate::lock_key::{CatalogLock, SchemaLock, TableLock}; -use crate::metrics; use crate::rpc::ddl::TruncateTableTask; use crate::rpc::router::{find_leader_regions, find_leaders, RegionRoute}; use crate::table_name::TableName; +use crate::{metrics, ClusterId}; pub struct TruncateTableProcedure { context: DdlContext, @@ -91,7 +91,7 @@ impl TruncateTableProcedure { pub(crate) const TYPE_NAME: &'static str = "metasrv-procedure::TruncateTable"; pub(crate) fn new( - cluster_id: u64, + cluster_id: ClusterId, task: TruncateTableTask, table_info_value: DeserializedValueWithBytes, region_routes: Vec, @@ -189,7 +189,7 @@ impl TruncateTableProcedure { #[derive(Debug, Serialize, Deserialize)] pub struct TruncateTableData { state: TruncateTableState, - cluster_id: u64, + cluster_id: ClusterId, task: TruncateTableTask, table_info_value: DeserializedValueWithBytes, region_routes: Vec, @@ -197,7 +197,7 @@ pub struct TruncateTableData { impl TruncateTableData { pub fn new( - cluster_id: u64, + cluster_id: ClusterId, task: TruncateTableTask, table_info_value: DeserializedValueWithBytes, region_routes: Vec, diff --git a/src/meta-srv/src/handler/node_stat.rs b/src/meta-srv/src/handler/node_stat.rs index 3d9fe02e78cc..09a2f98213f7 100644 --- a/src/meta-srv/src/handler/node_stat.rs +++ b/src/meta-srv/src/handler/node_stat.rs @@ -15,6 +15,7 @@ use std::collections::HashSet; use api::v1::meta::HeartbeatRequest; +use common_meta::ClusterId; use common_time::util as time_util; use serde::{Deserialize, Serialize}; use store_api::region_engine::RegionRole; @@ -26,7 +27,7 @@ use crate::keys::StatKey; #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Stat { pub timestamp_millis: i64, - pub cluster_id: u64, + pub cluster_id: ClusterId, // The datanode Id. pub id: u64, // The datanode address. diff --git a/src/meta-srv/src/keys.rs b/src/meta-srv/src/keys.rs index 2e4321937265..250f736c45f5 100644 --- a/src/meta-srv/src/keys.rs +++ b/src/meta-srv/src/keys.rs @@ -14,6 +14,7 @@ use std::str::FromStr; +use common_meta::ClusterId; use lazy_static::lazy_static; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -41,7 +42,7 @@ lazy_static! { #[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct LeaseKey { - pub cluster_id: u64, + pub cluster_id: ClusterId, pub node_id: u64, } @@ -132,7 +133,7 @@ impl TryFrom for Vec { #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] pub struct StatKey { - pub cluster_id: u64, + pub cluster_id: ClusterId, pub node_id: u64, } @@ -237,7 +238,7 @@ impl TryFrom> for StatValue { #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize)] pub struct InactiveRegionKey { - pub cluster_id: u64, + pub cluster_id: ClusterId, pub node_id: u64, pub region_id: u64, } diff --git a/src/meta-srv/src/region/lease_keeper.rs b/src/meta-srv/src/region/lease_keeper.rs index a1c42fe49651..a1065d4cbbc2 100644 --- a/src/meta-srv/src/region/lease_keeper.rs +++ b/src/meta-srv/src/region/lease_keeper.rs @@ -19,7 +19,7 @@ use common_meta::key::table_route::TableRouteValue; use common_meta::key::TableMetadataManagerRef; use common_meta::region_keeper::MemoryRegionKeeperRef; use common_meta::rpc::router::RegionRoute; -use common_meta::DatanodeId; +use common_meta::{ClusterId, DatanodeId}; use common_telemetry::warn; use snafu::ResultExt; use store_api::region_engine::RegionRole; @@ -167,7 +167,7 @@ impl RegionLeaseKeeper { /// and corresponding regions will be added to `non_exists` of [RenewRegionLeasesResponse]. pub async fn renew_region_leases( &self, - _cluster_id: u64, + _cluster_id: ClusterId, datanode_id: DatanodeId, regions: &[(RegionId, RegionRole)], ) -> Result {