commands.h 8.9 KB
Newer Older
Q
qinzuoyan 已提交
1 2 3 4 5 6
// Copyright (c) 2017, Xiaomi, Inc.  All rights reserved.
// This source code is licensed under the Apache License Version 2.0, which
// can be found in the LICENSE file in the root directory of this source tree.

#pragma once

7 8 9 10 11 12
#include <getopt.h>
#include <thread>
#include <iomanip>
#include <fstream>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
Q
qinzuoyan 已提交
13
#include <rocksdb/db.h>
14
#include <dsn/utility/filesystem.h>
15
#include <dsn/utility/output_utils.h>
16
#include <dsn/utility/string_conv.h>
Q
QinZuoyan 已提交
17
#include <dsn/utility/string_view.h>
Q
qinzuoyan 已提交
18 19
#include <dsn/dist/replication/replication_ddl_client.h>
#include <dsn/dist/replication/mutation_log_tool.h>
20

Q
qinzuoyan 已提交
21
#include <rrdb/rrdb.code.definition.h>
W
Wu Tao 已提交
22
#include <rrdb/rrdb_types.h>
23 24 25 26 27 28 29
#include <pegasus/version.h>
#include <pegasus/git_commit.h>
#include <pegasus/error.h>

#include "command_executor.h"
#include "command_utils.h"
#include "command_helper.h"
30
#include "args.h"
Q
qinzuoyan 已提交
31 32

using namespace dsn::replication;
33
using tp_alignment = ::dsn::utils::table_printer::alignment;
34
using tp_output_format = ::dsn::utils::table_printer::output_format;
Q
qinzuoyan 已提交
35

36
static const char *INDENT = "  ";
37 38 39 40 41 42 43 44 45 46 47 48
struct list_nodes_helper
{
    std::string node_name;
    std::string node_status;
    int primary_count;
    int secondary_count;
    int64_t memused_res_mb;
    int64_t block_cache_bytes;
    int64_t mem_tbl_bytes;
    int64_t mem_idx_bytes;
    int64_t disk_available_total_ratio;
    int64_t disk_available_min_ratio;
49 50 51 52 53 54 55 56
    double get_qps;
    double put_qps;
    double multi_get_qps;
    double multi_put_qps;
    double get_p99;
    double put_p99;
    double multi_get_p99;
    double multi_put_p99;
57 58
    double read_cu;
    double write_cu;
59 60 61 62 63 64 65 66 67 68
    list_nodes_helper(const std::string &n, const std::string &s)
        : node_name(n),
          node_status(s),
          primary_count(0),
          secondary_count(0),
          memused_res_mb(0),
          block_cache_bytes(0),
          mem_tbl_bytes(0),
          mem_idx_bytes(0),
          disk_available_total_ratio(0),
69 70 71 72 73 74 75 76
          disk_available_min_ratio(0),
          get_qps(0.0),
          put_qps(0.0),
          multi_get_qps(0.0),
          multi_put_qps(0.0),
          get_p99(0.0),
          put_p99(0.0),
          multi_get_p99(0.0),
77 78 79
          multi_put_p99(0.0),
          read_cu(0.0),
          write_cu(0.0)
80 81 82
    {
    }
};
Q
qinzuoyan 已提交
83

84
// == miscellaneous (see 'commands/misc.cpp') == //
W
Wu Tao 已提交
85

86
bool help_info(command_executor *e, shell_context *sc, arguments args);
87

88
bool version(command_executor *e, shell_context *sc, arguments args);
89

90
bool exit_shell(command_executor *e, shell_context *sc, arguments args);
91

92
// == global properties (see 'commands/global_properties.cpp') == //
W
Wu Tao 已提交
93

94
bool use_app_as_current(command_executor *e, shell_context *sc, arguments args);
95

96
bool process_escape_all(command_executor *e, shell_context *sc, arguments args);
97

98
bool process_timeout(command_executor *e, shell_context *sc, arguments args);
99

