Skip to content

Commit

Permalink
Add get_engine_path interface for RaftEngine trait
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayang-zheng committed Oct 19, 2022
1 parent 6700afe commit 8311460
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/tikv-ctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pd_client = { workspace = true }
prometheus = { version = "0.13", features = ["nightly"] }
protobuf = { version = "2.8", features = ["bytes"] }
raft = { version = "0.7.0", default-features = false, features = ["protobuf-codec"] }
raft-engine-ctl = { git = "https://github.com/tikv/raft-engine.git" }
raft-engine-ctl = { git = "https://github.com/jiayang-zheng/raft-engine.git", rev = "9200bdae002a2fa09a56e0753eae211477f03f48" }
raft_log_engine = { workspace = true }
raftstore = { workspace = true }
rand = "0.8"
Expand Down
4 changes: 4 additions & 0 deletions components/engine_panic/src/raft_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ impl RaftEngine for PanicEngine {
panic!()
}

fn get_engine_path(&self) -> &str {
panic!()
}

fn put_store_ident(&self, ident: &StoreIdent) -> Result<()> {
panic!()
}
Expand Down
4 changes: 4 additions & 0 deletions components/engine_rocks/src/raft_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ impl RaftEngine for RocksEngine {
Ok(used_size)
}

fn get_engine_path(&self) -> &str {
self.as_inner().path()
}

fn put_store_ident(&self, ident: &StoreIdent) -> Result<()> {
self.put_msg(keys::STORE_IDENT_KEY, ident)
}
Expand Down
3 changes: 3 additions & 0 deletions components/engine_traits/src/raft_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ pub trait RaftEngine: RaftEngineReadOnly + PerfContextExt + Clone + Sync + Send

fn get_engine_size(&self) -> Result<u64>;

/// The path to the directory on the filesystem where the raft log is stored
fn get_engine_path(&self) -> &str;

/// Visit all available raft groups.
///
/// If any error is returned, the iteration will stop.
Expand Down
2 changes: 1 addition & 1 deletion components/raft_log_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ num_cpus = "1"
online_config = { workspace = true }
protobuf = "2"
raft = { version = "0.7.0", default-features = false, features = ["protobuf-codec"] }
raft-engine = { git = "https://github.com/tikv/raft-engine.git", features = ["swap"] }
raft-engine = { git = "https://github.com/jiayang-zheng/raft-engine.git", rev = "9200bdae002a2fa09a56e0753eae211477f03f48", features = ["swap"] }
serde = "1.0"
serde_derive = "1.0"
slog = { version = "2.3", features = ["max_level_trace", "release_max_level_debug"] }
Expand Down
8 changes: 8 additions & 0 deletions components/raft_log_engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ impl RaftLogEngine {
)))
}

pub fn path(&self) -> &str {
self.0.path()
}

/// If path is not an empty directory, we say db exists.
pub fn exists(path: &str) -> bool {
let path = Path::new(path);
Expand Down Expand Up @@ -615,6 +619,10 @@ impl RaftEngine for RaftLogEngine {
Ok(self.0.get_used_size() as u64)
}

fn get_engine_path(&self) -> &str {
self.path()
}

fn for_each_raft_group<E, F>(&self, f: &mut F) -> std::result::Result<(), E>
where
F: FnMut(u64) -> std::result::Result<(), E>,
Expand Down

0 comments on commit 8311460

Please sign in to comment.