Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
3b96b264
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 搜索 >>
未验证
提交
3b96b264
编写于
10月 12, 2020
作者:
S
Smilencer
提交者:
GitHub
10月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(hotkey): build a fundamental framework of hotkey detection (#603)
上级
5a354292
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
149 addition
and
1 deletion
+149
-1
rdsn
rdsn
+1
-1
src/server/hotkey_collector.cpp
src/server/hotkey_collector.cpp
+37
-0
src/server/hotkey_collector.h
src/server/hotkey_collector.h
+75
-0
src/server/pegasus_server_impl.cpp
src/server/pegasus_server_impl.cpp
+24
-0
src/server/pegasus_server_impl.h
src/server/pegasus_server_impl.h
+7
-0
src/server/pegasus_server_impl_init.cpp
src/server/pegasus_server_impl_init.cpp
+4
-0
src/server/test/CMakeLists.txt
src/server/test/CMakeLists.txt
+1
-0
未找到文件。
rdsn
@
ccecd599
比较
69102a78
...
ccecd599
Subproject commit
69102a786f3b888155bc18b8b6c58031c7d2fd98
Subproject commit
ccecd5996a7b5c5b3281860186b30048a2ee4763
src/server/hotkey_collector.cpp
0 → 100644
浏览文件 @
3b96b264
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "hotkey_collector.h"
namespace
pegasus
{
namespace
server
{
// TODO: (Tangyanzhao) implement these functions
void
hotkey_collector
::
handle_rpc
(
const
dsn
::
replication
::
detect_hotkey_request
&
req
,
dsn
::
replication
::
detect_hotkey_response
&
resp
)
{
}
void
hotkey_collector
::
capture_raw_key
(
const
dsn
::
blob
&
raw_key
,
int64_t
weight
)
{
// TODO: (Tangyanzhao) Add a judgment sentence to check if it is a raw key
}
void
hotkey_collector
::
capture_hash_key
(
const
dsn
::
blob
&
hash_key
,
int64_t
weight
)
{}
}
// namespace server
}
// namespace pegasus
src/server/hotkey_collector.h
0 → 100644
浏览文件 @
3b96b264
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#pragma once
#include <dsn/utility/string_view.h>
#include <dsn/dist/replication/replication_types.h>
namespace
pegasus
{
namespace
server
{
// hotkey_collector is responsible to find the hot keys after the partition
// was detected to be hot. The two types of hotkey, READ & WRITE, are detected
// separately.
//
// +--------------------+ +----------------------------------------------------+
// | Replcia server | | Hotkey collector |
// | | | +-----------------------------------------------+ |
// | +----------------+ | | | Corase capture | |
// | | | |--> | +----------+ | |
// | | RPC received | || | | | Data | | |
// | | | || | | +-----+----+ | |
// | +-------+--------+ || | | | | |
// | | || | | +---------------+----v--+-------+---------+ | |
// | v || | | | |Hot | | | | | |
// | +-------+--------+ || | | |Bucket |Bucket |Bucket |Bucket |Bucket | | |
// | | Replication | || | | +-----------+-----------------------------+ | |
// | | (only on the | || | | | | |
// | | write path)) | || | +--------------|--------------------------------+ |
// | +-------+--------+ || | +--v---+ |
// | | || | | Data | |
// | v || | +------+ |
// | +-------+--------+ || | +-----|-------+-------------+ |
// | | | || | +------|-------------|-------------|---------+ |
// | | Capture data ---| | | Fine |capture | | | |
// | | | | | | | | | | |
// | +-------+--------+ | | | +----v----+ +----v----+ +----v----+ | |
// | | | | | | queue | | queue | | queue | | |
// | v | | | +----+----+ +----+----+ +----+----+ | |
// | +-------+--------+ | | | | | | | |
// | | | | | | +----v-------------v-------------v------+ | |
// | | Place data | | | | | Analsis pool | | |
// | | to the disk | | | | +-----------------|---------------------+ | |
// | | | | | +-------------------|------------------------+ |
// | +----------------+ | | v |
// | | | Hotkey |
// +--------------------+ +----------------------------------------------------+
class
hotkey_collector
{
public:
// TODO: (Tangyanzhao) capture_*_key should be consistent with hotspot detection
// weight: calculate the weight according to the specific situation
void
capture_raw_key
(
const
dsn
::
blob
&
raw_key
,
int64_t
weight
);
void
capture_hash_key
(
const
dsn
::
blob
&
hash_key
,
int64_t
weight
);
void
handle_rpc
(
const
dsn
::
replication
::
detect_hotkey_request
&
req
,
/*out*/
dsn
::
replication
::
detect_hotkey_response
&
resp
);
};
}
// namespace server
}
// namespace pegasus
src/server/pegasus_server_impl.cpp
浏览文件 @
3b96b264
...
...
@@ -22,6 +22,7 @@
#include "capacity_unit_calculator.h"
#include "pegasus_server_write.h"
#include "meta_store.h"
#include "hotkey_collector.h"
using
namespace
dsn
::
literals
::
chrono_literals
;
...
...
@@ -2798,5 +2799,28 @@ void pegasus_server_impl::set_ingestion_status(dsn::replication::ingestion_statu
_ingestion_status
=
status
;
}
void
pegasus_server_impl
::
on_detect_hotkey
(
const
dsn
::
replication
::
detect_hotkey_request
&
req
,
dsn
::
replication
::
detect_hotkey_response
&
resp
)
{
if
(
dsn_unlikely
(
req
.
action
!=
dsn
::
replication
::
detect_action
::
START
&&
req
.
action
!=
dsn
::
replication
::
detect_action
::
STOP
))
{
resp
.
err
=
dsn
::
ERR_INVALID_PARAMETERS
;
resp
.
__set_err_hint
(
"invalid detect_action"
);
return
;
}
if
(
dsn_unlikely
(
req
.
type
!=
dsn
::
replication
::
hotkey_type
::
READ
&&
req
.
type
!=
dsn
::
replication
::
hotkey_type
::
WRITE
))
{
resp
.
err
=
dsn
::
ERR_INVALID_PARAMETERS
;
resp
.
__set_err_hint
(
"invalid hotkey_type"
);
return
;
}
auto
collector
=
req
.
type
==
dsn
::
replication
::
hotkey_type
::
READ
?
_read_hotkey_collector
:
_write_hotkey_collector
;
collector
->
handle_rpc
(
req
,
resp
);
}
}
// namespace server
}
// namespace pegasus
src/server/pegasus_server_impl.h
浏览文件 @
3b96b264
...
...
@@ -28,6 +28,7 @@ namespace server {
class
meta_store
;
class
capacity_unit_calculator
;
class
pegasus_server_write
;
class
hotkey_collector
;
class
pegasus_server_impl
:
public
pegasus_read_service
{
...
...
@@ -318,6 +319,9 @@ private:
::
dsn
::
error_code
flush_all_family_columns
(
bool
wait
);
void
on_detect_hotkey
(
const
dsn
::
replication
::
detect_hotkey_request
&
req
,
dsn
::
replication
::
detect_hotkey_response
&
resp
)
override
;
private:
static
const
std
::
chrono
::
seconds
kServerStatUpdateTimeSec
;
static
const
std
::
string
COMPRESSION_HEADER
;
...
...
@@ -382,6 +386,9 @@ private:
dsn
::
task_tracker
_tracker
;
std
::
shared_ptr
<
hotkey_collector
>
_read_hotkey_collector
;
std
::
shared_ptr
<
hotkey_collector
>
_write_hotkey_collector
;
// perf counters
::
dsn
::
perf_counter_wrapper
_pfc_get_qps
;
::
dsn
::
perf_counter_wrapper
_pfc_multi_get_qps
;
...
...
src/server/pegasus_server_impl_init.cpp
浏览文件 @
3b96b264
...
...
@@ -12,6 +12,7 @@
#include "meta_store.h"
#include "pegasus_event_listener.h"
#include "pegasus_server_write.h"
#include "hotkey_collector.h"
namespace
pegasus
{
namespace
server
{
...
...
@@ -42,6 +43,9 @@ pegasus_server_impl::pegasus_server_impl(dsn::replication::replica *r)
_primary_address
=
dsn
::
rpc_address
(
dsn_primary_address
()).
to_string
();
_gpid
=
get_gpid
();
_read_hotkey_collector
=
std
::
make_shared
<
hotkey_collector
>
();
_write_hotkey_collector
=
std
::
make_shared
<
hotkey_collector
>
();
_verbose_log
=
dsn_config_get_value_bool
(
"pegasus.server"
,
"rocksdb_verbose_log"
,
false
,
...
...
src/server/test/CMakeLists.txt
浏览文件 @
3b96b264
...
...
@@ -10,6 +10,7 @@ set(MY_PROJ_SRC "../pegasus_server_impl.cpp"
"../pegasus_mutation_duplicator.cpp"
"../hotspot_partition_calculator.cpp"
"../meta_store.cpp"
"../hotkey_collector.cpp"
)
set
(
MY_SRC_SEARCH_MODE
"GLOB"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录