Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
1f066c60
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 搜索 >>
未验证
提交
1f066c60
编写于
7月 21, 2020
作者:
小地鼠家的小松鼠
提交者:
GitHub
7月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(bulk-load): add bulk load shell command (#561)
上级
418548da
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
229 addition
and
1 deletion
+229
-1
rdsn
rdsn
+1
-1
src/shell/commands.h
src/shell/commands.h
+12
-0
src/shell/commands/bulk_load.cpp
src/shell/commands/bulk_load.cpp
+192
-0
src/shell/main.cpp
src/shell/main.cpp
+24
-0
未找到文件。
rdsn
@
e32ce21c
比较
31637897
...
e32ce21c
Subproject commit
31637897ebb4774415a94c89c3475a03a4f120e4
Subproject commit
e32ce21c00b9492991533d1b545faf79076abc55
src/shell/commands.h
浏览文件 @
1f066c60
...
...
@@ -250,3 +250,15 @@ bool set_dup_fail_mode(command_executor *e, shell_context *sc, arguments args);
bool
query_disk_capacity
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
);
bool
query_disk_replica
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
);
// == 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
);
src/shell/commands/bulk_load.cpp
0 → 100644
浏览文件 @
1f066c60
// Copyright (c) 2019, 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.
#include "shell/commands.h"
bool
start_bulk_load
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
static
struct
option
long_options
[]
=
{{
"app_name"
,
required_argument
,
0
,
'a'
},
{
"cluster_name"
,
required_argument
,
0
,
'c'
},
{
"file_provider_type"
,
required_argument
,
0
,
'p'
},
{
0
,
0
,
0
,
0
}};
std
::
string
app_name
;
std
::
string
cluster_name
;
std
::
string
file_provider_type
;
optind
=
0
;
while
(
true
)
{
int
option_index
=
0
;
int
c
;
c
=
getopt_long
(
args
.
argc
,
args
.
argv
,
"a:c:p:"
,
long_options
,
&
option_index
);
if
(
c
==
-
1
)
break
;
switch
(
c
)
{
case
'a'
:
app_name
=
optarg
;
break
;
case
'c'
:
cluster_name
=
optarg
;
break
;
case
'p'
:
file_provider_type
=
optarg
;
break
;
default:
return
false
;
}
}
if
(
app_name
.
empty
())
{
fprintf
(
stderr
,
"app_name should not be empty
\n
"
);
return
false
;
}
if
(
cluster_name
.
empty
())
{
fprintf
(
stderr
,
"cluster_name should not be empty
\n
"
);
return
false
;
}
if
(
file_provider_type
.
empty
())
{
fprintf
(
stderr
,
"file_provider_type should not be empty
\n
"
);
return
false
;
}
auto
err_resp
=
sc
->
ddl_client
->
start_bulk_load
(
app_name
,
cluster_name
,
file_provider_type
);
dsn
::
error_s
err
=
err_resp
.
get_error
();
std
::
string
hint_msg
;
if
(
err
.
is_ok
())
{
err
=
dsn
::
error_s
::
make
(
err_resp
.
get_value
().
err
);
hint_msg
=
err_resp
.
get_value
().
hint_msg
;
}
if
(
!
err
.
is_ok
())
{
fmt
::
print
(
stderr
,
"start bulk load failed, error={} [hint:
\"
{}
\"
]
\n
"
,
err
,
hint_msg
);
}
else
{
fmt
::
print
(
stdout
,
"start bulk load succeed
\n
"
);
}
return
true
;
}
// helper function for pause/restart bulk load
bool
control_bulk_load_helper
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
,
dsn
::
replication
::
bulk_load_control_type
::
type
type
)
{
if
(
type
!=
dsn
::
replication
::
bulk_load_control_type
::
BLC_PAUSE
&&
type
!=
dsn
::
replication
::
bulk_load_control_type
::
BLC_RESTART
)
{
return
false
;
}
static
struct
option
long_options
[]
=
{{
"app_name"
,
required_argument
,
0
,
'a'
},
{
0
,
0
,
0
,
0
}};
std
::
string
app_name
;
optind
=
0
;
while
(
true
)
{
int
option_index
=
0
;
int
c
;
c
=
getopt_long
(
args
.
argc
,
args
.
argv
,
"a:"
,
long_options
,
&
option_index
);
if
(
c
==
-
1
)
break
;
switch
(
c
)
{
case
'a'
:
app_name
=
optarg
;
break
;
default:
return
false
;
}
}
if
(
app_name
.
empty
())
{
fprintf
(
stderr
,
"app_name should not be empty
\n
"
);
return
false
;
}
auto
err_resp
=
sc
->
ddl_client
->
control_bulk_load
(
app_name
,
type
);
dsn
::
error_s
err
=
err_resp
.
get_error
();
std
::
string
hint_msg
;
if
(
err
.
is_ok
())
{
err
=
dsn
::
error_s
::
make
(
err_resp
.
get_value
().
err
);
hint_msg
=
err_resp
.
get_value
().
hint_msg
;
}
std
::
string
type_str
=
type
==
dsn
::
replication
::
bulk_load_control_type
::
BLC_PAUSE
?
"pause"
:
"restart"
;
if
(
!
err
.
is_ok
())
{
fmt
::
print
(
stderr
,
"{} bulk load failed, error={} [hint:
\"
{}
\"
]
\n
"
,
type_str
,
err
,
hint_msg
);
}
else
{
fmt
::
print
(
stdout
,
"{} bulk load succeed
\n
"
,
type_str
);
}
return
true
;
}
bool
pause_bulk_load
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
return
control_bulk_load_helper
(
e
,
sc
,
args
,
dsn
::
replication
::
bulk_load_control_type
::
BLC_PAUSE
);
}
bool
restart_bulk_load
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
return
control_bulk_load_helper
(
e
,
sc
,
args
,
dsn
::
replication
::
bulk_load_control_type
::
BLC_RESTART
);
}
bool
cancel_bulk_load
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
static
struct
option
long_options
[]
=
{
{
"app_name"
,
required_argument
,
0
,
'a'
},
{
"forced"
,
no_argument
,
0
,
'f'
},
{
0
,
0
,
0
,
0
}};
std
::
string
app_name
;
bool
forced
=
false
;
optind
=
0
;
while
(
true
)
{
int
option_index
=
0
;
int
c
;
c
=
getopt_long
(
args
.
argc
,
args
.
argv
,
"a:f"
,
long_options
,
&
option_index
);
if
(
c
==
-
1
)
break
;
switch
(
c
)
{
case
'a'
:
app_name
=
optarg
;
break
;
case
'f'
:
forced
=
true
;
break
;
default:
return
false
;
}
}
if
(
app_name
.
empty
())
{
fprintf
(
stderr
,
"app_name should not be empty
\n
"
);
return
false
;
}
auto
type
=
forced
?
dsn
::
replication
::
bulk_load_control_type
::
BLC_FORCE_CANCEL
:
dsn
::
replication
::
bulk_load_control_type
::
BLC_CANCEL
;
auto
err_resp
=
sc
->
ddl_client
->
control_bulk_load
(
app_name
,
type
);
dsn
::
error_s
err
=
err_resp
.
get_error
();
std
::
string
hint_msg
;
if
(
err
.
is_ok
())
{
err
=
dsn
::
error_s
::
make
(
err_resp
.
get_value
().
err
);
hint_msg
=
err_resp
.
get_value
().
hint_msg
;
}
if
(
!
err
.
is_ok
())
{
fmt
::
print
(
stderr
,
"cancel bulk load failed, error={} [hint:
\"
{}
\"
]
\n
"
,
err
,
hint_msg
);
if
(
err
.
code
()
==
dsn
::
ERR_INVALID_STATE
&&
type
==
dsn
::
replication
::
bulk_load_control_type
::
BLC_CANCEL
)
{
fmt
::
print
(
stderr
,
"you can force cancel bulk load by using
\"
-f
\"\n
"
);
}
}
else
{
fmt
::
print
(
stdout
,
"cancel bulk load succeed
\n
"
);
}
return
true
;
}
bool
query_bulk_load_status
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
// TODO(heyuchen): TBD
return
true
;
}
src/shell/main.cpp
浏览文件 @
1f066c60
...
...
@@ -450,6 +450,30 @@ static command_executor commands[] = {
"set fail_mode of duplication"
,
"<app_name> <dup_id> <slow|skip>"
,
set_dup_fail_mode
},
{
"start_bulk_load"
,
"start app bulk load"
,
"<-a --app_name str> <-c --cluster_name str> <-p --file_provider_type str>"
,
start_bulk_load
,
},
{
"query_bulk_load_status"
,
"query app bulk load status"
,
"<-a --app_name str> [-i --partition_index num] [-d --detailed]"
,
query_bulk_load_status
,
},
{
"pause_bulk_load"
,
"pause app bulk load"
,
"<-a --app_name str>"
,
pause_bulk_load
,
},
{
"restart_bulk_load"
,
"restart app bulk load"
,
"<-a --app_name str>"
,
restart_bulk_load
,
},
{
"cancel_bulk_load"
,
"cancel app bulk load"
,
"<-a --app_name str> [-f --forced]"
,
cancel_bulk_load
,
},
{
"exit"
,
"exit shell"
,
""
,
exit_shell
,
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录