[store] refactor: clean up todo
@@ -640,13 +640,10 @@ impl MetaNode {
/// Start a MetaStore node from initialized store.
#[tracing::instrument(level = "info")]
- pub async fn new(
- node_id: NodeId,
- config: &configs::Config,
- ) -> common_exception::Result<Arc<MetaNode>> {
- let sto = MetaStore::new(node_id, config).await?;
+ pub async fn open(config: &configs::Config) -> common_exception::Result<Arc<MetaNode>> {
+ let sto = MetaStore::open(config).await?;
let sto = Arc::new(sto);
- let b = MetaNode::builder().node_id(node_id).sto(sto);
+ let b = MetaNode::builder().node_id(sto.id).sto(sto);
b.build().await
}
@@ -742,6 +739,10 @@ impl MetaNode {
node_id: NodeId,
config: &configs::Config,
) -> common_exception::Result<Arc<MetaNode>> {
+ // 1. Bring a node up as non voter, start the grpc service for raft communication.
+ // 2. Initialize itself as leader, because it is the only one in the new cluster.
+ // 3. Add itself to the cluster storage by committing an `add-node` log so that the cluster members(only this node) is persisted.
+
let mn = MetaNode::boot_non_voter(node_id, config).await?;
let mut cluster_node_ids = HashSet::new();
@@ -763,7 +764,7 @@ impl MetaNode {
/// Boot a node that is going to join an existent cluster.
/// For every node this should be called exactly once.
- /// When successfully initialized(e.g. received logs from raft leader), a node should be started with MetaNode::new().
+ /// When successfully initialized(e.g. received logs from raft leader), a node should be started with MetaNode::open().
#[tracing::instrument(level = "info")]
pub async fn boot_non_voter(
node_id: NodeId,
@@ -771,7 +772,7 @@ impl MetaNode {
) -> common_exception::Result<Arc<MetaNode>> {
// TODO test MetaNode::new() on a booted store.
// TODO: Before calling this func, the node should be added as a non-voter to leader.
- // TODO: check raft initialState to see if the store is clean.
+ // TODO(xp): what if fill in the node info into an empty state-machine, then MetaNode can be started without delaying grpc.
// When booting, there is addr stored in local store.
// Thus we need to start grpc manually.
