diff --git a/src/binaries/metactl/grpc.rs b/src/binaries/metactl/grpc.rs index 62ad54749f7e3..4b5406b564479 100644 --- a/src/binaries/metactl/grpc.rs +++ b/src/binaries/metactl/grpc.rs @@ -38,8 +38,10 @@ pub async fn export_meta(addr: &str, save: String) -> anyhow::Result<()> { let mut stream = exported.into_inner(); let file: Option = if !save.is_empty() { + eprintln!(" To: File: {}", save); Some(File::create(&save)?) } else { + eprintln!(" To: "); None }; diff --git a/src/binaries/metactl/main.rs b/src/binaries/metactl/main.rs index c2be3dfd90a11..4c80c83498196 100644 --- a/src/binaries/metactl/main.rs +++ b/src/binaries/metactl/main.rs @@ -208,15 +208,31 @@ async fn main() -> anyhow::Result<()> { let _guards = init_logging("metactl", &log_config); eprintln!(); - eprintln!("███╗ ███╗███████╗████████╗ █████╗ ██████╗████████╗██╗ "); - eprintln!("████╗ ████║██╔════╝╚══██╔══╝██╔══██╗ ██╔════╝╚══██╔══╝██║ "); - eprintln!("██╔████╔██║█████╗ ██║ ███████║█████╗██║ ██║ ██║ "); - eprintln!("██║╚██╔╝██║██╔══╝ ██║ ██╔══██║╚════╝██║ ██║ ██║ "); - eprintln!("██║ ╚═╝ ██║███████╗ ██║ ██║ ██║ ╚██████╗ ██║ ███████╗"); - eprintln!("╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝"); + eprintln!("╔╦╗╔═╗╔╦╗╔═╗ ╔═╗╔╦╗╦ "); + eprintln!("║║║║╣ ║ ╠═╣───║ ║ ║ "); + eprintln!("╩ ╩╚═╝ ╩ ╩ ╩ ╚═╝ ╩ ╩═╝ Databend"); eprintln!(); - eprintln!("config: {}", pretty(&config)?); + // eprintln!("███╗ ███╗███████╗████████╗ █████╗ ██████╗████████╗██╗ "); + // eprintln!("████╗ ████║██╔════╝╚══██╔══╝██╔══██╗ ██╔════╝╚══██╔══╝██║ "); + // eprintln!("██╔████╔██║█████╗ ██║ ███████║█████╗██║ ██║ ██║ "); + // eprintln!("██║╚██╔╝██║██╔══╝ ██║ ██╔══██║╚════╝██║ ██║ ██║ "); + // eprintln!("██║ ╚═╝ ██║███████╗ ██║ ██║ ██║ ╚██████╗ ██║ ███████╗"); + // eprintln!("╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝"); + + // ██████╗ █████╗ ████████╗ █████╗ ██████╗ ███████╗███╗ ██╗██████╗ + // ██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗██╔══██╗██╔════╝████╗ ██║██╔══██╗ + // ██║ ██║███████║ ██║ ███████║██████╔╝█████╗ ██╔██╗ ██║██║ ██║ + // ██║ ██║██╔══██║ ██║ ██╔══██║██╔══██╗██╔══╝ ██║╚██╗██║██║ ██║ + // ██████╔╝██║ ██║ ██║ ██║ ██║██████╔╝███████╗██║ ╚████║██████╔╝ + // ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝╚═╝ ╚═══╝╚═════╝ + // ╔╦╗╔═╗╔╦╗╔═╗ ╔═╗╔╦╗╦ + // ║║║║╣ ║ ╠═╣───║ ║ ║ + // ╩ ╩╚═╝ ╩ ╩ ╩ ╚═╝ ╩ ╩═╝ + + eprintln!("Version: {}", METASRV_COMMIT_VERSION.as_str()); + eprintln!(""); + eprintln!("Config: {}", pretty(&config)?); if !config.cmd.is_empty() { return match config.cmd.as_str() { @@ -237,10 +253,14 @@ async fn main() -> anyhow::Result<()> { } if config.export { + eprintln!(""); + eprintln!("Export:"); return snapshot::export_data(&config).await; } if config.import { + eprintln!(""); + eprintln!("Import:"); return snapshot::import_data(&config).await; } diff --git a/src/binaries/metactl/snapshot.rs b/src/binaries/metactl/snapshot.rs index 3cb485ddd2b44..5c4a50f379100 100644 --- a/src/binaries/metactl/snapshot.rs +++ b/src/binaries/metactl/snapshot.rs @@ -73,7 +73,7 @@ pub async fn export_data(config: &Config) -> anyhow::Result<()> { pub async fn import_data(config: &Config) -> anyhow::Result<()> { let raft_config = &config.raft_config; - eprintln!("import meta dir into: {}", raft_config.raft_dir); + eprintln!(" Into Meta Dir: '{}'", raft_config.raft_dir); let nodes = build_nodes(config.initial_cluster.clone(), raft_config.id)?; @@ -200,7 +200,7 @@ fn import_from(restore: String) -> anyhow::Result> { /// Raw config is: `=:[,...]`, e.g. `1=localhost:29103` or `1=localhost:29103,0.0.0.0:19191` /// The second part is obsolete grpc api address and will be just ignored. Databend-meta loads Grpc address from config file when starting up. fn build_nodes(initial_cluster: Vec, id: u64) -> anyhow::Result> { - eprintln!("init-cluster: id={}, {:?}", id, initial_cluster); + eprintln!("Initialize Cluster: id={}, {:?}", id, initial_cluster); let mut nodes = BTreeMap::new(); for peer in initial_cluster { @@ -257,7 +257,7 @@ async fn init_new_cluster( max_log_id: Option, id: u64, ) -> anyhow::Result<()> { - eprintln!("init-cluster: {:?}", nodes); + eprintln!("Initialize Cluster with: {:?}", nodes); let node_ids = nodes.keys().copied().collect::>(); @@ -351,14 +351,13 @@ fn clear() -> anyhow::Result<()> { fn export_from_dir(config: &Config) -> anyhow::Result<()> { let db = get_sled_db(); + eprintln!(" From: {}", config.raft_config.raft_dir); + let file: Option = if !config.db.is_empty() { - eprintln!( - "export meta dir from: {} to {}", - config.raft_config.raft_dir, config.db - ); + eprintln!(" To: File: {}", config.db); Some((File::create(&config.db))?) } else { - eprintln!("export meta dir from: {}", config.raft_config.raft_dir); + eprintln!(" To: "); None }; @@ -385,6 +384,8 @@ fn export_from_dir(config: &Config) -> anyhow::Result<()> { tree_names.extend(present_tree_names.into_iter().collect::>()); for tree_name in tree_names.iter() { + eprintln!("Exporting: sled tree: '{}'...", tree_name); + let tree = db.open_tree(tree_name)?; for ivec_pair_res in tree.iter() { let kv = ivec_pair_res?; @@ -411,14 +412,14 @@ fn export_from_dir(config: &Config) -> anyhow::Result<()> { file.as_ref().unwrap().sync_all()? } - eprintln!("export {} records", cnt); + eprintln!("Exported {} records", cnt); Ok(()) } /// Dump metasrv data, raft-log, state machine etc in json to stdout. async fn export_from_running_node(config: &Config) -> Result<(), anyhow::Error> { - eprintln!("export meta dir from remote: {}", config.grpc_api_address); + eprintln!(" From: online meta-service: {}", config.grpc_api_address); let grpc_api_addr = get_available_socket_addr(&config.grpc_api_address).await?;