Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
#法外狂徒张三
DolphinScheduler
提交
88711cd0
DolphinScheduler
项目概览
#法外狂徒张三
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
12
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
88711cd0
编写于
8月 23, 2019
作者:
D
dailidong
提交者:
GitHub
8月 23, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #732 from dailidong/dev
add embeded zookeeper for test
上级
bc21c42c
314bec15
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
100 addition
and
0 deletion
+100
-0
escheduler-common/src/test/java/cn/escheduler/common/zk/StandaloneZKServerForTest.java
...va/cn/escheduler/common/zk/StandaloneZKServerForTest.java
+100
-0
未找到文件。
escheduler-common/src/test/java/cn/escheduler/common/zk/StandaloneZKServerForTest.java
0 → 100644
浏览文件 @
88711cd0
/*
* 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.
*/
package
cn.escheduler.common.zk
;
import
java.io.File
;
import
java.util.Properties
;
import
cn.escheduler.common.thread.ThreadPoolExecutors
;
import
org.apache.zookeeper.server.ServerConfig
;
import
org.apache.zookeeper.server.ZooKeeperServerMain
;
import
org.apache.zookeeper.server.quorum.QuorumPeerConfig
;
import
org.junit.Before
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* just for test
*/
public
class
StandaloneZKServerForTest
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
StandaloneZKServerForTest
.
class
);
private
static
volatile
ZooKeeperServerMain
zkServer
=
null
;
@Before
public
void
before
()
{
logger
.
info
(
"standalone zookeeper server for test service start "
);
ThreadPoolExecutors
.
getInstance
().
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
//delete zk data dir ?
File
zkFile
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
"zookeeper"
);
// if(zkFile.exists()){
// zkFile.delete();
// }
startStandaloneServer
(
"2000"
,
zkFile
.
getAbsolutePath
(),
"2181"
,
"10"
,
"5"
);
}
});
}
/**
* start zk server
* @param tickTime zookeeper ticktime
* @param dataDir zookeeper data dir
* @param clientPort zookeeper client port
* @param initLimit zookeeper init limit
* @param syncLimit zookeeper sync limit
*/
private
void
startStandaloneServer
(
String
tickTime
,
String
dataDir
,
String
clientPort
,
String
initLimit
,
String
syncLimit
)
{
Properties
props
=
new
Properties
();
props
.
setProperty
(
"tickTime"
,
tickTime
);
props
.
setProperty
(
"dataDir"
,
dataDir
);
props
.
setProperty
(
"clientPort"
,
clientPort
);
props
.
setProperty
(
"initLimit"
,
initLimit
);
props
.
setProperty
(
"syncLimit"
,
syncLimit
);
QuorumPeerConfig
quorumConfig
=
new
QuorumPeerConfig
();
try
{
quorumConfig
.
parseProperties
(
props
);
if
(
zkServer
==
null
){
synchronized
(
StandaloneZKServerForTest
.
class
){
if
(
zkServer
==
null
){
zkServer
=
new
ZooKeeperServerMain
();
final
ServerConfig
config
=
new
ServerConfig
();
config
.
readFrom
(
quorumConfig
);
zkServer
.
runFromConfig
(
config
);
}
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"start standalone server fail!"
,
e
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录