Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
749dd8d5
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
749dd8d5
编写于
2月 26, 2021
作者:
M
Maksim Kita
提交者:
GitHub
2月 26, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21193 from kitaisreal/storage-rabbit-mq-added-uvloop
StorageRabbitMQ added UVLoop
上级
5b72cd23
29e78399
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
10 deletion
+52
-10
src/Storages/RabbitMQ/StorageRabbitMQ.cpp
src/Storages/RabbitMQ/StorageRabbitMQ.cpp
+3
-5
src/Storages/RabbitMQ/StorageRabbitMQ.h
src/Storages/RabbitMQ/StorageRabbitMQ.h
+2
-1
src/Storages/RabbitMQ/UVLoop.h
src/Storages/RabbitMQ/UVLoop.h
+44
-0
src/Storages/RabbitMQ/WriteBufferToRabbitMQProducer.cpp
src/Storages/RabbitMQ/WriteBufferToRabbitMQProducer.cpp
+1
-3
src/Storages/RabbitMQ/WriteBufferToRabbitMQProducer.h
src/Storages/RabbitMQ/WriteBufferToRabbitMQProducer.h
+2
-1
未找到文件。
src/Storages/RabbitMQ/StorageRabbitMQ.cpp
浏览文件 @
749dd8d5
...
...
@@ -99,9 +99,7 @@ StorageRabbitMQ::StorageRabbitMQ(
,
unique_strbase
(
getRandomName
())
,
queue_size
(
std
::
max
(
QUEUE_SIZE
,
static_cast
<
uint32_t
>
(
getMaxBlockSize
())))
{
loop
=
std
::
make_unique
<
uv_loop_t
>
();
uv_loop_init
(
loop
.
get
());
event_handler
=
std
::
make_shared
<
RabbitMQHandler
>
(
loop
.
get
(),
log
);
event_handler
=
std
::
make_shared
<
RabbitMQHandler
>
(
loop
.
getLoop
(),
log
);
restoreConnection
(
false
);
StorageInMemoryMetadata
storage_metadata
;
...
...
@@ -498,7 +496,7 @@ bool StorageRabbitMQ::restoreConnection(bool reconnecting)
AMQP
::
Login
(
login_password
.
first
,
login_password
.
second
),
vhost
));
cnt_retries
=
0
;
while
(
!
connection
->
ready
()
&&
!
stream_cancelled
&&
++
cnt_retries
!=
RETRIES_MAX
)
while
(
!
connection
->
ready
()
&&
!
stream_cancelled
&&
cnt_retries
++
!=
RETRIES_MAX
)
{
event_handler
->
iterateLoop
();
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
CONNECT_SLEEP
));
...
...
@@ -653,7 +651,7 @@ void StorageRabbitMQ::shutdown()
connection
->
close
();
size_t
cnt_retries
=
0
;
while
(
!
connection
->
closed
()
&&
++
cnt_retries
!=
RETRIES_MAX
)
while
(
!
connection
->
closed
()
&&
cnt_retries
++
!=
RETRIES_MAX
)
event_handler
->
iterateLoop
();
/// Should actually force closure, if not yet closed, but it generates distracting error logs
...
...
src/Storages/RabbitMQ/StorageRabbitMQ.h
浏览文件 @
749dd8d5
...
...
@@ -9,6 +9,7 @@
#include <Storages/RabbitMQ/Buffer_fwd.h>
#include <Storages/RabbitMQ/RabbitMQHandler.h>
#include <Storages/RabbitMQ/RabbitMQSettings.h>
#include <Storages/RabbitMQ/UVLoop.h>
#include <Common/thread_local_rng.h>
#include <amqpcpp/libuv.h>
#include <uv.h>
...
...
@@ -96,7 +97,7 @@ private:
std
::
pair
<
String
,
String
>
login_password
;
String
vhost
;
std
::
unique_ptr
<
uv_loop_t
>
loop
;
UVLoop
loop
;
std
::
shared_ptr
<
RabbitMQHandler
>
event_handler
;
std
::
unique_ptr
<
AMQP
::
TcpConnection
>
connection
;
/// Connection for all consumers
...
...
src/Storages/RabbitMQ/UVLoop.h
0 → 100644
浏览文件 @
749dd8d5
#pragma once
#include <memory>
#include <boost/noncopyable.hpp>
#include <uv.h>
#include <Common/Exception.h>
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
SYSTEM_ERROR
;
}
/// RAII wrapper around uv event loop
class
UVLoop
:
public
boost
::
noncopyable
{
public:
UVLoop
()
:
loop_ptr
(
new
uv_loop_t
())
{
int
res
=
uv_loop_init
(
loop_ptr
.
get
());
if
(
res
!=
0
)
throw
Exception
(
"UVLoop could not initialize"
,
ErrorCodes
::
SYSTEM_ERROR
);
}
~
UVLoop
()
{
if
(
loop_ptr
)
uv_loop_close
(
loop_ptr
.
get
());
}
inline
uv_loop_t
*
getLoop
()
{
return
loop_ptr
.
get
();
}
inline
const
uv_loop_t
*
getLoop
()
const
{
return
loop_ptr
.
get
();
}
private:
std
::
unique_ptr
<
uv_loop_t
>
loop_ptr
;
};
}
src/Storages/RabbitMQ/WriteBufferToRabbitMQProducer.cpp
浏览文件 @
749dd8d5
...
...
@@ -57,9 +57,7 @@ WriteBufferToRabbitMQProducer::WriteBufferToRabbitMQProducer(
,
max_rows
(
rows_per_message
)
,
chunk_size
(
chunk_size_
)
{
loop
=
std
::
make_unique
<
uv_loop_t
>
();
uv_loop_init
(
loop
.
get
());
event_handler
=
std
::
make_unique
<
RabbitMQHandler
>
(
loop
.
get
(),
log
);
event_handler
=
std
::
make_unique
<
RabbitMQHandler
>
(
loop
.
getLoop
(),
log
);
if
(
setupConnection
(
false
))
{
...
...
src/Storages/RabbitMQ/WriteBufferToRabbitMQProducer.h
浏览文件 @
749dd8d5
...
...
@@ -7,6 +7,7 @@
#include <atomic>
#include <amqpcpp.h>
#include <Storages/RabbitMQ/RabbitMQHandler.h>
#include <Storages/RabbitMQ/UVLoop.h>
#include <Common/ConcurrentBoundedQueue.h>
#include <Core/BackgroundSchedulePool.h>
#include <Core/Names.h>
...
...
@@ -69,7 +70,7 @@ private:
AMQP
::
Table
key_arguments
;
BackgroundSchedulePool
::
TaskHolder
writing_task
;
std
::
unique_ptr
<
uv_loop_t
>
loop
;
UVLoop
loop
;
std
::
unique_ptr
<
RabbitMQHandler
>
event_handler
;
std
::
unique_ptr
<
AMQP
::
TcpConnection
>
connection
;
std
::
unique_ptr
<
AMQP
::
TcpChannel
>
producer_channel
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录