Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
e5fcffd5
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 搜索 >>
未验证
提交
e5fcffd5
编写于
9月 20, 2019
作者:
W
Wu Tao
提交者:
GitHub
9月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(shell): add debugging commands for hex and escaped-string conversion (#395)
上级
da4bc679
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
1 deletion
+76
-1
src/shell/commands.h
src/shell/commands.h
+6
-1
src/shell/commands/debugger.cpp
src/shell/commands/debugger.cpp
+52
-0
src/shell/main.cpp
src/shell/main.cpp
+18
-0
未找到文件。
src/shell/commands.h
浏览文件 @
e5fcffd5
...
...
@@ -11,7 +11,6 @@
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <rocksdb/db.h>
#include <rocksdb/sst_dump_tool.h>
#include <dsn/utility/filesystem.h>
#include <dsn/utility/output_utils.h>
#include <dsn/utility/string_conv.h>
...
...
@@ -206,3 +205,9 @@ bool sst_dump(command_executor *e, shell_context *sc, arguments args);
bool
mlog_dump
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
);
bool
local_get
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
);
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
);
src/shell/commands/debugger.cpp
浏览文件 @
e5fcffd5
...
...
@@ -3,6 +3,9 @@
// can be found in the LICENSE file in the root directory of this source tree.
#include "shell/commands.h"
#include <rocksdb/sst_dump_tool.h>
#include <rocksdb/utilities/ldb_cmd.h>
#include <fmt/time.h>
bool
sst_dump
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
...
...
@@ -189,3 +192,52 @@ bool local_get(command_executor *e, shell_context *sc, arguments args)
delete
db
;
return
true
;
}
bool
rdb_key_str2hex
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
if
(
args
.
argc
!=
3
)
{
return
false
;
}
std
::
string
hash_key
=
sds_to_string
(
args
.
argv
[
1
]);
std
::
string
sort_key
=
sds_to_string
(
args
.
argv
[
2
]);
::
dsn
::
blob
key
;
pegasus
::
pegasus_generate_key
(
key
,
hash_key
,
sort_key
);
rocksdb
::
Slice
skey
(
key
.
data
(),
key
.
length
());
fprintf
(
stderr
,
"
\"
%s
\"\n
"
,
skey
.
ToString
(
true
).
c_str
());
return
true
;
}
bool
rdb_key_hex2str
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
if
(
args
.
argc
!=
2
)
{
return
false
;
}
std
::
string
hex_rdb_key
=
sds_to_string
(
args
.
argv
[
1
]);
dsn
::
blob
key
=
dsn
::
blob
::
create_from_bytes
(
rocksdb
::
LDBCommand
::
HexToString
(
hex_rdb_key
));
std
::
string
hash_key
,
sort_key
;
pegasus
::
pegasus_restore_key
(
key
,
hash_key
,
sort_key
);
fmt
::
print
(
stderr
,
"
\n
hash key:
\"
{}
\"\n
"
,
pegasus
::
utils
::
c_escape_string
(
hash_key
,
sc
->
escape_all
));
fmt
::
print
(
stderr
,
"
\n
sort key:
\"
{}
\"\n
"
,
pegasus
::
utils
::
c_escape_string
(
sort_key
,
sc
->
escape_all
));
return
true
;
}
bool
rdb_value_hex2str
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
if
(
args
.
argc
!=
2
)
{
return
false
;
}
std
::
string
hex_rdb_value
=
sds_to_string
(
args
.
argv
[
1
]);
std
::
string
pegasus_value
=
rocksdb
::
LDBCommand
::
HexToString
(
hex_rdb_value
);
auto
expire_ts
=
static_cast
<
int64_t
>
(
pegasus
::
pegasus_extract_expire_ts
(
0
,
pegasus_value
))
+
pegasus
::
utils
::
epoch_begin
;
// TODO(wutao): pass user specified version
fmt
::
print
(
stderr
,
"
\n
When to expire:
\n
{:%Y-%m-%d %H:%M:%S}
\n
"
,
*
std
::
localtime
(
&
expire_ts
));
dsn
::
blob
user_data
;
pegasus
::
pegasus_extract_user_data
(
0
,
std
::
move
(
pegasus_value
),
user_data
);
fprintf
(
stderr
,
"user_data:
\n
\"
%s
\"\n
"
,
pegasus
::
utils
::
c_escape_string
(
user_data
.
to_string
(),
sc
->
escape_all
).
c_str
());
return
true
;
}
src/shell/main.cpp
浏览文件 @
e5fcffd5
...
...
@@ -325,6 +325,24 @@ static command_executor commands[] = {
{
"local_get"
,
"get value from local db"
,
"<db_path> <hash_key> <sort_key>"
,
local_get
,
},
{
"rdb_key_str2hex"
,
"transform the given hashkey and sortkey to rocksdb raw key in hex representation"
,
"<hash_key> <sort_key>"
,
rdb_key_str2hex
,
},
{
"rdb_key_hex2str"
,
"transform the given rocksdb raw key in hex representation to hash key and sort key"
,
"<rdb_key_in_hex>"
,
rdb_key_hex2str
,
},
{
"rdb_value_hex2str"
,
"parse the given rocksdb raw value in hex representation"
,
"<value_in_hex>"
,
rdb_value_hex2str
,
},
{
"sst_dump"
,
"dump sstable dir or files"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录