Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
412492d3
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 搜索 >>
未验证
提交
412492d3
编写于
9月 16, 2020
作者:
S
Smilencer
提交者:
GitHub
9月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(hotspot): add a function to start hotkey detecting in hotspot_partition_calculator (#601)
上级
e56690c2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
79 addition
and
21 deletion
+79
-21
src/base/rrdb_types.cpp
src/base/rrdb_types.cpp
+12
-12
src/idl/rrdb.thrift
src/idl/rrdb.thrift
+1
-1
src/include/rrdb/rrdb_types.h
src/include/rrdb/rrdb_types.h
+6
-8
src/server/hotspot_partition_calculator.cpp
src/server/hotspot_partition_calculator.cpp
+54
-0
src/server/hotspot_partition_calculator.h
src/server/hotspot_partition_calculator.h
+4
-0
src/server/pegasus_read_service.h
src/server/pegasus_read_service.h
+2
-0
未找到文件。
src/base/rrdb_types.cpp
浏览文件 @
412492d3
...
...
@@ -4608,9 +4608,9 @@ hotkey_detect_request::~hotkey_detect_request() throw() {}
void
hotkey_detect_request
::
__set_type
(
const
hotkey_type
::
type
val
)
{
this
->
type
=
val
;
}
void
hotkey_detect_request
::
__set_
opera
tion
(
const
hotkey_detect_action
::
type
val
)
void
hotkey_detect_request
::
__set_
ac
tion
(
const
hotkey_detect_action
::
type
val
)
{
this
->
opera
tion
=
val
;
this
->
ac
tion
=
val
;
}
uint32_t
hotkey_detect_request
::
read
(
::
apache
::
thrift
::
protocol
::
TProtocol
*
iprot
)
...
...
@@ -4646,8 +4646,8 @@ uint32_t hotkey_detect_request::read(::apache::thrift::protocol::TProtocol *ipro
if
(
ftype
==
::
apache
::
thrift
::
protocol
::
T_I32
)
{
int32_t
ecast135
;
xfer
+=
iprot
->
readI32
(
ecast135
);
this
->
opera
tion
=
(
hotkey_detect_action
::
type
)
ecast135
;
this
->
__isset
.
opera
tion
=
true
;
this
->
ac
tion
=
(
hotkey_detect_action
::
type
)
ecast135
;
this
->
__isset
.
ac
tion
=
true
;
}
else
{
xfer
+=
iprot
->
skip
(
ftype
);
}
...
...
@@ -4674,8 +4674,8 @@ uint32_t hotkey_detect_request::write(::apache::thrift::protocol::TProtocol *opr
xfer
+=
oprot
->
writeI32
((
int32_t
)
this
->
type
);
xfer
+=
oprot
->
writeFieldEnd
();
xfer
+=
oprot
->
writeFieldBegin
(
"
opera
tion"
,
::
apache
::
thrift
::
protocol
::
T_I32
,
2
);
xfer
+=
oprot
->
writeI32
((
int32_t
)
this
->
opera
tion
);
xfer
+=
oprot
->
writeFieldBegin
(
"
ac
tion"
,
::
apache
::
thrift
::
protocol
::
T_I32
,
2
);
xfer
+=
oprot
->
writeI32
((
int32_t
)
this
->
ac
tion
);
xfer
+=
oprot
->
writeFieldEnd
();
xfer
+=
oprot
->
writeFieldStop
();
...
...
@@ -4687,33 +4687,33 @@ void swap(hotkey_detect_request &a, hotkey_detect_request &b)
{
using
::
std
::
swap
;
swap
(
a
.
type
,
b
.
type
);
swap
(
a
.
operation
,
b
.
opera
tion
);
swap
(
a
.
action
,
b
.
ac
tion
);
swap
(
a
.
__isset
,
b
.
__isset
);
}
hotkey_detect_request
::
hotkey_detect_request
(
const
hotkey_detect_request
&
other136
)
{
type
=
other136
.
type
;
operation
=
other136
.
opera
tion
;
action
=
other136
.
ac
tion
;
__isset
=
other136
.
__isset
;
}
hotkey_detect_request
::
hotkey_detect_request
(
hotkey_detect_request
&&
other137
)
{
type
=
std
::
move
(
other137
.
type
);
operation
=
std
::
move
(
other137
.
opera
tion
);
action
=
std
::
move
(
other137
.
ac
tion
);
__isset
=
std
::
move
(
other137
.
__isset
);
}
hotkey_detect_request
&
hotkey_detect_request
::
operator
=
(
const
hotkey_detect_request
&
other138
)
{
type
=
other138
.
type
;
operation
=
other138
.
opera
tion
;
action
=
other138
.
ac
tion
;
__isset
=
other138
.
__isset
;
return
*
this
;
}
hotkey_detect_request
&
hotkey_detect_request
::
operator
=
(
hotkey_detect_request
&&
other139
)
{
type
=
std
::
move
(
other139
.
type
);
operation
=
std
::
move
(
other139
.
opera
tion
);
action
=
std
::
move
(
other139
.
ac
tion
);
__isset
=
std
::
move
(
other139
.
__isset
);
return
*
this
;
}
...
...
@@ -4723,7 +4723,7 @@ void hotkey_detect_request::printTo(std::ostream &out) const
out
<<
"hotkey_detect_request("
;
out
<<
"type="
<<
to_string
(
type
);
out
<<
", "
<<
"
operation="
<<
to_string
(
opera
tion
);
<<
"
action="
<<
to_string
(
ac
tion
);
out
<<
")"
;
}
...
...
src/idl/rrdb.thrift
浏览文件 @
412492d3
...
...
@@ -293,7 +293,7 @@ struct duplicate_response
struct hotkey_detect_request {
1: hotkey_type type
2: hotkey_detect_action
opera
tion
2: hotkey_detect_action
ac
tion
}
struct hotkey_detect_response {
...
...
src/include/rrdb/rrdb_types.h
浏览文件 @
412492d3
...
...
@@ -1967,9 +1967,9 @@ inline std::ostream &operator<<(std::ostream &out, const duplicate_response &obj
typedef
struct
_hotkey_detect_request__isset
{
_hotkey_detect_request__isset
()
:
type
(
false
),
opera
tion
(
false
)
{}
_hotkey_detect_request__isset
()
:
type
(
false
),
ac
tion
(
false
)
{}
bool
type
:
1
;
bool
opera
tion
:
1
;
bool
ac
tion
:
1
;
}
_hotkey_detect_request__isset
;
class
hotkey_detect_request
...
...
@@ -1979,25 +1979,23 @@ public:
hotkey_detect_request
(
hotkey_detect_request
&&
);
hotkey_detect_request
&
operator
=
(
const
hotkey_detect_request
&
);
hotkey_detect_request
&
operator
=
(
hotkey_detect_request
&&
);
hotkey_detect_request
()
:
type
((
hotkey_type
::
type
)
0
),
operation
((
hotkey_detect_action
::
type
)
0
)
{
}
hotkey_detect_request
()
:
type
((
hotkey_type
::
type
)
0
),
action
((
hotkey_detect_action
::
type
)
0
)
{}
virtual
~
hotkey_detect_request
()
throw
();
hotkey_type
::
type
type
;
hotkey_detect_action
::
type
opera
tion
;
hotkey_detect_action
::
type
ac
tion
;
_hotkey_detect_request__isset
__isset
;
void
__set_type
(
const
hotkey_type
::
type
val
);
void
__set_
opera
tion
(
const
hotkey_detect_action
::
type
val
);
void
__set_
ac
tion
(
const
hotkey_detect_action
::
type
val
);
bool
operator
==
(
const
hotkey_detect_request
&
rhs
)
const
{
if
(
!
(
type
==
rhs
.
type
))
return
false
;
if
(
!
(
operation
==
rhs
.
opera
tion
))
if
(
!
(
action
==
rhs
.
ac
tion
))
return
false
;
return
true
;
}
...
...
src/server/hotspot_partition_calculator.cpp
浏览文件 @
412492d3
...
...
@@ -21,6 +21,13 @@
#include <math.h>
#include <dsn/dist/fmt_logging.h>
#include <dsn/utility/flags.h>
#include <dsn/tool-api/rpc_address.h>
#include <dsn/tool-api/group_address.h>
#include <dsn/utility/error_code.h>
#include <rrdb/rrdb_types.h>
#include <dsn/dist/replication/duplication_common.h>
#include <dsn/tool-api/task_tracker.h>
#include "pegasus_read_service.h"
namespace
pegasus
{
namespace
server
{
...
...
@@ -98,5 +105,52 @@ void hotspot_partition_calculator::data_analyse()
}
}
// TODO:(TangYanzhao) call this function to start hotkey detection
/*static*/
void
hotspot_partition_calculator
::
send_hotkey_detect_request
(
const
std
::
string
&
app_name
,
const
uint64_t
partition_index
,
const
dsn
::
apps
::
hotkey_type
::
type
hotkey_type
,
const
dsn
::
apps
::
hotkey_detect_action
::
type
action
)
{
auto
request
=
std
::
make_unique
<
dsn
::
apps
::
hotkey_detect_request
>
();
request
->
type
=
hotkey_type
;
request
->
action
=
action
;
ddebug_f
(
"{} {} hotkey detection in {}.{}"
,
(
action
==
dsn
::
apps
::
hotkey_detect_action
::
STOP
)
?
"Stop"
:
"Start"
,
(
hotkey_type
==
dsn
::
apps
::
hotkey_type
::
WRITE
)
?
"write"
:
"read"
,
app_name
,
partition_index
);
dsn
::
rpc_address
meta_server
;
meta_server
.
assign_group
(
"meta-servers"
);
std
::
vector
<
dsn
::
rpc_address
>
meta_servers
;
replica_helper
::
load_meta_servers
(
meta_servers
);
for
(
const
auto
&
address
:
meta_servers
)
{
meta_server
.
group_address
()
->
add
(
address
);
}
auto
cluster_name
=
dsn
::
replication
::
get_current_cluster_name
();
auto
resolver
=
partition_resolver
::
get_resolver
(
cluster_name
,
meta_servers
,
app_name
.
c_str
());
dsn
::
task_tracker
tracker
;
detect_hotkey_rpc
rpc
(
std
::
move
(
request
),
RPC_DETECT_HOTKEY
,
std
::
chrono
::
seconds
(
10
),
partition_index
);
rpc
.
call
(
resolver
,
&
tracker
,
[
app_name
,
partition_index
](
dsn
::
error_code
error
)
{
if
(
error
!=
dsn
::
ERR_OK
)
{
derror_f
(
"Hotkey detect rpc sending failed, in {}.{}, error_hint:{}"
,
app_name
,
partition_index
,
error
.
to_string
());
}
})
->
wait
();
if
(
rpc
.
response
().
err
!=
dsn
::
ERR_OK
)
{
derror_f
(
"Hotkey detect rpc sending failed, in {}.{}, error_hint:{} {}"
,
app_name
,
partition_index
,
rpc
.
response
().
err
,
rpc
.
response
().
err_hint
);
}
}
}
// namespace server
}
// namespace pegasus
src/server/hotspot_partition_calculator.h
浏览文件 @
412492d3
...
...
@@ -37,6 +37,10 @@ public:
void
data_aggregate
(
const
std
::
vector
<
row_data
>
&
partitions
);
// analyse the saved data to find hotspot partition
void
data_analyse
();
static
void
send_hotkey_detect_request
(
const
std
::
string
&
app_name
,
const
uint64_t
partition_index
,
const
dsn
::
apps
::
hotkey_type
::
type
hotkey_type
,
const
dsn
::
apps
::
hotkey_detect_action
::
type
action
);
private:
const
std
::
string
_app_name
;
...
...
src/server/pegasus_read_service.h
浏览文件 @
412492d3
...
...
@@ -32,6 +32,8 @@ typedef ::dsn::rpc_holder<::dsn::blob, dsn::apps::ttl_response> ttl_rpc;
typedef
::
dsn
::
rpc_holder
<::
dsn
::
apps
::
get_scanner_request
,
dsn
::
apps
::
scan_response
>
get_scanner_rpc
;
typedef
::
dsn
::
rpc_holder
<::
dsn
::
apps
::
scan_request
,
dsn
::
apps
::
scan_response
>
scan_rpc
;
typedef
::
dsn
::
rpc_holder
<::
dsn
::
apps
::
hotkey_detect_request
,
dsn
::
apps
::
hotkey_detect_response
>
detect_hotkey_rpc
;
class
pegasus_read_service
:
public
dsn
::
replication
::
replication_app_base
,
public
dsn
::
replication
::
storage_serverlet
<
pegasus_read_service
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录