commands.h 8.4 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>
W
Wu Tao 已提交
18
#include <dsn/dist/cli/cli.client.h>
Q
qinzuoyan 已提交
19 20
#include <dsn/dist/replication/replication_ddl_client.h>
#include <dsn/dist/replication/mutation_log_tool.h>
21

Q
qinzuoyan 已提交
22
#include <rrdb/rrdb.code.definition.h>
W
Wu Tao 已提交
23
#include <rrdb/rrdb_types.h>
24 25 26 27 28 29 30
#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"
31
#include "args.h"
Q
qinzuoyan 已提交
32 33

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

37
static const char *INDENT = "  ";
38 39 40 41 42 43 44 45 46 47 48 49
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;
50 51 52 53 54 55 56 57
    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;
58 59
    double read_cu;
    double write_cu;
60 61 62 63 64 65 66 67 68 69
    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),
70 71 72 73 74 75 76 77
          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),
78 79 80
          multi_put_p99(0.0),
          read_cu(0.0),
          write_cu(0.0)
81 82 83
    {
    }
};
Q
qinzuoyan 已提交
84

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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);
234 235 236 237 238 239 240 241 242 243 244 245

// == 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);
246 247 248 249 250 251

// == 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);