Skip to content

Commit

Permalink
add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Jul 10, 2023
1 parent a5db619 commit 90a9886
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion cluster/src/shard_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use snafu::ResultExt;
use table_engine::{
engine::{TableEngineRef, TableState},
table::TableId,
ANALYTIC_ENGINE_TYPE,
};

use crate::{
Expand Down
15 changes: 7 additions & 8 deletions cluster/src/shard_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use crate::{
Result, ShardVersionMismatch, TableAlreadyExists, TableNotFound, UpdateFrozenShard,
};

/// [ShardTablesCache] caches the information about tables and shards, and the
/// relationship between them is: one shard -> multiple tables.
/// Shard set
///
/// Manage all shards opened on current node
#[derive(Debug, Default, Clone)]
pub struct ShardSet {
inner: Arc<std::sync::RwLock<HashMap<ShardId, ShardRef>>>,
Expand Down Expand Up @@ -46,6 +47,9 @@ impl ShardSet {
}
}

/// Shard
///
/// NOTICE: all write operations on a shard will be performed sequentially.
pub struct Shard {
pub data: ShardDataRef,
pub operator: tokio::sync::Mutex<ShardOperator>,
Expand Down Expand Up @@ -113,19 +117,14 @@ impl Shard {

pub type ShardRef = Arc<Shard>;

#[derive(Debug, Clone)]
pub struct TableWithShards {
pub table_info: TableInfo,
pub shard_infos: Vec<ShardInfo>,
}

#[derive(Debug, Clone)]
pub struct UpdatedTableInfo {
pub prev_version: u64,
pub shard_info: ShardInfo,
pub table_info: TableInfo,
}

/// Shard data
#[derive(Debug)]
pub struct ShardData {
/// Shard info
Expand Down
12 changes: 6 additions & 6 deletions server/src/grpc/meta_event_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async fn do_open_shard(ctx: HandlerContext, shard_info: ShardInfo) -> Result<()>

shard.open(open_ctx).await.box_err().context(ErrWithCause {
code: StatusCode::Internal,
msg: "fail to open shard in cluster",
msg: "fail to open shard",
})
}

Expand Down Expand Up @@ -346,7 +346,7 @@ async fn do_close_shard(ctx: &HandlerContext, shard_id: ShardId) -> Result<()> {
.box_err()
.context(ErrWithCause {
code: StatusCode::Internal,
msg: "fail to close shard in cluster",
msg: "fail to close shard",
})?;

// Remove the shard from the cluster topology after the shard is closed indeed.
Expand Down Expand Up @@ -434,7 +434,7 @@ async fn handle_create_table_on_shard(
.box_err()
.context(ErrWithCause {
code: StatusCode::Internal,
msg: "fail to create table on shard in cluster",
msg: "fail to create table on shard",
})
}

Expand Down Expand Up @@ -470,7 +470,7 @@ async fn handle_drop_table_on_shard(
.box_err()
.context(ErrWithCause {
code: StatusCode::Internal,
msg: "fail to drop table on shard in cluster",
msg: "fail to drop table on shard",
})
}

Expand Down Expand Up @@ -503,7 +503,7 @@ async fn handle_open_table_on_shard(
.box_err()
.context(ErrWithCause {
code: StatusCode::Internal,
msg: "fail to open table on shard in cluster",
msg: "fail to open table on shard",
})
}

Expand Down Expand Up @@ -537,7 +537,7 @@ async fn handle_close_table_on_shard(
.box_err()
.context(ErrWithCause {
code: StatusCode::Internal,
msg: "fail to close table on shard in cluster",
msg: "fail to close table on shard",
})
}

Expand Down

0 comments on commit 90a9886

Please sign in to comment.