100
bool cc_command(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
101

102
// == node management (see 'commands/node_management.cpp') == //
W
Wu Tao 已提交
103

104
bool query_cluster_info(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
105

106
bool ls_nodes(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
107

108
bool server_info(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
109

110
bool server_stat(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
111

112
bool remote_command(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
113

114
bool flush_log(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
115

116
// == table management (see 'commands/table_management.cpp') == //
W
Wu Tao 已提交
117

118
bool ls_apps(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
119

120
bool query_app(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
121

122
bool app_disk(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
123

124
bool app_stat(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
125

126
bool create_app(command_executor *e, shell_context *sc, arguments args);
Q
QinZuoyan 已提交
127

128
bool drop_app(command_executor *e, shell_context *sc, arguments args);
129

130
bool recall_app(command_executor *e, shell_context *sc, arguments args);
131

132
bool get_app_envs(command_executor *e, shell_context *sc, arguments args);
133

134
bool set_app_envs(command_executor *e, shell_context *sc, arguments args);
135

136
bool del_app_envs(command_executor *e, shell_context *sc, arguments args);
137

138
bool clear_app_envs(command_executor *e, shell_context *sc, arguments args);
139

140
// == data operations (see 'commands/data_operations.cpp') == //
W
Wu Tao 已提交
141

142
bool data_operations(command_executor *e, shell_context *sc, arguments args);
143

144
bool set_value(command_executor *e, shell_context *sc, arguments args);
145

146
bool multi_set_value(command_executor *e, shell_context *sc, arguments args);
147

148
bool get_value(command_executor *e, shell_context *sc, arguments args);
149

150
bool multi_get_value(command_executor *e, shell_context *sc, arguments args);
151

152
bool multi_get_range(command_executor *e, shell_context *sc, arguments args);
153

154
bool multi_get_sortkeys(command_executor *e, shell_context *sc, arguments args);
155

156
bool delete_value(command_executor *e, shell_context *sc, arguments args);
157

158
bool multi_del_value(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
159

160
bool multi_del_range(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
161

162
bool incr(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
163

164
bool check_and_set(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
165

166
bool check_and_mutate(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
167

168
bool exist(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
169

170
bool sortkey_count(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
171

172
bool get_ttl(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
173

174
bool calculate_hash_value(command_executor *e, shell_context *sc, arguments args);
175

176
bool hash_scan(command_executor *e, shell_context *sc, arguments args);
177

178
bool full_scan(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
179

180
bool copy_data(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
181

182
bool clear_data(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
183

184
bool count_data(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
185

186
// == load balancing(see 'commands/rebalance.cpp') == //
W
Wu Tao 已提交
187

188
bool set_meta_level(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
189

190
bool get_meta_level(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
191

192
bool propose(command_executor *e, shell_context *sc, arguments args);
193

194
bool balance(command_executor *e, shell_context *sc, arguments args);
195

196
// == data recovery(see 'commands/recovery.cpp') == //
W
Wu Tao 已提交
197

198
bool recover(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
199

200
bool ddd_diagnose(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
201

202
// == cold backup (see 'commands/cold_backup.cpp') == //
W
Wu Tao 已提交
203

204
bool add_backup_policy(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
205

206
bool ls_backup_policy(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
207

208
bool modify_backup_policy(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
209

210
bool disable_backup_policy(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
211

212
bool enable_backup_policy(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
213

214
bool restore(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
215

216
bool query_backup_policy(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
217

218
bool query_restore_status(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
219

220
// == debugger (see 'commands/debugger.cpp') == //Debugging tool
W
Wu Tao 已提交
221

222
bool sst_dump(command_executor *e, shell_context *sc, arguments args);
Q
qinzuoyan 已提交
223

224
bool mlog_dump(command_executor *e, shell_context *sc, arguments args);
225

226
bool local_get(command_executor *e, shell_context *sc, arguments args);
227 228 229 230 231 232

bool rdb_key_hex2str(command_executor *e, shell_context *sc, arguments args);

bool rdb_key_str2hex(command_executor *e, shell_context *sc, arguments args);

bool rdb_value_hex2str(command_executor *e, shell_context *sc, arguments args);
233 234 235 236 237 238 239 240 241 242 243 244

// == duplication (see 'commands/duplication.cpp') == //

bool add_dup(command_executor *e, shell_context *sc, arguments args);

bool query_dup(command_executor *e, shell_context *sc, arguments args);

bool remove_dup(command_executor *e, shell_context *sc, arguments args);

bool start_dup(command_executor *e, shell_context *sc, arguments args);

bool pause_dup(command_executor *e, shell_context *sc, arguments args);
245

246 247
bool set_dup_fail_mode(command_executor *e, shell_context *sc, arguments args);

248 249 250 251 252
// == disk rebalance (see 'commands/disk_rebalance.cpp') == //

bool query_disk_capacity(command_executor *e, shell_context *sc, arguments args);

bool query_disk_replica(command_executor *e, shell_context *sc, arguments args);
253 254 255 256 257 258 259 260 261 262 263 264

// == bulk load (see 'commands/bulk_load.cpp') == //

bool start_bulk_load(command_executor *e, shell_context *sc, arguments args);

bool query_bulk_load_status(command_executor *e, shell_context *sc, arguments args);

bool pause_bulk_load(command_executor *e, shell_context *sc, arguments args);

bool restart_bulk_load(command_executor *e, shell_context *sc, arguments args);

bool cancel_bulk_load(command_executor *e, shell_context *sc, arguments args);