Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
f5652b44
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,发现更多精彩内容 >>
提交
f5652b44
编写于
4月 03, 2018
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modifications after removing libzookeeper; initialize ZooKeeper session lazily [#CLICKHOUSE-2]
上级
08170d0d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
57 deletion
+14
-57
dbms/src/Common/ZooKeeper/ZooKeeperImpl.cpp
dbms/src/Common/ZooKeeper/ZooKeeperImpl.cpp
+1
-7
dbms/src/Interpreters/Context.cpp
dbms/src/Interpreters/Context.cpp
+3
-17
dbms/src/Interpreters/Context.h
dbms/src/Interpreters/Context.h
+0
-2
dbms/src/Server/ClusterCopier.cpp
dbms/src/Server/ClusterCopier.cpp
+9
-25
dbms/src/Server/Server.cpp
dbms/src/Server/Server.cpp
+1
-6
未找到文件。
dbms/src/Common/ZooKeeper/ZooKeeperImpl.cpp
浏览文件 @
f5652b44
...
...
@@ -345,7 +345,7 @@ void read(String & s, ReadBuffer & in)
static
constexpr
int32_t
max_string_size
=
1
<<
20
;
int32_t
size
=
0
;
read
(
size
,
in
);
if
(
size
<
0
)
/// TODO Actually it means that zookeeper node ha
ve
NULL value. Maybe better to treat it like empty string.
if
(
size
<
0
)
/// TODO Actually it means that zookeeper node ha
s
NULL value. Maybe better to treat it like empty string.
throw
Exception
(
"Negative size while reading string from ZooKeeper"
,
ZooKeeper
::
ZMARSHALLINGERROR
);
if
(
size
>
max_string_size
)
throw
Exception
(
"Too large string size while reading from ZooKeeper"
,
ZooKeeper
::
ZMARSHALLINGERROR
);
...
...
@@ -862,8 +862,6 @@ void ZooKeeper::receiveEvent()
throw
Exception
(
"Received error in heartbeat response: "
+
String
(
errorMessage
(
err
)),
ZRUNTIMEINCONSISTENCY
);
response
=
std
::
make_shared
<
HeartbeatResponse
>
();
// std::cerr << "Received heartbeat\n";
}
else
if
(
xid
==
watch_xid
)
{
...
...
@@ -896,8 +894,6 @@ void ZooKeeper::receiveEvent()
watches
.
erase
(
it
);
}
};
// std::cerr << "Received watch\n";
}
else
{
...
...
@@ -912,8 +908,6 @@ void ZooKeeper::receiveEvent()
operations
.
erase
(
it
);
}
// std::cerr << "Received response: " << request_info.request->getOpNum() << "\n";
response
=
request_info
.
request
->
makeResponse
();
}
...
...
dbms/src/Interpreters/Context.cpp
浏览文件 @
f5652b44
...
...
@@ -515,12 +515,6 @@ void Context::setConfig(const ConfigurationPtr & config)
shared
->
config
=
config
;
}
ConfigurationPtr
Context
::
getConfig
()
const
{
auto
lock
=
getLock
();
return
shared
->
config
;
}
Poco
::
Util
::
AbstractConfiguration
&
Context
::
getConfigRef
()
const
{
auto
lock
=
getLock
();
...
...
@@ -1326,21 +1320,13 @@ DDLWorker & Context::getDDLWorker() const
return
*
shared
->
ddl_worker
;
}
void
Context
::
setZooKeeper
(
zkutil
::
ZooKeeperPtr
zookeeper
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared
->
zookeeper_mutex
);
if
(
shared
->
zookeeper
)
throw
Exception
(
"ZooKeeper client has already been set."
,
ErrorCodes
::
LOGICAL_ERROR
);
shared
->
zookeeper
=
std
::
move
(
zookeeper
);
}
zkutil
::
ZooKeeperPtr
Context
::
getZooKeeper
()
const
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared
->
zookeeper_mutex
);
if
(
shared
->
zookeeper
&&
shared
->
zookeeper
->
expired
())
if
(
!
shared
->
zookeeper
)
shared
->
zookeeper
=
std
::
make_shared
<
zkutil
::
ZooKeeper
>
(
getConfigRef
(),
"zookeeper"
);
else
if
(
shared
->
zookeeper
->
expired
())
shared
->
zookeeper
=
shared
->
zookeeper
->
startNewSession
();
return
shared
->
zookeeper
;
...
...
dbms/src/Interpreters/Context.h
浏览文件 @
f5652b44
...
...
@@ -140,7 +140,6 @@ public:
/// Global application configuration settings.
void
setConfig
(
const
ConfigurationPtr
&
config
);
ConfigurationPtr
getConfig
()
const
;
Poco
::
Util
::
AbstractConfiguration
&
getConfigRef
()
const
;
/** Take the list of users, quotas and configuration profiles from this config.
...
...
@@ -300,7 +299,6 @@ public:
MergeList
&
getMergeList
();
const
MergeList
&
getMergeList
()
const
;
void
setZooKeeper
(
std
::
shared_ptr
<
zkutil
::
ZooKeeper
>
zookeeper
);
/// If the current session is expired at the time of the call, synchronously creates and returns a new session with the startNewSession() call.
std
::
shared_ptr
<
zkutil
::
ZooKeeper
>
getZooKeeper
()
const
;
/// Has ready or expired ZooKeeper
...
...
dbms/src/Server/ClusterCopier.cpp
浏览文件 @
f5652b44
...
...
@@ -716,13 +716,11 @@ class ClusterCopier
{
public:
ClusterCopier
(
const
ConfigurationPtr
&
zookeeper_config_
,
const
String
&
task_path_
,
ClusterCopier
(
const
String
&
task_path_
,
const
String
&
host_id_
,
const
String
&
proxy_database_name_
,
Context
&
context_
)
:
zookeeper_config
(
zookeeper_config_
),
task_zookeeper_path
(
task_path_
),
host_id
(
host_id_
),
working_database_name
(
proxy_database_name_
),
...
...
@@ -733,7 +731,7 @@ public:
void
init
()
{
auto
zookeeper
=
getZooKeeper
();
auto
zookeeper
=
context
.
getZooKeeper
();
task_description_watch_callback
=
[
this
]
(
const
ZooKeeperImpl
::
ZooKeeper
::
WatchResponse
&
)
{
...
...
@@ -763,8 +761,8 @@ public:
/// Do not initialize tables, will make deferred initialization in process()
getZooKeeper
()
->
createAncestors
(
getWorkersPathVersion
()
+
"/"
);
getZooKeeper
()
->
createAncestors
(
getWorkersPath
()
+
"/"
);
zookeeper
->
createAncestors
(
getWorkersPathVersion
()
+
"/"
);
zookeeper
->
createAncestors
(
getWorkersPath
()
+
"/"
);
}
template
<
typename
T
>
...
...
@@ -891,7 +889,7 @@ public:
void
reloadTaskDescription
()
{
auto
zookeeper
=
getZooKeeper
();
auto
zookeeper
=
context
.
getZooKeeper
();
task_description_watch_zookeeper
=
zookeeper
;
String
task_config_str
;
...
...
@@ -1088,7 +1086,7 @@ protected:
{
LOG_DEBUG
(
log
,
"Check that all shards processed partition "
<<
partition_name
<<
" successfully"
);
auto
zookeeper
=
getZooKeeper
();
auto
zookeeper
=
context
.
getZooKeeper
();
Strings
status_paths
;
for
(
auto
&
shard
:
shards_with_partition
)
...
...
@@ -1460,7 +1458,7 @@ protected:
TaskTable
&
task_table
=
task_shard
.
task_table
;
ClusterPartition
&
cluster_partition
=
task_table
.
getClusterPartition
(
task_partition
.
name
);
auto
zookeeper
=
getZooKeeper
();
auto
zookeeper
=
context
.
getZooKeeper
();
String
is_dirty_flag_path
=
task_partition
.
getCommonPartitionIsDirtyPath
();
String
current_task_is_active_path
=
task_partition
.
getActiveWorkerPath
();
...
...
@@ -1996,21 +1994,7 @@ protected:
return
successful_shards
;
}
zkutil
::
ZooKeeperPtr
getZooKeeper
()
{
auto
zookeeper
=
context
.
getZooKeeper
();
if
(
!
zookeeper
)
{
context
.
setZooKeeper
(
std
::
make_shared
<
zkutil
::
ZooKeeper
>
(
*
zookeeper_config
,
"zookeeper"
));
zookeeper
=
context
.
getZooKeeper
();
}
return
zookeeper
;
}
private:
ConfigurationPtr
zookeeper_config
;
String
task_zookeeper_path
;
String
task_description_path
;
String
host_id
;
...
...
@@ -2153,6 +2137,7 @@ void ClusterCopierApp::mainImpl()
auto
context
=
std
::
make_unique
<
Context
>
(
Context
::
createGlobal
());
SCOPE_EXIT
(
context
->
shutdown
());
context
->
setConfig
(
zookeeper_configuration
);
context
->
setGlobalContext
(
*
context
);
context
->
setApplicationType
(
Context
::
ApplicationType
::
LOCAL
);
context
->
setPath
(
process_path
);
...
...
@@ -2166,8 +2151,7 @@ void ClusterCopierApp::mainImpl()
context
->
addDatabase
(
default_database
,
std
::
make_shared
<
DatabaseMemory
>
(
default_database
));
context
->
setCurrentDatabase
(
default_database
);
std
::
unique_ptr
<
ClusterCopier
>
copier
(
new
ClusterCopier
(
zookeeper_configuration
,
task_path
,
host_id
,
default_database
,
*
context
));
std
::
unique_ptr
<
ClusterCopier
>
copier
=
std
::
make_unique
<
ClusterCopier
>
(
task_path
,
host_id
,
default_database
,
*
context
);
copier
->
setSafeMode
(
is_safe_mode
);
copier
->
setCopyFaultProbability
(
copy_fault_probability
);
...
...
dbms/src/Server/Server.cpp
浏览文件 @
f5652b44
...
...
@@ -102,12 +102,7 @@ int Server::main(const std::vector<std::string> & /*args*/)
global_context
->
setGlobalContext
(
*
global_context
);
global_context
->
setApplicationType
(
Context
::
ApplicationType
::
SERVER
);
bool
has_zookeeper
=
false
;
if
(
config
().
has
(
"zookeeper"
))
{
global_context
->
setZooKeeper
(
std
::
make_shared
<
zkutil
::
ZooKeeper
>
(
config
(),
"zookeeper"
));
has_zookeeper
=
true
;
}
bool
has_zookeeper
=
config
().
has
(
"zookeeper"
);
zkutil
::
ZooKeeperNodeCache
main_config_zk_node_cache
([
&
]
{
return
global_context
->
getZooKeeper
();
});
if
(
loaded_config
.
has_zk_includes
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录