Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
0888b2d5
提交
0888b2d5
authored
5月 09, 2017
作者:
xueli.xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
阻塞处理策略
上级
8600f883
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
43 行增加
和
6 行删除
+43
-6
RemoteHttpJobBean.java
...ava/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java
+1
-0
ExecutorBizImpl.java
.../main/java/com/xxl/job/core/biz/impl/ExecutorBizImpl.java
+4
-2
TriggerParam.java
...rc/main/java/com/xxl/job/core/biz/model/TriggerParam.java
+9
-0
JobThread.java
...core/src/main/java/com/xxl/job/core/thread/JobThread.java
+29
-4
没有找到文件。
xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java
浏览文件 @
0888b2d5
...
...
@@ -61,6 +61,7 @@ public class RemoteHttpJobBean extends QuartzJobBean {
triggerParam
.
setJobId
(
jobInfo
.
getId
());
triggerParam
.
setExecutorHandler
(
jobInfo
.
getExecutorHandler
());
triggerParam
.
setExecutorParams
(
jobInfo
.
getExecutorParam
());
triggerParam
.
setExecutorBlockStrategy
(
jobInfo
.
getExecutorBlockStrategy
());
triggerParam
.
setGlueType
(
jobInfo
.
getGlueType
());
triggerParam
.
setGlueSource
(
jobInfo
.
getGlueSource
());
triggerParam
.
setGlueUpdatetime
(
jobInfo
.
getGlueUpdatetime
().
getTime
());
...
...
xxl-job-core/src/main/java/com/xxl/job/core/biz/impl/ExecutorBizImpl.java
浏览文件 @
0888b2d5
...
...
@@ -4,6 +4,7 @@ import com.xxl.job.core.biz.ExecutorBiz;
import
com.xxl.job.core.biz.model.LogResult
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.biz.model.TriggerParam
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.job.core.executor.XxlJobExecutor
;
import
com.xxl.job.core.glue.GlueFactory
;
import
com.xxl.job.core.glue.GlueTypeEnum
;
...
...
@@ -128,8 +129,9 @@ public class ExecutorBizImpl implements ExecutorBiz {
}
// push data to queue
jobThread
.
pushTriggerQueue
(
triggerParam
);
return
ReturnT
.
SUCCESS
;
ExecutorBlockStrategyEnum
blockStrategy
=
ExecutorBlockStrategyEnum
.
match
(
triggerParam
.
getExecutorBlockStrategy
(),
null
);
ReturnT
<
String
>
pushResult
=
jobThread
.
pushTriggerQueue
(
triggerParam
,
blockStrategy
);
return
pushResult
;
}
}
xxl-job-core/src/main/java/com/xxl/job/core/biz/model/TriggerParam.java
浏览文件 @
0888b2d5
...
...
@@ -13,6 +13,7 @@ public class TriggerParam implements Serializable{
private
String
executorHandler
;
private
String
executorParams
;
private
String
executorBlockStrategy
;
private
String
glueType
;
private
String
glueSource
;
...
...
@@ -47,6 +48,14 @@ public class TriggerParam implements Serializable{
this
.
executorParams
=
executorParams
;
}
public
String
getExecutorBlockStrategy
()
{
return
executorBlockStrategy
;
}
public
void
setExecutorBlockStrategy
(
String
executorBlockStrategy
)
{
this
.
executorBlockStrategy
=
executorBlockStrategy
;
}
public
String
getGlueType
()
{
return
glueType
;
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java
浏览文件 @
0888b2d5
...
...
@@ -3,6 +3,7 @@ package com.xxl.job.core.thread;
import
com.xxl.job.core.biz.model.HandleCallbackParam
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.biz.model.TriggerParam
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.log.XxlJobLogger
;
...
...
@@ -31,6 +32,9 @@ public class JobThread extends Thread{
private
boolean
toStop
=
false
;
private
String
stopReason
;
private
boolean
running
=
false
;
public
JobThread
(
IJobHandler
handler
)
{
this
.
handler
=
handler
;
triggerQueue
=
new
LinkedBlockingQueue
<
TriggerParam
>();
...
...
@@ -40,14 +44,33 @@ public class JobThread extends Thread{
return
handler
;
}
public
void
pushTriggerQueue
(
TriggerParam
triggerParam
)
{
public
ReturnT
<
String
>
pushTriggerQueue
(
TriggerParam
triggerParam
,
ExecutorBlockStrategyEnum
blockStrategy
)
{
// avoid repeat
if
(
triggerLogIdSet
.
contains
(
triggerParam
.
getLogId
()))
{
logger
.
debug
(
"repeate trigger job, logId:{}"
,
triggerParam
.
getLogId
());
return
;
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"repeate trigger job, logId:"
+
triggerParam
.
getLogId
());
}
// block strategy
if
(
ExecutorBlockStrategyEnum
.
DISCARD_LATER
==
blockStrategy
)
{
// discard when running
if
(
running
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"任务阻塞:"
+
ExecutorBlockStrategyEnum
.
DISCARD_LATER
.
getTitle
());
}
}
else
if
(
ExecutorBlockStrategyEnum
.
COVER_EARLY
==
blockStrategy
)
{
// kill running old and clear queue
if
(
running
)
{
this
.
interrupt
();
}
triggerQueue
.
clear
();
triggerLogIdSet
.
clear
();
}
else
{
// just add to queue
}
triggerLogIdSet
.
add
(
triggerParam
.
getLogId
());
triggerQueue
.
add
(
triggerParam
);
return
ReturnT
.
SUCCESS
;
}
public
void
toStop
(
String
stopReason
)
{
...
...
@@ -59,15 +82,17 @@ public class JobThread extends Thread{
this
.
toStop
=
true
;
this
.
stopReason
=
stopReason
;
}
int
i
=
1
;
@Override
public
void
run
()
{
while
(!
toStop
){
running
=
false
;
try
{
// to check toStop signal, we need cycle, so wo cannot use queue.take(), instand of poll(timeout)
TriggerParam
triggerParam
=
triggerQueue
.
poll
(
3L
,
TimeUnit
.
SECONDS
);
if
(
triggerParam
!=
null
)
{
running
=
true
;
triggerLogIdSet
.
remove
(
triggerParam
.
getLogId
());
// parse param
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论