Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
aboota
xxl-job
提交
0888b2d5
X
xxl-job
项目概览
aboota
/
xxl-job
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
xxl-job
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0888b2d5
编写于
5月 09, 2017
作者:
X
xueli.xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
阻塞处理策略
上级
8600f883
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
6 deletion
+43
-6
xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java
...ava/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java
+1
-0
xxl-job-core/src/main/java/com/xxl/job/core/biz/impl/ExecutorBizImpl.java
.../main/java/com/xxl/job/core/biz/impl/ExecutorBizImpl.java
+4
-2
xxl-job-core/src/main/java/com/xxl/job/core/biz/model/TriggerParam.java
...rc/main/java/com/xxl/job/core/biz/model/TriggerParam.java
+9
-0
xxl-job-core/src/main/java/com/xxl/job/core/thread/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
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录