Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
29ad3b72
Incubator Pegasus
项目概览
apache
/
Incubator Pegasus
通知
9
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Incubator Pegasus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
29ad3b72
编写于
5月 24, 2018
作者:
Q
QinZuoyan
提交者:
GitHub
5月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
*: update rdsn; fix pack scripts; fix server configs; improve shell help format (#53)
上级
c117d770
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
147 addition
and
116 deletion
+147
-116
rdsn
rdsn
+1
-1
run.sh
run.sh
+8
-8
scripts/pack_client.sh
scripts/pack_client.sh
+4
-0
scripts/pack_server.sh
scripts/pack_server.sh
+1
-0
scripts/pack_tools.sh
scripts/pack_tools.sh
+2
-0
src/server/config.ini
src/server/config.ini
+2
-2
src/shell/args.h
src/shell/args.h
+3
-3
src/shell/main.cpp
src/shell/main.cpp
+126
-102
未找到文件。
rdsn
@
e77b7bb6
比较
e42cc100
...
e77b7bb6
Subproject commit e
42cc100833be6695c64325df7a6f2eabb91c776
Subproject commit e
77b7bb6df1859c324a54804f4e254d5155092d7
run.sh
浏览文件 @
29ad3b72
...
...
@@ -479,8 +479,8 @@ function run_start_onebox()
cd
meta
$i
ln
-s
-f
${
SERVER_PATH
}
/pegasus_server pegasus_server
sed
"s/@META_PORT@/
$meta_port
/;s/@REPLICA_PORT@/34800/"
${
ROOT
}
/config-server.ini
>
config.ini
echo
"cd
`
pwd
`
&&
../meta
$i
/pegasus_server config.ini -app_list meta &>result &"
../meta
$i
/pegasus_server config.ini
-app_list
meta &>result &
echo
"cd
`
pwd
`
&&
$PWD
/pegasus_server config.ini -app_list meta &>result &"
$PWD
/pegasus_server config.ini
-app_list
meta &>result &
PID
=
$!
ps
-ef
|
grep
'/pegasus_server config.ini'
|
grep
"
\<
$PID
\>
"
cd
..
...
...
@@ -492,8 +492,8 @@ function run_start_onebox()
cd
replica
$j
ln
-s
-f
${
SERVER_PATH
}
/pegasus_server pegasus_server
sed
"s/@META_PORT@/34600/;s/@REPLICA_PORT@/
$replica_port
/"
${
ROOT
}
/config-server.ini
>
config.ini
echo
"cd
`
pwd
`
&&
../replica
$j
/pegasus_server config.ini -app_list replica &>result &"
../replica
$j
/pegasus_server config.ini
-app_list
replica &>result &
echo
"cd
`
pwd
`
&&
$PWD
/pegasus_server config.ini -app_list replica &>result &"
$PWD
/pegasus_server config.ini
-app_list
replica &>result &
PID
=
$!
ps
-ef
|
grep
'/pegasus_server config.ini'
|
grep
"
\<
$PID
\>
"
cd
..
...
...
@@ -652,8 +652,8 @@ function run_start_onebox_instance()
exit
-1
fi
cd
$dir
echo
"cd
`
pwd
`
&&
../meta
$META_I
D
/pegasus_server config.ini -app_list meta &>result &"
../meta
$META_I
D
/pegasus_server config.ini
-app_list
meta &>result &
echo
"cd
`
pwd
`
&&
$PW
D
/pegasus_server config.ini -app_list meta &>result &"
$PW
D
/pegasus_server config.ini
-app_list
meta &>result &
PID
=
$!
ps
-ef
|
grep
'/pegasus_server config.ini'
|
grep
"
\<
$PID
\>
"
cd
..
...
...
@@ -670,8 +670,8 @@ function run_start_onebox_instance()
exit
-1
fi
cd
$dir
echo
"cd
`
pwd
`
&&
../replica
$REPLICA_I
D
/pegasus_server config.ini -app_list replica &>result &"
../replica
$REPLICA_I
D
/pegasus_server config.ini
-app_list
replica &>result &
echo
"cd
`
pwd
`
&&
$PW
D
/pegasus_server config.ini -app_list replica &>result &"
$PW
D
/pegasus_server config.ini
-app_list
replica &>result &
PID
=
$!
ps
-ef
|
grep
'/pegasus_server config.ini'
|
grep
"
\<
$PID
\>
"
cd
..
...
...
scripts/pack_client.sh
浏览文件 @
29ad3b72
...
...
@@ -94,6 +94,10 @@ ln -sf `ls ${pack}/lib | grep libboost_system` ${pack}/lib/libboost_system.so
cp
-v
`
get_boost_lib
$custom_boost_lib
filesystem
`
${
pack
}
/lib
ln
-sf
`
ls
${
pack
}
/lib |
grep
libboost_filesystem
`
${
pack
}
/lib/libboost_filesystem.so
cp
-v
-r
./src/include
${
pack
}
cd
src/sample
make clean
cd
$shell_dir
cp
-v
-r
./src/sample
${
pack
}
echo
"Pegasus Client
$version
(
$commit_id
)
$platform
$build_type
"
>
${
pack
}
/VERSION
...
...
scripts/pack_server.sh
浏览文件 @
29ad3b72
...
...
@@ -91,6 +91,7 @@ cp -v ./DSN_ROOT/bin/pegasus_server/pegasus_server ${pack}/bin
cp
-v
./DSN_ROOT/lib/libdsn_meta_server.so
${
pack
}
/bin
cp
-v
./DSN_ROOT/lib/libdsn_replica_server.so
${
pack
}
/bin
cp
-v
./rdsn/thirdparty/output/lib/libPoco
*
.so.48
${
pack
}
/bin
cp
-v
./rdsn/thirdparty/output/lib/libtcmalloc.so.4
${
pack
}
/bin
cp
-v
./scripts/sendmail.sh
${
pack
}
/bin
cp
-v
./src/server/config.ini
${
pack
}
/bin
...
...
scripts/pack_tools.sh
浏览文件 @
29ad3b72
...
...
@@ -100,6 +100,7 @@ cp -v -r ./DSN_ROOT/bin/pegasus_pressureclient ${pack}/DSN_ROOT/bin/
mkdir
-p
${
pack
}
/DSN_ROOT/lib
cp
-v
-r
./DSN_ROOT/lib/
*
.so
*
${
pack
}
/DSN_ROOT/lib/
cp
-v
./rdsn/thirdparty/output/lib/libPoco
*
.so.48
${
pack
}
/DSN_ROOT/lib/
cp
-v
./rdsn/thirdparty/output/lib/libtcmalloc.so.4
${
pack
}
/DSN_ROOT/lib/
cp
-v
`
get_boost_lib
$custom_boost_lib
system
`
${
pack
}
/DSN_ROOT/lib/
cp
-v
`
get_boost_lib
$custom_boost_lib
filesystem
`
${
pack
}
/DSN_ROOT/lib/
cp
-v
`
get_stdcpp_lib
$custom_gcc
`
${
pack
}
/DSN_ROOT/lib/
...
...
@@ -109,6 +110,7 @@ cp -v `get_system_lib shell crypto` ${pack}/DSN_ROOT/lib/
cp
-v
`
get_system_lib shell ssl
`
${
pack
}
/DSN_ROOT/lib/
cp
-v
`
get_system_lib shell aio
`
${
pack
}
/DSN_ROOT/lib/
cp
-v
`
get_system_lib shell bz2
`
${
pack
}
/DSN_ROOT/lib/
chmod
-x
${
pack
}
/DSN_ROOT/lib/
*
mkdir
-p
${
pack
}
/scripts
cp
-v
./scripts/
*
${
pack
}
/scripts/
...
...
src/server/config.ini
浏览文件 @
29ad3b72
...
...
@@ -240,8 +240,6 @@
cold_backup_root
=
%{cluster.name}
max_concurrent_uploading_file_count
=
10
manual_compact_min_interval_seconds
=
3600
[replication.app]
app_name
=
temp
app_type
=
pegasus
...
...
@@ -276,6 +274,8 @@
checkpoint_reserve_time_seconds
=
0
updating_rocksdb_sstsize_interval_seconds
=
600
manual_compact_min_interval_seconds
=
3600
perf_counter_cluster_name
=
%{cluster.name}
perf_counter_update_interval_seconds
=
10
perf_counter_enable_stat
=
true
...
...
src/shell/args.h
浏览文件 @
29ad3b72
...
...
@@ -15,7 +15,7 @@
#include <boost/lexical_cast.hpp>
#include <dsn/service_api_c.h>
extern
std
::
string
s
_last_history
;
extern
std
::
string
g
_last_history
;
inline
void
rl_gets
(
char
*&
line_read
,
bool
nextCommand
=
true
)
{
...
...
@@ -32,9 +32,9 @@ inline void rl_gets(char *&line_read, bool nextCommand = true)
if
(
!
line_read
)
dsn_exit
(
0
);
if
(
line_read
&&
*
line_read
&&
s
_last_history
!=
line_read
)
{
if
(
line_read
&&
*
line_read
&&
g
_last_history
!=
line_read
)
{
add_history
(
line_read
);
s
_last_history
=
line_read
;
g
_last_history
=
line_read
;
}
}
...
...
src/shell/main.cpp
浏览文件 @
29ad3b72
...
...
@@ -3,6 +3,7 @@
// can be found in the LICENSE file in the root directory of this source tree.
#include <pegasus/version.h>
#include <dsn/utility/strings.h>
#include <setjmp.h>
#include <signal.h>
#include <algorithm>
...
...
@@ -10,11 +11,12 @@
#include "command_executor.h"
#include "commands.h"
std
::
string
s_last_history
;
const
int
max_params_count
=
10000
;
std
::
map
<
std
::
string
,
command_executor
*>
commands_map
;
shell_context
global_context
;
size_t
max_length
=
0
;
std
::
string
g_last_history
;
const
int
s_max_params_count
=
10000
;
std
::
map
<
std
::
string
,
command_executor
*>
s_commands_map
;
shell_context
s_global_context
;
size_t
s_max_name_length
=
0
;
size_t
s_option_width
=
70
;
void
print_help
();
bool
help_info
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
...
...
@@ -36,39 +38,37 @@ command_executor commands[] = {
{
"app"
,
"get the partition information for some specific app"
,
"<app_name> [-d|--detailed] [-o|--output
<out_file>
]"
,
"<app_name> [-d|--detailed] [-o|--output
file_name
]"
,
query_app
,
},
{
"app_disk"
,
"get the disk usage information for some specific app"
,
"<app_name> [-d|--detailed] [-o|--output
<out_file>
]"
,
"<app_name> [-d|--detailed] [-o|--output
file_name
]"
,
app_disk
,
},
{
"ls"
,
"list all apps"
,
"[-a|-all] [-d|--detailed] [-s|--status "
"<all|available|creating|dropping|dropped>] "
"[-o|--output FILE_PATH]"
,
"[-a|-all] [-d|--detailed] [-o|--output file_name] "
"[-s|--status all|available|creating|dropping|dropped]"
,
ls_apps
,
},
{
"nodes"
,
"get the node status for this cluster"
,
"[-d|--detailed] [-s|--status <all|alive|unalive>] [-o|--output "
"FILE_PATH]"
,
"[-d|--detailed] [-o|--output file_name] [-s|--status all|alive|unalive]"
,
ls_nodes
,
},
{
"create"
,
"create an app"
,
"
app_name [--partition_count|-p NUMBER] [--replica_count|-r NUMBER
] "
"[-
-envs|-e
k1=v1,k2=v2...]"
,
"
<app_name> [-p|--partition_count num] [-r|--replica_count num
] "
"[-
e|--envs
k1=v1,k2=v2...]"
,
create_app
,
},
{
"drop"
,
"drop an app"
,
"
app_name [--reserve_seconds|-r NUMBER
]"
,
drop_app
,
"drop"
,
"drop an app"
,
"
<app_name> [-r|--reserve_seconds num
]"
,
drop_app
,
},
{
"recall"
,
"recall an app"
,
"<app_id> [new_app_name]"
,
recall_app
,
...
...
@@ -76,7 +76,7 @@ command_executor commands[] = {
{
"set_meta_level"
,
"set the meta function level: stopped, blind, freezed, steady, lively"
,
"<stopped
| blind | freezed | steady |
lively>"
,
"<stopped
|blind|freezed|steady|
lively>"
,
set_meta_level
,
},
{
...
...
@@ -85,17 +85,16 @@ command_executor commands[] = {
{
"balance"
,
"send explicit balancer request for the cluster"
,
"-g|--gpid <appid.pidx> -p|--type <move_pri|copy_pri|copy_sec> -f|--from "
"<from_address> "
"-t|--to <to_address>"
,
"<-g|--gpid appid.pidx> <-p|--type move_pri|copy_pri|copy_sec> <-f|--from from_address> "
"<-t|--to to_address>"
,
balance
,
},
{
"propose"
,
"send configuration proposals to cluster"
,
"[-f|--force] "
"
-g|--gpid <appid.pidx> -p|--type <
ASSIGN_PRIMARY|ADD_SECONDARY|DOWNGRADE_TO_INACTIVE...> "
"
-t|--target <node_exec_command> -n|--node <nod
e_affected> "
,
"
<-g|--gpid appid.pidx> <-p|--type
ASSIGN_PRIMARY|ADD_SECONDARY|DOWNGRADE_TO_INACTIVE...> "
"
<-t|--target node_to_exec_command> <-n|--node node_to_b
e_affected> "
,
propose
,
},
{
...
...
@@ -144,10 +143,10 @@ command_executor commands[] = {
"multi_get_range"
,
"get multiple values under sort key range for a single hash key"
,
"<hash_key> <start_sort_key> <stop_sort_key> "
"[-
-start_inclusive|-a <true|false>] [--stop_inclusive|-b <true|false>
] "
"[-
-sort_key_filter_type|-s <anywhere|prefix|postfix>
] "
"[-
-sort_key_filter_pattern|-y <str>
] "
"[-
-max_count|-n <num>] [--no_value|-i] [--reverse|-r
]"
,
"[-
a|--start_inclusive true|false] [-b|--stop_inclusive true|false
] "
"[-
s|--sort_key_filter_type anywhere|prefix|postfix
] "
"[-
y|--sort_key_filter_pattern str
] "
"[-
n|--max_count num] [-i|--no_value] [-r|--reverse
]"
,
data_operations
,
},
{
...
...
@@ -157,7 +156,7 @@ command_executor commands[] = {
data_operations
,
},
{
"del"
,
"del a key"
,
"<hash_key> <sort_key>"
,
data_operations
,
"del"
,
"del
ete
a key"
,
"<hash_key> <sort_key>"
,
data_operations
,
},
{
"multi_del"
,
...
...
@@ -169,10 +168,10 @@ command_executor commands[] = {
"multi_del_range"
,
"delete multiple values under sort key range for a single hash key"
,
"<hash_key> <start_sort_key> <stop_sort_key> "
"[-
-start_inclusive|-a <true|false>] [--stop_inclusive|-b <true|false>
] "
"[-
-sort_key_filter_type|-s <anywhere|prefix|postfix>
] "
"[-
-sort_key_filter_pattern|-y <str>
] "
"[-
-output|-o <file_name>] [--silent|-i
]"
,
"[-
a|--start_inclusive true|false] [-b|--stop_inclusive true|false
] "
"[-
s|--sort_key_filter_type anywhere|prefix|postfix
] "
"[-
y|--sort_key_filter_pattern str
] "
"[-
o|--output file_name] [-i|--silent
]"
,
data_operations
,
},
{
...
...
@@ -187,76 +186,72 @@ command_executor commands[] = {
{
"hash_scan"
,
"scan all sorted keys for a single hash key"
,
"<hash_key> <start_sort_key> <stop_sort_key>
[-d|--detailed]
"
"[-
o|--output <file_name>] [-n|--max_count <num>] [-t|--timeout_ms <num>
] "
"[-
-start_inclusive|-a <true|false>] [--stop_inclusive|-b <true|false>
] "
"[-
-sort_key_filter_type|-s <anywhere|prefix|postfix>
] "
"[-
-sort_key_filter_pattern|-y <str>
] "
"[-
-no_value|-i
]"
,
"<hash_key> <start_sort_key> <stop_sort_key> "
"[-
a|--start_inclusive true|false] [-b|--stop_inclusive true|false
] "
"[-
s|--sort_key_filter_type anywhere|prefix|postfix
] "
"[-
y|--sort_key_filter_pattern str
] "
"[-
o|--output file_name] [-n|--max_count num] [-t|--timeout_ms num
] "
"[-
d|--detailed] [-i|--no_value
]"
,
data_operations
,
},
{
"full_scan"
,
"scan all hash keys"
,
"[-d|--detailed] [-p|--partition <num>] [-o|--output <file_name>] "
"[-n|--max_count <num>] [-t|--timeout_ms <num>] "
"[--hash_key_filter_type|-h <anywhere|prefix|postfix>] "
"[--hash_key_filter_pattern|-x <str>] "
"[--sort_key_filter_type|-s <anywhere|prefix|postfix>] "
"[--sort_key_filter_pattern|-y <str>] "
"[--no_value|-i]"
,
"[-h|--hash_key_filter_type anywhere|prefix|postfix] "
"[-x|--hash_key_filter_pattern str] "
"[-s|--sort_key_filter_type anywhere|prefix|postfix] "
"[-y|--sort_key_filter_pattern str] "
"[-o|--output file_name] [-n|--max_count num] [-t|--timeout_ms num] "
"[-d|--detailed] [-i|--no_value] [-p|--partition num]"
,
data_operations
,
},
{
"copy_data"
,
"copy app data"
,
"-c|--target_cluster_name <str> -a|--target_app_name <str> "
"[-s|--max_split_count <num>] "
"[-b|--max_batch_count <num>] [-t|--timeout_ms <num>]"
,
"<-c|--target_cluster_name str> <-a|--target_app_name str> "
"[-s|--max_split_count num] [-b|--max_batch_count num] [-t|--timeout_ms num]"
,
data_operations
,
},
{
"clear_data"
,
"clear app data"
,
"[-f|--force] [-s|--max_split_count <num>] [-b|--max_batch_count <num>] "
"[-t|--timeout_ms "
"<num>]"
,
"[-f|--force] [-s|--max_split_count num] [-b|--max_batch_count num] "
"[-t|--timeout_ms num]"
,
data_operations
,
},
{
"count_data"
,
"get app row count"
,
"[-s|--max_split_count <num>] [-b|--max_batch_count <num>] "
"[-t|--timeout_ms <num>] "
"[-z|--stat_size] [-c|--top_count <num>]"
,
"[-s|--max_split_count num] [-b|--max_batch_count num] "
"[-t|--timeout_ms num] [-z|--stat_size] [-c|--top_count num]"
,
data_operations
,
},
{
"remote_command"
,
"send remote command to servers"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
,...,ip:port
] "
"
command
[arguments...]"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
...
] "
"
<command>
[arguments...]"
,
remote_command
,
},
{
"server_info"
,
"get info of servers"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
,...,ip:port
]"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
...
]"
,
server_info
,
},
{
"server_stat"
,
"get stat of servers"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
,...,ip:port
]"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
...
]"
,
server_stat
,
},
{
"app_stat"
,
"get stat of apps"
,
"[-a|--app_name
<str>] [-o|--output <out_file>
]"
,
app_stat
,
"app_stat"
,
"get stat of apps"
,
"[-a|--app_name
str] [-o|--output file_name
]"
,
app_stat
,
},
{
"flush_log"
,
"flush log of servers"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
,...,ip:port
]"
,
"[-t all|meta-server|replica-server] [-l ip:port,ip:port
...
]"
,
flush_log
,
},
{
...
...
@@ -265,67 +260,65 @@ command_executor commands[] = {
{
"sst_dump"
,
"dump sstable dir or files"
,
"[--command=check|scan|none|raw] --file=data_dir_OR_sst_file "
"[--from=<user_key>] "
"[--to=<user_key>] [--read_num=NUM] [--show_properties]"
,
"[--command=check|scan|none|raw] <--file=data_dir_OR_sst_file> "
"[--from=user_key] [--to=user_key] [--read_num=num] [--show_properties]"
,
sst_dump
,
},
{
"mlog_dump"
,
"dump mutation log dir"
,
"
-i|--input log_dir
[-o|--output file_name] [-d|--detailed]"
,
"
<-i|--input log_dir>
[-o|--output file_name] [-d|--detailed]"
,
mlog_dump
,
},
{
"recover"
,
"control the meta to recover the system from given nodes"
,
"[-f|--node_list_file file_name] [-s|--node_list_str node_str] "
"[-w|--wait_seconds seconds] "
"[-b|--skip_bad_nodes] [-l|--skip_lost_partitions] [-o|--output "
"FILE_NAME]"
,
"[-f|--node_list_file file_name] [-s|--node_list_str str] "
"[-w|--wait_seconds num] "
"[-b|--skip_bad_nodes] [-l|--skip_lost_partitions] [-o|--output file_name]"
,
recover
,
},
{
"add_backup_policy"
,
"add new cold backup policy"
,
"<-p|--policy_name
p1> <-b|--backup_provider_type provider> <-a|--app_ids 1,2,3
..> "
"<-i|--backup_interval_seconds
sec
> <-s|--start_time hour:minute> "
"<-c|--backup_history_cnt
count
>"
,
"<-p|--policy_name
str> <-b|--backup_provider_type str> <-a|--app_ids 1,2.
..> "
"<-i|--backup_interval_seconds
num
> <-s|--start_time hour:minute> "
"<-c|--backup_history_cnt
num
>"
,
add_backup_policy
,
},
{
"ls_backup_policy"
,
"list the names of the subsistent backup policies"
,
""
,
ls_backup_policy
},
{
"query_backup_policy"
,
"query subsistent backup policy and last backup infos"
,
"<-p|--policy_name p1,p2
> [-b|--backup_info_cnt cnt
]"
,
"<-p|--policy_name p1,p2
...> [-b|--backup_info_cnt num
]"
,
query_backup_policy
,
},
{
"modify_backup_policy"
,
"modify the backup policy"
,
"<-p|--policy_name
p1
> [-a|--add_app 1,2...] [-r|--remove_app 1,2...] "
"[-i|--backup_interval_seconds
sec] [-c|--backup_history_count cnt
] "
"<-p|--policy_name
str
> [-a|--add_app 1,2...] [-r|--remove_app 1,2...] "
"[-i|--backup_interval_seconds
num] [-c|--backup_history_count num
] "
"[-s|--start_time hour:minute]"
,
modify_backup_policy
,
},
{
"disable_backup_policy"
,
"stop policy continue backup"
,
"<-p|--policy_name
p1
>"
,
"<-p|--policy_name
str
>"
,
disable_backup_policy
,
},
{
"enable_backup_policy"
,
"start backup policy to backup again"
,
"<-p|--policy_name
p1
>"
,
"<-p|--policy_name
str
>"
,
enable_backup_policy
,
},
{
"restore_app"
,
"restore app from backup media"
,
"<-c|--old_cluster_name
name> <-p|--old_policy_name name> <-a|--old_app_name name
> "
"<-c|--old_cluster_name
str> <-p|--old_policy_name str> <-a|--old_app_name str
> "
"<-i|--old_app_id id> <-t|--timestamp/backup_id timestamp> "
"<-b|--backup_provider_type
provider> [-n|--new_app_name name] [-s|--skip_bad_partition]
"
,
"<-b|--backup_provider_type
str> [-n|--new_app_name str] [-s|--skip_bad_partition]
"
,
restore
,
},
{
...
...
@@ -338,10 +331,10 @@ command_executor commands[] = {
"get_app_envs"
,
"get current app envs"
,
""
,
get_app_envs
,
},
{
"set_app_envs"
,
"set current app envs"
,
"<key
1> <value1> <key2> <value2> ...
"
,
set_app_envs
,
"set_app_envs"
,
"set current app envs"
,
"<key
> <value> [key value...]
"
,
set_app_envs
,
},
{
"del_app_envs"
,
"delete current app envs"
,
"<key
1> <key2> ...
"
,
del_app_envs
,
"del_app_envs"
,
"delete current app envs"
,
"<key
> [key...]
"
,
del_app_envs
,
},
{
"clear_app_envs"
,
"clear current app envs"
,
"<-a|--all> <-p|--prefix str>"
,
clear_app_envs
,
...
...
@@ -353,41 +346,72 @@ command_executor commands[] = {
nullptr
,
nullptr
,
nullptr
,
nullptr
,
}};
void
print_help
(
command_executor
*
e
,
size_t
leng
th
)
void
print_help
(
command_executor
*
e
,
size_t
name_width
,
size_t
option_wid
th
)
{
int
padding
=
length
-
strlen
(
e
->
name
);
std
::
cout
<<
"
\t
"
<<
e
->
name
<<
": "
;
for
(
int
i
=
0
;
i
<
padding
;
++
i
)
std
::
cout
<<
" "
;
std
::
cout
<<
e
->
name
<<
" "
<<
e
->
option_usage
<<
std
::
endl
;
std
::
vector
<
std
::
string
>
lines
;
std
::
string
options
(
e
->
option_usage
);
int
line_start
=
0
;
int
line_end
=
-
1
;
int
i
;
for
(
i
=
0
;
i
<
options
.
size
();
i
++
)
{
if
(
i
-
line_start
>=
option_width
&&
line_end
>=
line_start
)
{
std
::
string
s
=
options
.
substr
(
line_start
,
line_end
-
line_start
+
1
);
std
::
string
r
=
dsn
::
utils
::
trim_string
((
char
*
)
s
.
c_str
());
if
(
!
r
.
empty
())
lines
.
push_back
(
r
);
line_start
=
line_end
+
2
;
}
if
((
options
[
i
]
==
']'
||
options
[
i
]
==
'>'
)
&&
i
<
options
.
size
()
-
1
&&
options
[
i
+
1
]
==
' '
)
{
line_end
=
i
;
}
}
line_end
=
i
-
1
;
if
(
line_end
>=
line_start
)
{
std
::
string
s
=
options
.
substr
(
line_start
,
line_end
-
line_start
+
1
);
std
::
string
r
=
dsn
::
utils
::
trim_string
((
char
*
)
s
.
c_str
());
if
(
!
r
.
empty
())
lines
.
push_back
(
r
);
}
std
::
cout
<<
"
\t
"
<<
e
->
name
<<
std
::
string
(
name_width
+
2
-
strlen
(
e
->
name
),
' '
);
if
(
lines
.
empty
())
{
std
::
cout
<<
std
::
endl
;
}
else
{
for
(
int
k
=
0
;
k
<
lines
.
size
();
k
++
)
{
if
(
k
!=
0
)
std
::
cout
<<
"
\t
"
<<
std
::
string
(
name_width
+
2
,
' '
);
std
::
cout
<<
lines
[
k
]
<<
std
::
endl
;
}
}
}
void
print_help
()
{
std
::
cout
<<
"Usage:"
<<
std
::
endl
;
for
(
int
i
=
0
;
commands
[
i
].
name
!=
nullptr
;
++
i
)
{
print_help
(
&
commands
[
i
],
max_leng
th
);
print_help
(
&
commands
[
i
],
s_max_name_length
,
s_option_wid
th
);
}
}
void
register_all_commands
()
{
for
(
int
i
=
0
;
commands
[
i
].
name
!=
nullptr
;
++
i
)
{
auto
pr
=
commands_map
.
emplace
(
commands
[
i
].
name
,
&
commands
[
i
]);
auto
pr
=
s_
commands_map
.
emplace
(
commands
[
i
].
name
,
&
commands
[
i
]);
dassert
(
pr
.
second
,
"the command '%s' is already registered!!!"
,
commands
[
i
].
name
);
max_length
=
std
::
max
(
max
_length
,
strlen
(
commands
[
i
].
name
));
s_max_name_length
=
std
::
max
(
s_max_name
_length
,
strlen
(
commands
[
i
].
name
));
}
}
void
execute_command
(
command_executor
*
e
,
int
argc
,
std
::
string
str_args
[])
{
static
char
buffer
[
max_params_count
][
512
];
// 512*32
static
char
*
argv
[
max_params_count
];
for
(
int
i
=
0
;
i
<
max_params_count
;
++
i
)
{
static
char
buffer
[
s_
max_params_count
][
512
];
// 512*32
static
char
*
argv
[
s_
max_params_count
];
for
(
int
i
=
0
;
i
<
s_
max_params_count
;
++
i
)
{
argv
[
i
]
=
buffer
[
i
];
}
for
(
int
i
=
0
;
i
<
argc
&&
i
<
max_params_count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
argc
&&
i
<
s_
max_params_count
;
++
i
)
{
if
(
!
str_args
[
i
].
empty
())
{
strcpy
(
argv
[
i
],
str_args
[
i
].
c_str
());
}
else
{
...
...
@@ -395,9 +419,9 @@ void execute_command(command_executor *e, int argc, std::string str_args[])
}
}
if
(
!
e
->
exec
(
e
,
&
global_context
,
{
argc
,
argv
}))
{
if
(
!
e
->
exec
(
e
,
&
s_
global_context
,
{
argc
,
argv
}))
{
printf
(
"USAGE: "
);
print_help
(
e
,
max_leng
th
);
print_help
(
e
,
s_max_name_length
,
s_option_wid
th
);
}
}
...
...
@@ -433,16 +457,16 @@ void initialize(int argc, char **argv)
std
::
string
cluster_name
=
argc
>
2
?
argv
[
2
]
:
"mycluster"
;
std
::
cout
<<
"The cluster name is: "
<<
cluster_name
<<
std
::
endl
;
global_context
.
current_cluster_name
=
cluster_name
;
std
::
string
section
=
"uri-resolver.dsn://"
+
global_context
.
current_cluster_name
;
s_
global_context
.
current_cluster_name
=
cluster_name
;
std
::
string
section
=
"uri-resolver.dsn://"
+
s_
global_context
.
current_cluster_name
;
std
::
string
key
=
"arguments"
;
std
::
string
server_list
=
dsn_config_get_value_string
(
section
.
c_str
(),
key
.
c_str
(),
""
,
""
);
std
::
cout
<<
"The cluster meta list is: "
<<
server_list
<<
std
::
endl
;
dsn
::
replication
::
replica_helper
::
load_meta_servers
(
global_context
.
meta_list
,
section
.
c_str
(),
key
.
c_str
());
global_context
.
ddl_client
=
new
dsn
::
replication
::
replication_ddl_client
(
global_context
.
meta_list
);
s_
global_context
.
meta_list
,
section
.
c_str
(),
key
.
c_str
());
s_
global_context
.
ddl_client
=
new
dsn
::
replication
::
replication_ddl_client
(
s_
global_context
.
meta_list
);
register_all_commands
();
}
...
...
@@ -454,8 +478,8 @@ void run()
while
(
true
)
{
int
arg_count
;
std
::
string
args
[
max_params_count
];
scanfCommand
(
arg_count
,
args
,
max_params_count
);
std
::
string
args
[
s_
max_params_count
];
scanfCommand
(
arg_count
,
args
,
s_
max_params_count
);
if
(
arg_count
>
0
)
{
int
i
=
0
;
for
(;
i
<
arg_count
;
++
i
)
{
...
...
@@ -473,8 +497,8 @@ void run()
}
if
(
i
<
arg_count
)
continue
;
auto
iter
=
commands_map
.
find
(
args
[
0
]);
if
(
iter
!=
commands_map
.
end
())
{
auto
iter
=
s_
commands_map
.
find
(
args
[
0
]);
if
(
iter
!=
s_
commands_map
.
end
())
{
execute_command
(
iter
->
second
,
arg_count
,
args
);
}
else
{
std
::
cout
<<
"ERROR: invalid subcommand '"
<<
args
[
0
]
<<
"'"
<<
std
::
endl
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录