Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
9de5da09
Unverified
提交
9de5da09
authored
6月 24, 2018
作者:
许雪里
提交者:
GitHub
6月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #293 from liuluo129/feature/timeout
“添加任务超时属性,超时后失败” 赞,这个特性十分实用!
上级
3c215422
c3c7ded5
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
91 行增加
和
16 行删除
+91
-16
tables_xxl_job.sql
doc/db/tables_xxl_job.sql
+1
-0
XxlJobInfo.java
...rc/main/java/com/xxl/job/admin/core/model/XxlJobInfo.java
+11
-0
XxlJobTrigger.java
...in/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java
+3
-0
message.properties
xxl-job-admin/src/main/resources/i18n/message.properties
+2
-0
message_en.properties
xxl-job-admin/src/main/resources/i18n/message_en.properties
+2
-0
XxlJobInfoMapper.xml
...in/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml
+20
-15
jobinfo.index.ftl
...rc/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl
+5
-0
jobinfo.index.1.js
xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js
+1
-0
joblog.index.1.js
xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js
+2
-0
ReturnT.java
...ore/src/main/java/com/xxl/job/core/biz/model/ReturnT.java
+3
-0
TriggerParam.java
...rc/main/java/com/xxl/job/core/biz/model/TriggerParam.java
+10
-0
IJobHandler.java
...e/src/main/java/com/xxl/job/core/handler/IJobHandler.java
+2
-0
JobThread.java
...core/src/main/java/com/xxl/job/core/thread/JobThread.java
+29
-1
没有找到文件。
doc/db/tables_xxl_job.sql
浏览文件 @
9de5da09
...
@@ -158,6 +158,7 @@ CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_INFO` (
...
@@ -158,6 +158,7 @@ CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_INFO` (
`update_time`
datetime
DEFAULT
NULL
,
`update_time`
datetime
DEFAULT
NULL
,
`author`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'作者'
,
`author`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'作者'
,
`alarm_email`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'报警邮件'
,
`alarm_email`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'报警邮件'
,
`execute_timeout`
int
(
11
)
NOT
NULL
DEFAULT
0
COMMENT
'任务执行超时时间'
,
`executor_route_strategy`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'执行器路由策略'
,
`executor_route_strategy`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'执行器路由策略'
,
`executor_handler`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'执行器任务handler'
,
`executor_handler`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'执行器任务handler'
,
`executor_param`
varchar
(
512
)
DEFAULT
NULL
COMMENT
'执行器任务参数'
,
`executor_param`
varchar
(
512
)
DEFAULT
NULL
COMMENT
'执行器任务参数'
,
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobInfo.java
浏览文件 @
9de5da09
...
@@ -36,6 +36,17 @@ public class XxlJobInfo {
...
@@ -36,6 +36,17 @@ public class XxlJobInfo {
// copy from quartz
// copy from quartz
private
String
jobStatus
;
// 任务状态 【base on quartz】
private
String
jobStatus
;
// 任务状态 【base on quartz】
private
int
executeTimeout
;
// 任务最多执行时间,超时后报警
public
int
getExecuteTimeout
()
{
return
executeTimeout
;
}
public
void
setExecuteTimeout
(
int
executeTimeout
)
{
this
.
executeTimeout
=
executeTimeout
;
}
public
int
getId
()
{
public
int
getId
()
{
return
id
;
return
id
;
}
}
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java
浏览文件 @
9de5da09
...
@@ -96,6 +96,8 @@ public class XxlJobTrigger {
...
@@ -96,6 +96,8 @@ public class XxlJobTrigger {
triggerParam
.
setGlueUpdatetime
(
jobInfo
.
getGlueUpdatetime
().
getTime
());
triggerParam
.
setGlueUpdatetime
(
jobInfo
.
getGlueUpdatetime
().
getTime
());
triggerParam
.
setBroadcastIndex
(
i
);
triggerParam
.
setBroadcastIndex
(
i
);
triggerParam
.
setBroadcastTotal
(
addressList
.
size
());
// update02
triggerParam
.
setBroadcastTotal
(
addressList
.
size
());
// update02
// 执行超时时间
triggerParam
.
setExecuteTimeout
(
jobInfo
.
getExecuteTimeout
());
// 4.2、trigger-run (route run / trigger remote executor)
// 4.2、trigger-run (route run / trigger remote executor)
triggerResult
=
runExecutor
(
triggerParam
,
address
);
// update03
triggerResult
=
runExecutor
(
triggerParam
,
address
);
// update03
...
@@ -164,6 +166,7 @@ public class XxlJobTrigger {
...
@@ -164,6 +166,7 @@ public class XxlJobTrigger {
triggerParam
.
setGlueUpdatetime
(
jobInfo
.
getGlueUpdatetime
().
getTime
());
triggerParam
.
setGlueUpdatetime
(
jobInfo
.
getGlueUpdatetime
().
getTime
());
triggerParam
.
setBroadcastIndex
(
0
);
triggerParam
.
setBroadcastIndex
(
0
);
triggerParam
.
setBroadcastTotal
(
1
);
triggerParam
.
setBroadcastTotal
(
1
);
triggerParam
.
setExecuteTimeout
(
jobInfo
.
getExecuteTimeout
());
// 4.2、trigger-run (route run / trigger remote executor)
// 4.2、trigger-run (route run / trigger remote executor)
triggerResult
=
executorRouteStrategyEnum
.
getRouter
().
routeRun
(
triggerParam
,
addressList
);
triggerResult
=
executorRouteStrategyEnum
.
getRouter
().
routeRun
(
triggerParam
,
addressList
);
...
...
xxl-job-admin/src/main/resources/i18n/message.properties
浏览文件 @
9de5da09
...
@@ -107,6 +107,7 @@ jobinfo_field_gluetype=运行模式
...
@@ -107,6 +107,7 @@ jobinfo_field_gluetype=运行模式
jobinfo_field_executorparam
=
任务参数
jobinfo_field_executorparam
=
任务参数
jobinfo_field_cron_unvalid
=
Cron格式非法
jobinfo_field_cron_unvalid
=
Cron格式非法
jobinfo_field_author
=
负责人
jobinfo_field_author
=
负责人
jobinfo_field_timeout
=
最大执行时间
jobinfo_field_alarmemail
=
报警邮件
jobinfo_field_alarmemail
=
报警邮件
jobinfo_field_alarmemail_placeholder
=
请输入报警邮件,多个邮件地址则逗号分隔
jobinfo_field_alarmemail_placeholder
=
请输入报警邮件,多个邮件地址则逗号分隔
jobinfo_field_executorRouteStrategy
=
路由策略
jobinfo_field_executorRouteStrategy
=
路由策略
...
@@ -157,6 +158,7 @@ joblog_clean_type_9=清理所有日志数据
...
@@ -157,6 +158,7 @@ joblog_clean_type_9=清理所有日志数据
joblog_clean_type_unvalid
=
清理类型参数异常
joblog_clean_type_unvalid
=
清理类型参数异常
joblog_handleCode_200
=
成功
joblog_handleCode_200
=
成功
joblog_handleCode_500
=
失败
joblog_handleCode_500
=
失败
joblog_handleCode_400
=
超时
joblog_handleCode_501
=
失败重试
joblog_handleCode_501
=
失败重试
joblog_kill_log
=
终止任务
joblog_kill_log
=
终止任务
joblog_kill_log_limit
=
调度失败,无法终止日志
joblog_kill_log_limit
=
调度失败,无法终止日志
...
...
xxl-job-admin/src/main/resources/i18n/message_en.properties
浏览文件 @
9de5da09
...
@@ -103,6 +103,7 @@ jobinfo_field_update=Edit Job
...
@@ -103,6 +103,7 @@ jobinfo_field_update=Edit Job
jobinfo_field_id
=
Job ID
jobinfo_field_id
=
Job ID
jobinfo_field_jobgroup
=
Executor
jobinfo_field_jobgroup
=
Executor
jobinfo_field_jobdesc
=
Job description
jobinfo_field_jobdesc
=
Job description
jobinfo_field_timeout
=
Max execute time
jobinfo_field_gluetype
=
GLUE Type
jobinfo_field_gluetype
=
GLUE Type
jobinfo_field_executorparam
=
Param
jobinfo_field_executorparam
=
Param
jobinfo_field_cron_unvalid
=
The Cron is illegal
jobinfo_field_cron_unvalid
=
The Cron is illegal
...
@@ -157,6 +158,7 @@ joblog_clean_type_9=Clean up all log data
...
@@ -157,6 +158,7 @@ joblog_clean_type_9=Clean up all log data
joblog_clean_type_unvalid
=
Clean type is illegal
joblog_clean_type_unvalid
=
Clean type is illegal
joblog_handleCode_200
=
Success
joblog_handleCode_200
=
Success
joblog_handleCode_500
=
Fail
joblog_handleCode_500
=
Fail
joblog_handleCode_400
=
Timeout
joblog_handleCode_501
=
Fail retry
joblog_handleCode_501
=
Fail retry
joblog_kill_log
=
Kill Job
joblog_kill_log
=
Kill Job
joblog_kill_log_limit
=
Trigger Fail, can not kill job
joblog_kill_log_limit
=
Trigger Fail, can not kill job
...
...
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml
浏览文件 @
9de5da09
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxl.job.admin.dao.XxlJobInfoDao"
>
<mapper
namespace=
"com.xxl.job.admin.dao.XxlJobInfoDao"
>
<resultMap
id=
"XxlJobInfo"
type=
"com.xxl.job.admin.core.model.XxlJobInfo"
>
<resultMap
id=
"XxlJobInfo"
type=
"com.xxl.job.admin.core.model.XxlJobInfo"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"id"
property=
"id"
/>
<result
column=
"job_group"
property=
"jobGroup"
/>
<result
column=
"job_group"
property=
"jobGroup"
/>
<result
column=
"job_cron"
property=
"jobCron"
/>
<result
column=
"job_cron"
property=
"jobCron"
/>
<result
column=
"job_desc"
property=
"jobDesc"
/>
<result
column=
"job_desc"
property=
"jobDesc"
/>
<result
column=
"add_time"
property=
"addTime"
/>
<result
column=
"add_time"
property=
"addTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"author"
property=
"author"
/>
<result
column=
"author"
property=
"author"
/>
<result
column=
"alarm_email"
property=
"alarmEmail"
/>
<result
column=
"alarm_email"
property=
"alarmEmail"
/>
...
@@ -21,11 +21,12 @@
...
@@ -21,11 +21,12 @@
<result
column=
"executor_param"
property=
"executorParam"
/>
<result
column=
"executor_param"
property=
"executorParam"
/>
<result
column=
"executor_block_strategy"
property=
"executorBlockStrategy"
/>
<result
column=
"executor_block_strategy"
property=
"executorBlockStrategy"
/>
<result
column=
"executor_fail_strategy"
property=
"executorFailStrategy"
/>
<result
column=
"executor_fail_strategy"
property=
"executorFailStrategy"
/>
<result
column=
"glue_type"
property=
"glueType"
/>
<result
column=
"glue_type"
property=
"glueType"
/>
<result
column=
"glue_source"
property=
"glueSource"
/>
<result
column=
"glue_source"
property=
"glueSource"
/>
<result
column=
"glue_remark"
property=
"glueRemark"
/>
<result
column=
"glue_remark"
property=
"glueRemark"
/>
<result
column=
"glue_updatetime"
property=
"glueUpdatetime"
/>
<result
column=
"glue_updatetime"
property=
"glueUpdatetime"
/>
<result
column=
"execute_timeout"
property=
"executeTimeout"
/>
<result
column=
"child_jobid"
property=
"childJobId"
/>
<result
column=
"child_jobid"
property=
"childJobId"
/>
</resultMap>
</resultMap>
...
@@ -48,9 +49,10 @@
...
@@ -48,9 +49,10 @@
t.glue_source,
t.glue_source,
t.glue_remark,
t.glue_remark,
t.glue_updatetime,
t.glue_updatetime,
t.execute_timeout,
t.child_jobid
t.child_jobid
</sql>
</sql>
<select
id=
"pageList"
parameterType=
"java.util.HashMap"
resultMap=
"XxlJobInfo"
>
<select
id=
"pageList"
parameterType=
"java.util.HashMap"
resultMap=
"XxlJobInfo"
>
SELECT
<include
refid=
"Base_Column_List"
/>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
...
@@ -68,7 +70,7 @@
...
@@ -68,7 +70,7 @@
ORDER BY id DESC
ORDER BY id DESC
LIMIT #{offset}, #{pagesize}
LIMIT #{offset}, #{pagesize}
</select>
</select>
<select
id=
"pageListCount"
parameterType=
"java.util.HashMap"
resultType=
"int"
>
<select
id=
"pageListCount"
parameterType=
"java.util.HashMap"
resultType=
"int"
>
SELECT count(1)
SELECT count(1)
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
...
@@ -103,10 +105,11 @@
...
@@ -103,10 +105,11 @@
glue_source,
glue_source,
glue_remark,
glue_remark,
glue_updatetime,
glue_updatetime,
child_jobid
child_jobid,
execute_timeout
) VALUES (
) VALUES (
#{jobGroup},
#{jobGroup},
#{jobCron},
#{jobCron},
#{jobDesc},
#{jobDesc},
NOW(),
NOW(),
NOW(),
NOW(),
...
@@ -121,7 +124,8 @@
...
@@ -121,7 +124,8 @@
#{glueSource},
#{glueSource},
#{glueRemark},
#{glueRemark},
NOW(),
NOW(),
#{childJobId}
#{childJobId},
#{executeTimeout}
);
);
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
SELECT LAST_INSERT_ID()
...
@@ -134,10 +138,10 @@
...
@@ -134,10 +138,10 @@
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
WHERE t.id = #{id}
WHERE t.id = #{id}
</select>
</select>
<update
id=
"update"
parameterType=
"com.xxl.job.admin.core.model.XxlJobInfo"
>
<update
id=
"update"
parameterType=
"com.xxl.job.admin.core.model.XxlJobInfo"
>
UPDATE XXL_JOB_QRTZ_TRIGGER_INFO
UPDATE XXL_JOB_QRTZ_TRIGGER_INFO
SET
SET
job_cron = #{jobCron},
job_cron = #{jobCron},
job_desc = #{jobDesc},
job_desc = #{jobDesc},
update_time = NOW(),
update_time = NOW(),
...
@@ -152,10 +156,11 @@
...
@@ -152,10 +156,11 @@
glue_source = #{glueSource},
glue_source = #{glueSource},
glue_remark = #{glueRemark},
glue_remark = #{glueRemark},
glue_updatetime = #{glueUpdatetime},
glue_updatetime = #{glueUpdatetime},
child_jobid = #{childJobId}
child_jobid = #{childJobId},
execute_timeout = ${executeTimeout}
WHERE id = #{id}
WHERE id = #{id}
</update>
</update>
<delete
id=
"delete"
parameterType=
"java.util.HashMap"
>
<delete
id=
"delete"
parameterType=
"java.util.HashMap"
>
DELETE
DELETE
FROM XXL_JOB_QRTZ_TRIGGER_INFO
FROM XXL_JOB_QRTZ_TRIGGER_INFO
...
...
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl
浏览文件 @
9de5da09
...
@@ -169,6 +169,11 @@
...
@@ -169,6 +169,11 @@
<div
class=
"col-sm-4"
><input
type=
"text"
class=
"form-control"
name=
"alarmEmail"
placeholder=
"${I18n.jobinfo_field_alarmemail_placeholder}"
maxlength=
"100"
></div>
<div
class=
"col-sm-4"
><input
type=
"text"
class=
"form-control"
name=
"alarmEmail"
placeholder=
"${I18n.jobinfo_field_alarmemail_placeholder}"
maxlength=
"100"
></div>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"lastname"
class=
"col-sm-2 control-label"
>
${I18n.jobinfo_field_timeout}
<font
color=
"red"
>
*
</font></label>
<div
class=
"col-sm-4"
><input
type=
"text"
class=
"form-control"
name=
"executeTimeout"
placeholder=
"0"
maxlength=
"100"
></div>
</div>
<hr>
<hr>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-3 col-sm-6"
>
<div
class=
"col-sm-offset-3 col-sm-6"
>
...
...
xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js
浏览文件 @
9de5da09
...
@@ -362,6 +362,7 @@ $(function() {
...
@@ -362,6 +362,7 @@ $(function() {
$
(
"#updateModal .form input[name='jobCron']"
).
val
(
row
.
jobCron
);
$
(
"#updateModal .form input[name='jobCron']"
).
val
(
row
.
jobCron
);
$
(
"#updateModal .form input[name='author']"
).
val
(
row
.
author
);
$
(
"#updateModal .form input[name='author']"
).
val
(
row
.
author
);
$
(
"#updateModal .form input[name='alarmEmail']"
).
val
(
row
.
alarmEmail
);
$
(
"#updateModal .form input[name='alarmEmail']"
).
val
(
row
.
alarmEmail
);
$
(
"#updateModal .form input[name='executeTimeout']"
).
val
(
row
.
executeTimeout
);
$
(
'#updateModal .form select[name=executorRouteStrategy] option[value='
+
row
.
executorRouteStrategy
+
']'
).
prop
(
'selected'
,
true
);
$
(
'#updateModal .form select[name=executorRouteStrategy] option[value='
+
row
.
executorRouteStrategy
+
']'
).
prop
(
'selected'
,
true
);
$
(
"#updateModal .form input[name='executorHandler']"
).
val
(
row
.
executorHandler
);
$
(
"#updateModal .form input[name='executorHandler']"
).
val
(
row
.
executorHandler
);
$
(
"#updateModal .form input[name='executorParam']"
).
val
(
row
.
executorParam
);
$
(
"#updateModal .form input[name='executorParam']"
).
val
(
row
.
executorParam
);
...
...
xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js
浏览文件 @
9de5da09
...
@@ -159,6 +159,8 @@ $(function() {
...
@@ -159,6 +159,8 @@ $(function() {
html
=
'<span style="color: red">'
+
I18n
.
joblog_handleCode_500
+
'</span>'
;
html
=
'<span style="color: red">'
+
I18n
.
joblog_handleCode_500
+
'</span>'
;
}
else
if
(
data
==
501
)
{
}
else
if
(
data
==
501
)
{
html
=
'<span style="color: red">'
+
I18n
.
joblog_handleCode_501
+
'</span>'
;
html
=
'<span style="color: red">'
+
I18n
.
joblog_handleCode_501
+
'</span>'
;
}
else
if
(
data
==
400
)
{
html
=
'<span style="color: red">'
+
I18n
.
joblog_handleCode_400
+
'</span>'
;
}
else
if
(
data
==
0
)
{
}
else
if
(
data
==
0
)
{
html
=
''
;
html
=
''
;
}
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/biz/model/ReturnT.java
浏览文件 @
9de5da09
...
@@ -12,8 +12,11 @@ public class ReturnT<T> implements Serializable {
...
@@ -12,8 +12,11 @@ public class ReturnT<T> implements Serializable {
public
static
final
int
SUCCESS_CODE
=
200
;
public
static
final
int
SUCCESS_CODE
=
200
;
public
static
final
int
FAIL_CODE
=
500
;
public
static
final
int
FAIL_CODE
=
500
;
public
static
final
int
EXECUTE_TIMEOUT
=
400
;
public
static
final
ReturnT
<
String
>
SUCCESS
=
new
ReturnT
<
String
>(
null
);
public
static
final
ReturnT
<
String
>
SUCCESS
=
new
ReturnT
<
String
>(
null
);
public
static
final
ReturnT
<
String
>
FAIL
=
new
ReturnT
<
String
>(
FAIL_CODE
,
null
);
public
static
final
ReturnT
<
String
>
FAIL
=
new
ReturnT
<
String
>(
FAIL_CODE
,
null
);
public
static
final
ReturnT
<
String
>
TIMEOUT
=
new
ReturnT
<
String
>(
EXECUTE_TIMEOUT
,
"执行超时"
);
private
int
code
;
private
int
code
;
private
String
msg
;
private
String
msg
;
...
...
xxl-job-core/src/main/java/com/xxl/job/core/biz/model/TriggerParam.java
浏览文件 @
9de5da09
...
@@ -24,6 +24,16 @@ public class TriggerParam implements Serializable{
...
@@ -24,6 +24,16 @@ public class TriggerParam implements Serializable{
private
int
broadcastIndex
;
private
int
broadcastIndex
;
private
int
broadcastTotal
;
private
int
broadcastTotal
;
private
int
executeTimeout
;
public
int
getExecuteTimeout
()
{
return
executeTimeout
;
}
public
void
setExecuteTimeout
(
int
executeTimeout
)
{
this
.
executeTimeout
=
executeTimeout
;
}
public
int
getJobId
()
{
public
int
getJobId
()
{
return
jobId
;
return
jobId
;
}
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/handler/IJobHandler.java
浏览文件 @
9de5da09
...
@@ -14,6 +14,8 @@ public abstract class IJobHandler {
...
@@ -14,6 +14,8 @@ public abstract class IJobHandler {
public
static
final
ReturnT
<
String
>
SUCCESS
=
new
ReturnT
<
String
>(
200
,
null
);
public
static
final
ReturnT
<
String
>
SUCCESS
=
new
ReturnT
<
String
>(
200
,
null
);
/** fail */
/** fail */
public
static
final
ReturnT
<
String
>
FAIL
=
new
ReturnT
<
String
>(
500
,
null
);
public
static
final
ReturnT
<
String
>
FAIL
=
new
ReturnT
<
String
>(
500
,
null
);
/** timeout */
public
static
final
ReturnT
<
String
>
TIMEOUT
=
new
ReturnT
<
String
>(
400
,
null
);
/** fail retry */
/** fail retry */
public
static
final
ReturnT
<
String
>
FAIL_RETRY
=
new
ReturnT
<
String
>(
501
,
null
);
public
static
final
ReturnT
<
String
>
FAIL_RETRY
=
new
ReturnT
<
String
>(
501
,
null
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java
浏览文件 @
9de5da09
...
@@ -15,11 +15,15 @@ import java.io.PrintWriter;
...
@@ -15,11 +15,15 @@ import java.io.PrintWriter;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.concurrent.*
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
* handler thread
* handler thread
* @author xuxueli 2016-1-16 19:52:47
* @author xuxueli 2016-1-16 19:52:47
...
@@ -107,6 +111,7 @@ public class JobThread extends Thread{
...
@@ -107,6 +111,7 @@ public class JobThread extends Thread{
TriggerParam
triggerParam
=
null
;
TriggerParam
triggerParam
=
null
;
ReturnT
<
String
>
executeResult
=
null
;
ReturnT
<
String
>
executeResult
=
null
;
ExecutorService
singleThread
=
Executors
.
newSingleThreadExecutor
();
try
{
try
{
// to check toStop signal, we need cycle, so wo cannot use queue.take(), instand of poll(timeout)
// to check toStop signal, we need cycle, so wo cannot use queue.take(), instand of poll(timeout)
triggerParam
=
triggerQueue
.
poll
(
3L
,
TimeUnit
.
SECONDS
);
triggerParam
=
triggerQueue
.
poll
(
3L
,
TimeUnit
.
SECONDS
);
...
@@ -122,7 +127,27 @@ public class JobThread extends Thread{
...
@@ -122,7 +127,27 @@ public class JobThread extends Thread{
// execute
// execute
XxlJobLogger
.
log
(
"<br>----------- xxl-job job execute start -----------<br>----------- Param:"
+
triggerParam
.
getExecutorParams
());
XxlJobLogger
.
log
(
"<br>----------- xxl-job job execute start -----------<br>----------- Param:"
+
triggerParam
.
getExecutorParams
());
executeResult
=
handler
.
execute
(
triggerParam
.
getExecutorParams
());
int
executeTimeout
=
triggerParam
.
getExecuteTimeout
();
final
TriggerParam
finalTriggerParam
=
triggerParam
;
Future
<
ReturnT
<
String
>>
future
=
singleThread
.
submit
(
new
Callable
<
ReturnT
<
String
>>()
{
@Override
public
ReturnT
<
String
>
call
()
throws
Exception
{
return
handler
.
execute
(
finalTriggerParam
.
getExecutorParams
());
}
});
try
{
if
(
executeTimeout
>
0
)
{
executeResult
=
future
.
get
(
executeTimeout
,
TimeUnit
.
SECONDS
);
}
else
{
executeResult
=
future
.
get
();
}
}
catch
(
TimeoutException
timeoutException
)
{
executeResult
=
ReturnT
.
TIMEOUT
;
}
if
(
executeResult
==
null
)
{
if
(
executeResult
==
null
)
{
executeResult
=
IJobHandler
.
FAIL
;
executeResult
=
IJobHandler
.
FAIL
;
}
}
...
@@ -145,6 +170,9 @@ public class JobThread extends Thread{
...
@@ -145,6 +170,9 @@ public class JobThread extends Thread{
XxlJobLogger
.
log
(
"<br>----------- JobThread Exception:"
+
errorMsg
+
"<br>----------- xxl-job job execute end(error) -----------"
);
XxlJobLogger
.
log
(
"<br>----------- JobThread Exception:"
+
errorMsg
+
"<br>----------- xxl-job job execute end(error) -----------"
);
}
finally
{
}
finally
{
if
(
singleThread
!=
null
)
{
singleThread
.
shutdown
();
}
if
(
triggerParam
!=
null
)
{
if
(
triggerParam
!=
null
)
{
// callback handler info
// callback handler info
if
(!
toStop
)
{
if
(!
toStop
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论