Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
aa133365
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,发现更多精彩内容 >>
提交
aa133365
编写于
1月 30, 2017
作者:
A
artpaul
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync
上级
706fe739
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
63 addition
and
8 deletion
+63
-8
dbms/include/DB/Interpreters/DDLWorker.h
dbms/include/DB/Interpreters/DDLWorker.h
+4
-2
dbms/src/Interpreters/DDLWorker.cpp
dbms/src/Interpreters/DDLWorker.cpp
+57
-4
dbms/src/Server/Server.cpp
dbms/src/Server/Server.cpp
+2
-2
未找到文件。
dbms/include/DB/Interpreters/DDLWorker.h
浏览文件 @
aa133365
...
...
@@ -16,7 +16,9 @@ namespace DB
class
DDLWorker
{
public:
DDLWorker
(
Context
*
ctx
,
const
std
::
string
&
host
,
int
port
);
DDLWorker
(
const
Poco
::
Util
::
AbstractConfiguration
&
config
,
const
std
::
string
&
config_name
,
Context
&
context_
,
const
std
::
string
&
host
,
int
port
);
~
DDLWorker
();
private:
...
...
@@ -26,7 +28,7 @@ private:
void
run
();
private:
Context
*
context
;
Context
&
context
;
std
::
string
local_addr
;
std
::
string
base_path
;
...
...
dbms/src/Interpreters/DDLWorker.cpp
浏览文件 @
aa133365
...
...
@@ -4,11 +4,64 @@
namespace
DB
{
DDLWorker
::
DDLWorker
(
Context
*
ctx
,
const
std
::
string
&
host
,
int
port
)
:
context
(
ctx
)
namespace
ErrorCodes
{
extern
const
int
UNKNOWN_ELEMENT_IN_CONFIG
;
extern
const
int
INVALID_CONFIG_PARAMETER
;
}
namespace
{
/// Helper class which extracts from the ClickHouse configuration file
/// the parameters we need for operating the resharding thread.
class
Arguments
final
{
public:
Arguments
(
const
Poco
::
Util
::
AbstractConfiguration
&
config
,
const
std
::
string
&
config_name
)
{
Poco
::
Util
::
AbstractConfiguration
::
Keys
keys
;
config
.
keys
(
config_name
,
keys
);
for
(
const
auto
&
key
:
keys
)
{
if
(
key
==
"task_queue_path"
)
task_queue_path
=
config
.
getString
(
config_name
+
"."
+
key
);
else
throw
Exception
{
"Unknown parameter in resharding configuration"
,
ErrorCodes
::
UNKNOWN_ELEMENT_IN_CONFIG
};
}
if
(
task_queue_path
.
empty
())
throw
Exception
{
"Resharding: missing parameter task_queue_path"
,
ErrorCodes
::
INVALID_CONFIG_PARAMETER
};
}
Arguments
(
const
Arguments
&
)
=
delete
;
Arguments
&
operator
=
(
const
Arguments
&
)
=
delete
;
std
::
string
getTaskQueuePath
()
const
{
return
task_queue_path
;
}
private:
std
::
string
task_queue_path
;
};
}
DDLWorker
::
DDLWorker
(
const
Poco
::
Util
::
AbstractConfiguration
&
config
,
const
std
::
string
&
config_name
,
Context
&
context_
,
const
std
::
string
&
host
,
int
port
)
:
context
(
context_
)
,
stop_flag
(
false
)
,
thread
(
&
DDLWorker
::
run
,
this
)
{
Arguments
arguments
(
config
,
config_name
);
auto
zookeeper
=
context
.
getZooKeeper
();
std
::
string
root
=
arguments
.
getTaskQueuePath
();
if
(
root
.
back
()
!=
'/'
)
root
+=
"/"
;
local_addr
=
host
+
":"
+
std
::
to_string
(
port
);
base_path
=
"/clickhouse/task_queue/ddl/"
;
}
...
...
@@ -26,7 +79,7 @@ void DDLWorker::processTasks() {
}
void
DDLWorker
::
processCreate
(
const
std
::
string
&
path
)
{
auto
zookeeper
=
context
->
getZooKeeper
();
auto
zookeeper
=
context
.
getZooKeeper
();
const
Strings
&
children
=
zookeeper
->
getChildren
(
path
);
for
(
const
auto
&
name
:
children
)
{
...
...
@@ -35,7 +88,7 @@ void DDLWorker::processCreate(const std::string & path) {
std
::
string
value
=
zookeeper
->
get
(
path
);
if
(
!
value
.
empty
())
{
executeQuery
(
value
,
*
context
);
executeQuery
(
value
,
context
);
}
zookeeper
->
remove
(
path
);
...
...
dbms/src/Server/Server.cpp
浏览文件 @
aa133365
...
...
@@ -377,9 +377,9 @@ int Server::main(const std::vector<std::string> & args)
has_resharding_worker
=
true
;
}
// TODO read from config
if
(
has_zookeeper
)
if
(
has_zookeeper
&&
config
().
has
(
"distributed_ddl"
)
)
{
auto
ddl_worker
=
std
::
make_shared
<
DDLWorker
>
(
global_context
.
get
()
,
"localhost"
,
9000
);
auto
ddl_worker
=
std
::
make_shared
<
DDLWorker
>
(
config
(),
"distributed_ddl"
,
*
global_context
,
"localhost"
,
9000
);
global_context
->
setDDLWorker
(
ddl_worker
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录