Skip to content

Commit

Permalink
chore: use ClusterId
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed May 8, 2024
1 parent 455874f commit 1c80360
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/common/meta/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/common/meta/src/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,7 +85,7 @@ pub trait ProcedureExecutor: Send + Sync {
pub type ProcedureExecutorRef = Arc<dyn ProcedureExecutor>;

pub struct TableMetadataAllocatorContext {
pub cluster_id: u64,
pub cluster_id: ClusterId,
}

/// Metadata allocated to a table.
Expand Down
6 changes: 3 additions & 3 deletions src/common/meta/src/ddl/alter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/common/meta/src/ddl/drop_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,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<FlowInfoValue>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/meta/src/ddl/drop_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RegionRoute>,
pub physical_table_id: Option<TableId>,
Expand Down
4 changes: 2 additions & 2 deletions src/common/meta/src/ddl/tests/create_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,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,
Expand Down Expand Up @@ -70,7 +70,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<TableName>,
sink_table_name: TableName,
Expand Down
8 changes: 4 additions & 4 deletions src/common/meta/src/ddl/truncate_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<TableInfoValue>,
region_routes: Vec<RegionRoute>,
Expand Down Expand Up @@ -189,15 +189,15 @@ impl TruncateTableProcedure {
#[derive(Debug, Serialize, Deserialize)]
pub struct TruncateTableData {
state: TruncateTableState,
cluster_id: u64,
cluster_id: ClusterId,
task: TruncateTableTask,
table_info_value: DeserializedValueWithBytes<TableInfoValue>,
region_routes: Vec<RegionRoute>,
}

impl TruncateTableData {
pub fn new(
cluster_id: u64,
cluster_id: ClusterId,
task: TruncateTableTask,
table_info_value: DeserializedValueWithBytes<TableInfoValue>,
region_routes: Vec<RegionRoute>,
Expand Down
3 changes: 2 additions & 1 deletion src/meta-srv/src/handler/node_stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions src/meta-srv/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use std::str::FromStr;

use common_meta::ClusterId;
use lazy_static::lazy_static;
use regex::Regex;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -132,7 +133,7 @@ impl TryFrom<LeaseValue> for Vec<u8> {

#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct StatKey {
pub cluster_id: u64,
pub cluster_id: ClusterId,
pub node_id: u64,
}

Expand Down Expand Up @@ -237,7 +238,7 @@ impl TryFrom<Vec<u8>> 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,
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta-srv/src/region/lease_keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<RenewRegionLeasesResponse> {
Expand Down

0 comments on commit 1c80360

Please sign in to comment.