Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
16103456
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,发现更多精彩内容 >>
提交
16103456
编写于
8月 28, 2017
作者:
N
Nikolai Kochetov
提交者:
alexey-milovidov
8月 30, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added root and identity section to zookeeper configuration [#CLICKHOUSE-3031]
上级
495daffa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
9 deletion
+26
-9
dbms/src/Common/ZooKeeper/ZooKeeper.cpp
dbms/src/Common/ZooKeeper/ZooKeeper.cpp
+24
-7
dbms/src/Common/ZooKeeper/ZooKeeper.h
dbms/src/Common/ZooKeeper/ZooKeeper.h
+2
-2
未找到文件。
dbms/src/Common/ZooKeeper/ZooKeeper.cpp
浏览文件 @
16103456
...
...
@@ -71,7 +71,7 @@ void ZooKeeper::processCallback(zhandle_t * zh, int type, int state, const char
destroyContext
(
context
);
}
void
ZooKeeper
::
init
(
const
std
::
string
&
hosts_
,
int32_t
session_timeout_ms_
)
void
ZooKeeper
::
init
(
const
std
::
string
&
hosts_
,
const
std
::
string
&
identity
,
int32_t
session_timeout_ms_
)
{
log
=
&
Logger
::
get
(
"ZooKeeper"
);
zoo_set_debug_level
(
ZOO_LOG_LEVEL_ERROR
);
...
...
@@ -84,12 +84,21 @@ void ZooKeeper::init(const std::string & hosts_, int32_t session_timeout_ms_)
if
(
!
impl
)
throw
KeeperException
(
"Fail to initialize zookeeper. Hosts are "
+
hosts
);
default_acl
=
&
ZOO_OPEN_ACL_UNSAFE
;
if
(
!
identity
.
empty
())
{
auto
code
=
zoo_add_auth
(
impl
,
"digest"
,
identity
.
c_str
(),
static_cast
<
int
>
(
identity
.
size
()),
0
,
0
);
if
(
code
!=
ZOK
)
throw
KeeperException
(
"Zookeeper authentication failed. Hosts are "
+
hosts
,
code
);
default_acl
=
&
ZOO_CREATOR_ALL_ACL
;
}
else
default_acl
=
&
ZOO_OPEN_ACL_UNSAFE
;
}
ZooKeeper
::
ZooKeeper
(
const
std
::
string
&
hosts
,
int32_t
session_timeout_ms
)
ZooKeeper
::
ZooKeeper
(
const
std
::
string
&
hosts
,
const
std
::
string
&
identity
,
int32_t
session_timeout_ms
)
{
init
(
hosts
,
session_timeout_ms
);
init
(
hosts
,
identity
,
session_timeout_ms
);
}
struct
ZooKeeperArgs
...
...
@@ -107,12 +116,19 @@ struct ZooKeeperArgs
if
(
startsWith
(
key
,
"node"
))
{
hosts_strings
.
push_back
(
config
.
getString
(
config_name
+
"."
+
key
+
".host"
)
+
":"
+
config
.
getString
(
config_name
+
"."
+
key
+
".port"
,
"2181"
));
config
.
getString
(
config_name
+
"."
+
key
+
".host"
)
+
":"
+
config
.
getString
(
config_name
+
"."
+
key
+
".port"
,
"2181"
)
+
config
.
getString
(
config_name
+
"."
+
key
+
".root"
,
""
)
);
}
else
if
(
key
==
"session_timeout_ms"
)
{
session_timeout_ms
=
config
.
getInt
(
config_name
+
"."
+
key
);
}
else
if
(
key
==
"identity"
)
{
identity
=
config
.
getString
(
config_name
+
"."
+
key
);
}
else
throw
KeeperException
(
std
::
string
(
"Unknown key "
)
+
key
+
" in config file"
);
}
...
...
@@ -130,13 +146,14 @@ struct ZooKeeperArgs
}
std
::
string
hosts
;
size_t
session_timeout_ms
;
std
::
string
identity
;
int
session_timeout_ms
;
};
ZooKeeper
::
ZooKeeper
(
const
Poco
::
Util
::
AbstractConfiguration
&
config
,
const
std
::
string
&
config_name
)
{
ZooKeeperArgs
args
(
config
,
config_name
);
init
(
args
.
hosts
,
args
.
session_timeout_ms
);
init
(
args
.
hosts
,
args
.
identity
,
args
.
session_timeout_ms
);
}
WatchCallback
ZooKeeper
::
callbackForEvent
(
const
EventPtr
&
event
)
...
...
dbms/src/Common/ZooKeeper/ZooKeeper.h
浏览文件 @
16103456
...
...
@@ -54,7 +54,7 @@ class ZooKeeper
public:
using
Ptr
=
std
::
shared_ptr
<
ZooKeeper
>
;
ZooKeeper
(
const
std
::
string
&
hosts
,
int32_t
session_timeout_ms
=
DEFAULT_SESSION_TIMEOUT
);
ZooKeeper
(
const
std
::
string
&
hosts
,
const
std
::
string
&
identity
,
int32_t
session_timeout_ms
=
DEFAULT_SESSION_TIMEOUT
);
/** Config of the form:
<zookeeper>
...
...
@@ -353,7 +353,7 @@ private:
friend
struct
WatchContext
;
friend
class
EphemeralNodeHolder
;
void
init
(
const
std
::
string
&
hosts
,
int32_t
session_timeout_ms
);
void
init
(
const
std
::
string
&
hosts
,
const
std
::
string
&
identity
,
int32_t
session_timeout_ms
);
void
removeChildrenRecursive
(
const
std
::
string
&
path
);
void
tryRemoveChildrenRecursive
(
const
std
::
string
&
path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录