|
14 | 14 |
|
15 | 15 | #![allow(clippy::uninlined_format_args)] |
16 | 16 |
|
17 | | -mod export_from_grpc; |
18 | | - |
19 | | -pub mod admin; |
20 | | -pub mod export_from_disk; |
21 | | -pub mod import; |
22 | | -pub mod import_v004; |
23 | | -pub(crate) mod reading; |
24 | | -pub mod upgrade; |
25 | | - |
26 | 17 | use std::collections::BTreeMap; |
27 | 18 |
|
28 | | -use admin::MetaAdminClient; |
29 | | -use clap::Args; |
30 | 19 | use clap::CommandFactory; |
31 | 20 | use clap::Parser; |
32 | 21 | use clap::Subcommand; |
33 | 22 | use databend_common_base::base::tokio; |
34 | 23 | use databend_common_meta_client::MetaGrpcClient; |
| 24 | +use databend_common_meta_control::admin::MetaAdminClient; |
| 25 | +use databend_common_meta_control::args::BenchArgs; |
| 26 | +use databend_common_meta_control::args::ExportArgs; |
| 27 | +use databend_common_meta_control::args::GlobalArgs; |
| 28 | +use databend_common_meta_control::args::ImportArgs; |
| 29 | +use databend_common_meta_control::args::StatusArgs; |
| 30 | +use databend_common_meta_control::args::TransferLeaderArgs; |
| 31 | +use databend_common_meta_control::export_from_disk; |
| 32 | +use databend_common_meta_control::export_from_grpc; |
| 33 | +use databend_common_meta_control::import; |
35 | 34 | use databend_common_meta_kvapi::kvapi::KVApi; |
36 | | -use databend_common_meta_raft_store::config::RaftConfig; |
37 | 35 | use databend_common_tracing::init_logging; |
38 | 36 | use databend_common_tracing::Config as LogConfig; |
39 | 37 | use databend_common_tracing::FileConfig; |
40 | | -use databend_common_tracing::CONFIG_DEFAULT_LOG_LEVEL; |
41 | 38 | use databend_meta::version::METASRV_COMMIT_VERSION; |
42 | 39 | use serde::Deserialize; |
43 | 40 |
|
44 | | -#[derive(Debug, Clone, Deserialize, Args)] |
45 | | -pub struct GlobalArgs { |
46 | | - #[clap(long, default_value = CONFIG_DEFAULT_LOG_LEVEL)] |
47 | | - pub log_level: String, |
48 | | - |
49 | | - /// DEPRECATE: use subcommand instead. |
50 | | - #[clap( |
51 | | - long, |
52 | | - env = "METASRV_GRPC_API_ADDRESS", |
53 | | - default_value = "127.0.0.1:9191" |
54 | | - )] |
55 | | - pub grpc_api_address: String, |
56 | | - |
57 | | - /// DEPRECATE: use subcommand instead. |
58 | | - #[clap(long)] |
59 | | - pub import: bool, |
60 | | - |
61 | | - /// DEPRECATE: use subcommand instead. |
62 | | - #[clap(long)] |
63 | | - pub export: bool, |
64 | | - |
65 | | - /// DEPRECATE: use subcommand instead. |
66 | | - /// |
67 | | - /// The dir to store persisted meta state, including raft logs, state machine etc. |
68 | | - #[clap(long)] |
69 | | - #[serde(alias = "kvsrv_raft_dir")] |
70 | | - pub raft_dir: Option<String>, |
71 | | - |
72 | | - /// DEPRECATE: use subcommand instead. |
73 | | - /// |
74 | | - /// The N.O. json strings in a export stream item. |
75 | | - /// |
76 | | - /// Set this to a smaller value if you get gRPC message body too large error. |
77 | | - /// This requires meta-service >= 1.2.315; For older version, this argument is ignored. |
78 | | - /// |
79 | | - /// By default it is 32. |
80 | | - #[clap(long)] |
81 | | - pub export_chunk_size: Option<u64>, |
82 | | - |
83 | | - /// DEPRECATE: use subcommand instead. |
84 | | - /// |
85 | | - /// When export raft data, this is the name of the save db file. |
86 | | - /// If `db` is empty, output the exported data as json to stdout instead. |
87 | | - /// When import raft data, this is the name of the restored db file. |
88 | | - /// If `db` is empty, the restored data is from stdin instead. |
89 | | - #[clap(long, default_value = "")] |
90 | | - pub db: String, |
91 | | - |
92 | | - /// DEPRECATE: use subcommand instead. |
93 | | - /// |
94 | | - /// initial_cluster format: node_id=endpoint,grpc_api_addr |
95 | | - #[clap(long)] |
96 | | - pub initial_cluster: Vec<String>, |
97 | | - |
98 | | - /// DEPRECATE: use subcommand instead. |
99 | | - /// |
100 | | - /// The node id. Used in these cases: |
101 | | - /// |
102 | | - /// 1. when this server is not initialized, e.g. --boot or --single for the first time. |
103 | | - /// 2. --initial_cluster with new cluster node id. |
104 | | - /// |
105 | | - /// Otherwise this argument is ignored. |
106 | | - #[clap(long, default_value = "0")] |
107 | | - #[serde(alias = "kvsrv_id")] |
108 | | - pub id: u64, |
109 | | -} |
110 | | - |
111 | | -#[derive(Debug, Clone, Deserialize, Args)] |
112 | | -pub struct StatusArgs { |
113 | | - #[clap(long, default_value = "127.0.0.1:9191")] |
114 | | - pub grpc_api_address: String, |
115 | | -} |
116 | | - |
117 | | -#[derive(Debug, Clone, Deserialize, Args)] |
118 | | -pub struct ExportArgs { |
119 | | - #[clap(long, default_value = "127.0.0.1:9191")] |
120 | | - pub grpc_api_address: String, |
121 | | - |
122 | | - /// The dir to store persisted meta state, including raft logs, state machine etc. |
123 | | - #[clap(long)] |
124 | | - #[serde(alias = "kvsrv_raft_dir")] |
125 | | - pub raft_dir: Option<String>, |
126 | | - |
127 | | - /// The N.O. json strings in a export stream item. |
128 | | - /// |
129 | | - /// Set this to a smaller value if you get gRPC message body too large error. |
130 | | - /// This requires meta-service >= 1.2.315; For older version, this argument is ignored. |
131 | | - /// |
132 | | - /// By default it is 32. |
133 | | - #[clap(long)] |
134 | | - pub chunk_size: Option<u64>, |
135 | | - |
136 | | - /// The name of the save db file. |
137 | | - /// If `db` is empty, output the exported data as json to stdout instead. |
138 | | - #[clap(long, default_value = "")] |
139 | | - pub db: String, |
140 | | - |
141 | | - /// The node id. Used in these cases: |
142 | | - /// |
143 | | - /// 1. when this server is not initialized, e.g. --boot or --single for the first time. |
144 | | - /// 2. --initial_cluster with new cluster node id. |
145 | | - /// |
146 | | - /// Otherwise this argument is ignored. |
147 | | - #[clap(long, default_value = "0")] |
148 | | - #[serde(alias = "kvsrv_id")] |
149 | | - pub id: u64, |
150 | | -} |
151 | | - |
152 | | -impl From<ExportArgs> for RaftConfig { |
153 | | - #[allow(clippy::field_reassign_with_default)] |
154 | | - fn from(value: ExportArgs) -> Self { |
155 | | - let mut c = Self::default(); |
156 | | - |
157 | | - c.raft_dir = value.raft_dir.unwrap_or_default(); |
158 | | - c.id = value.id; |
159 | | - c |
160 | | - } |
161 | | -} |
162 | | - |
163 | | -#[derive(Debug, Clone, Deserialize, Args)] |
164 | | -pub struct ImportArgs { |
165 | | - /// The dir to store persisted meta state, including raft logs, state machine etc. |
166 | | - #[clap(long)] |
167 | | - #[serde(alias = "kvsrv_raft_dir")] |
168 | | - pub raft_dir: Option<String>, |
169 | | - |
170 | | - /// The name of the restored db file. |
171 | | - /// If `db` is empty, the restored data is from stdin instead. |
172 | | - #[clap(long, default_value = "")] |
173 | | - pub db: String, |
174 | | - |
175 | | - /// initial_cluster format: node_id=endpoint,grpc_api_addr |
176 | | - #[clap(long)] |
177 | | - pub initial_cluster: Vec<String>, |
178 | | - |
179 | | - /// The node id. Used in these cases: |
180 | | - /// |
181 | | - /// 1. when this server is not initialized, e.g. --boot or --single for the first time. |
182 | | - /// 2. --initial_cluster with new cluster node id. |
183 | | - /// |
184 | | - /// Otherwise this argument is ignored. |
185 | | - #[clap(long, default_value = "0")] |
186 | | - #[serde(alias = "kvsrv_id")] |
187 | | - pub id: u64, |
188 | | -} |
189 | | - |
190 | | -impl From<ImportArgs> for RaftConfig { |
191 | | - #[allow(clippy::field_reassign_with_default)] |
192 | | - fn from(value: ImportArgs) -> Self { |
193 | | - let mut c = Self::default(); |
194 | | - |
195 | | - c.raft_dir = value.raft_dir.unwrap_or_default(); |
196 | | - c.id = value.id; |
197 | | - c |
198 | | - } |
199 | | -} |
200 | | - |
201 | | -#[derive(Debug, Clone, Deserialize, Args)] |
202 | | -pub struct TransferLeaderArgs { |
203 | | - #[clap(long)] |
204 | | - pub to: Option<u64>, |
205 | | - |
206 | | - #[clap(long, default_value = "127.0.0.1:28002")] |
207 | | - pub admin_api_address: String, |
208 | | -} |
209 | | - |
210 | | -#[derive(Debug, Clone, Deserialize, Args)] |
211 | | -pub struct BenchArgs { |
212 | | - #[clap(long, default_value = "127.0.0.1:9191")] |
213 | | - pub grpc_api_address: String, |
214 | | -} |
215 | | - |
216 | 41 | #[derive(Debug, Deserialize, Parser)] |
217 | 42 | #[clap(name = "databend-metactl", about, version = &**METASRV_COMMIT_VERSION, author)] |
218 | 43 | struct App { |
|
0 commit comments