Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wk1234123
DolphinScheduler
提交
80c6ce57
DolphinScheduler
项目概览
wk1234123
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
5
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
80c6ce57
编写于
3月 14, 2020
作者:
R
Rubik-W
提交者:
GitHub
3月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The master and worker server exit exception #2163 (#2176)
* fix: #2163 * fix: format
上级
2e63dc9c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
49 deletion
+46
-49
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/thread/ThreadUtils.java
...rg/apache/dolphinscheduler/common/thread/ThreadUtils.java
+14
-3
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
...g/apache/dolphinscheduler/server/master/MasterServer.java
+16
-17
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java
...g/apache/dolphinscheduler/server/worker/WorkerServer.java
+16
-29
未找到文件。
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/thread/ThreadUtils.java
浏览文件 @
80c6ce57
...
...
@@ -120,12 +120,24 @@ public class ThreadUtils {
/**
* Wrapper over ScheduledThreadPoolExecutor
* @param threadName
* @param corePoolSize
* @return
*/
public
static
ScheduledExecutorService
newDaemonThreadScheduledExecutor
(
String
threadName
,
int
corePoolSize
)
{
public
static
ScheduledExecutorService
newDaemonThreadScheduledExecutor
(
String
threadName
,
int
corePoolSize
)
{
return
newThreadScheduledExecutor
(
threadName
,
corePoolSize
,
true
);
}
/**
* Wrapper over ScheduledThreadPoolExecutor
* @param threadName
* @param corePoolSize
* @param isDaemon
* @return
*/
public
static
ScheduledExecutorService
newThreadScheduledExecutor
(
String
threadName
,
int
corePoolSize
,
boolean
isDaemon
)
{
ThreadFactory
threadFactory
=
new
ThreadFactoryBuilder
()
.
setDaemon
(
true
)
.
setDaemon
(
isDaemon
)
.
setNameFormat
(
threadName
)
.
build
();
ScheduledThreadPoolExecutor
executor
=
new
ScheduledThreadPoolExecutor
(
corePoolSize
,
threadFactory
);
...
...
@@ -135,7 +147,6 @@ public class ThreadUtils {
return
executor
;
}
public
static
ThreadInfo
getThreadInfo
(
Thread
t
)
{
long
tid
=
t
.
getId
();
return
threadBean
.
getThreadInfo
(
tid
,
STACK_DEPTH
);
...
...
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
浏览文件 @
80c6ce57
...
...
@@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.common.utils.OSUtils;
import
org.apache.dolphinscheduler.common.utils.StringUtils
;
import
org.apache.dolphinscheduler.server.master.config.MasterConfig
;
import
org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread
;
import
org.apache.dolphinscheduler.server.worker.WorkerServer
;
import
org.apache.dolphinscheduler.server.zk.ZKMasterClient
;
import
org.apache.dolphinscheduler.service.bean.SpringApplicationContext
;
import
org.apache.dolphinscheduler.service.process.ProcessService
;
...
...
@@ -37,8 +38,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.WebApplicationType
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.FilterType
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PreDestroy
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -46,7 +49,9 @@ import java.util.concurrent.TimeUnit;
/**
* master server
*/
@ComponentScan
(
"org.apache.dolphinscheduler"
)
@ComponentScan
(
value
=
"org.apache.dolphinscheduler"
,
excludeFilters
=
{
@ComponentScan
.
Filter
(
type
=
FilterType
.
ASSIGNABLE_TYPE
,
classes
=
{
WorkerServer
.
class
})
})
public
class
MasterServer
implements
IStoppable
{
/**
...
...
@@ -112,7 +117,7 @@ public class MasterServer implements IStoppable {
masterSchedulerService
=
ThreadUtils
.
newDaemonSingleThreadExecutor
(
"Master-Scheduler-Thread"
);
heartbeatMasterService
=
ThreadUtils
.
new
DaemonThreadScheduledExecutor
(
"Master-Main-Thread"
,
Constants
.
DEFAULT_MASTER_HEARTBEAT_THREAD_NUM
);
heartbeatMasterService
=
ThreadUtils
.
new
ThreadScheduledExecutor
(
"Master-Main-Thread"
,
Constants
.
DEFAULT_MASTER_HEARTBEAT_THREAD_NUM
,
false
);
// heartbeat thread implement
Runnable
heartBeatThread
=
heartBeatThread
();
...
...
@@ -147,23 +152,17 @@ public class MasterServer implements IStoppable {
}
logger
.
error
(
"start Quartz failed"
,
e
);
}
/**
* register hooks, which are called before the process exits
*/
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
zkMasterClient
.
getActiveMasterNum
()
<=
1
)
{
zkMasterClient
.
getAlertDao
().
sendServerStopedAlert
(
1
,
OSUtils
.
getHost
(),
"Master-Server"
);
}
stop
(
"shutdownhook"
);
}
}));
}
@PreDestroy
public
void
destroy
()
{
// master server exit alert
if
(
zkMasterClient
.
getActiveMasterNum
()
<=
1
)
{
zkMasterClient
.
getAlertDao
().
sendServerStopedAlert
(
1
,
OSUtils
.
getHost
(),
"Master-Server"
);
}
stop
(
"shutdownhook"
);
}
/**
* gracefully stop
...
...
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java
浏览文件 @
80c6ce57
...
...
@@ -29,6 +29,7 @@ import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import
org.apache.dolphinscheduler.common.utils.OSUtils
;
import
org.apache.dolphinscheduler.dao.AlertDao
;
import
org.apache.dolphinscheduler.dao.entity.TaskInstance
;
import
org.apache.dolphinscheduler.server.master.MasterServer
;
import
org.apache.dolphinscheduler.server.utils.ProcessUtils
;
import
org.apache.dolphinscheduler.server.worker.config.WorkerConfig
;
import
org.apache.dolphinscheduler.server.worker.runner.FetchTaskThread
;
...
...
@@ -43,10 +44,13 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.WebApplicationType
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.FilterType
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PreDestroy
;
import
java.util.Set
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutorService
;
...
...
@@ -56,7 +60,10 @@ import java.util.concurrent.TimeUnit;
/**
* worker server
*/
@ComponentScan
(
"org.apache.dolphinscheduler"
)
@SpringBootApplication
@ComponentScan
(
value
=
"org.apache.dolphinscheduler"
,
excludeFilters
=
{
@ComponentScan
.
Filter
(
type
=
FilterType
.
ASSIGNABLE_TYPE
,
classes
=
{
MasterServer
.
class
})
})
public
class
WorkerServer
implements
IStoppable
{
/**
...
...
@@ -104,11 +111,6 @@ public class WorkerServer implements IStoppable {
*/
private
ExecutorService
fetchTaskExecutorService
;
/**
* CountDownLatch latch
*/
private
CountDownLatch
latch
;
@Value
(
"${server.is-combined-server:false}"
)
private
Boolean
isCombinedServer
;
...
...
@@ -149,7 +151,7 @@ public class WorkerServer implements IStoppable {
this
.
fetchTaskExecutorService
=
ThreadUtils
.
newDaemonSingleThreadExecutor
(
"Worker-Fetch-Thread-Executor"
);
heartbeatWorkerService
=
ThreadUtils
.
new
DaemonThreadScheduledExecutor
(
"Worker-Heartbeat-Thread-Executor"
,
Constants
.
DEFAUL_WORKER_HEARTBEAT_THREAD_NUM
);
heartbeatWorkerService
=
ThreadUtils
.
new
ThreadScheduledExecutor
(
"Worker-Heartbeat-Thread-Executor"
,
Constants
.
DEFAUL_WORKER_HEARTBEAT_THREAD_NUM
,
false
);
// heartbeat thread implement
Runnable
heartBeatThread
=
heartBeatThread
();
...
...
@@ -171,29 +173,15 @@ public class WorkerServer implements IStoppable {
// submit fetch task thread
fetchTaskExecutorService
.
execute
(
fetchTaskThread
);
}
/**
* register hooks, which are called before the process exits
*/
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
// worker server exit alert
if
(
zkWorkerClient
.
getActiveMasterNum
()
<=
1
)
{
alertDao
.
sendServerStopedAlert
(
1
,
OSUtils
.
getHost
(),
"Worker-Server"
);
}
stop
(
"shutdownhook"
);
}
}));
//let the main thread await
latch
=
new
CountDownLatch
(
1
);
if
(!
isCombinedServer
)
{
try
{
latch
.
await
();
}
catch
(
InterruptedException
ignore
)
{
}
@PreDestroy
public
void
destroy
()
{
// worker server exit alert
if
(
zkWorkerClient
.
getActiveMasterNum
()
<=
1
)
{
alertDao
.
sendServerStopedAlert
(
1
,
OSUtils
.
getHost
(),
"Worker-Server"
);
}
stop
(
"shutdownhook"
);
}
@Override
...
...
@@ -251,7 +239,6 @@ public class WorkerServer implements IStoppable {
}
catch
(
Exception
e
){
logger
.
warn
(
"zookeeper service stopped exception:{}"
,
e
.
getMessage
());
}
latch
.
countDown
();
logger
.
info
(
"zookeeper service stopped"
);
}
catch
(
Exception
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录