Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5b280137
authored
Jul 16, 2019
by
xuxueli
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调度组件优化:针对永远不会触发的Cron禁止配置和启动;任务Cron最后一次触发后再也不会触发时,比如一次性任务,主动停止相关任务;
parent
90eba382
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
22 deletions
doc/XXL-JOB官方文档.md
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
xxl-job-admin/src/main/resources/i18n/message.properties
xxl-job-admin/src/main/resources/i18n/message_en.properties
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml
doc/XXL-JOB官方文档.md
View file @
5b280137
## 《分
布式任务调度平台XXL-JOB》
## 《分
布式任务调度平台XXL-JOB》
...
@@ -1519,6 +1519,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
...
@@ -1519,6 +1519,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
8、
[
ING
]
任务、执行器数据全量本地缓存;新增消息表广播通知;
-
8、
[
ING
]
任务、执行器数据全量本地缓存;新增消息表广播通知;
-
9、
[
ING
]
任务触发组件优化,常规1s预加载一次,轮空时主动休眠4s;
-
9、
[
ING
]
任务触发组件优化,常规1s预加载一次,轮空时主动休眠4s;
-
10、注册监控线程优化,降低死锁几率;
-
10、注册监控线程优化,降低死锁几率;
-
11、调度组件优化:针对永远不会触发的Cron禁止配置和启动;任务Cron最后一次触发后再也不会触发时,比如一次性任务,主动停止相关任务;
### TODO LIST
### TODO LIST
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java
View file @
5b280137
...
@@ -78,12 +78,15 @@ public class JobScheduleHelper {
...
@@ -78,12 +78,15 @@ public class JobScheduleHelper {
// 过期超5s:本地忽略,当前时间开始计算下次触发时间
// 过期超5s:本地忽略,当前时间开始计算下次触发时间
// fresh next
// fresh next
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
());
jobInfo
.
setTriggerNextTime
(
if
(
nextValidTime
!=
null
)
{
new
CronExpression
(
jobInfo
.
getJobCron
())
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
.
getNextValidTimeAfter
(
new
Date
())
jobInfo
.
setTriggerNextTime
(
nextValidTime
.
getTime
());
.
getTime
()
}
else
{
);
jobInfo
.
setTriggerStatus
(
0
);
jobInfo
.
setTriggerLastTime
(
0
);
jobInfo
.
setTriggerNextTime
(
0
);
}
}
else
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
())
{
}
else
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
())
{
// 过期5s内 :立即触发一次,当前时间开始计算下次触发时间;
// 过期5s内 :立即触发一次,当前时间开始计算下次触发时间;
...
@@ -110,12 +113,15 @@ public class JobScheduleHelper {
...
@@ -110,12 +113,15 @@ public class JobScheduleHelper {
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
// 3、fresh next
// 3、fresh next
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
jobInfo
.
getTriggerNextTime
()));
jobInfo
.
setTriggerNextTime
(
if
(
nextValidTime
!=
null
)
{
new
CronExpression
(
jobInfo
.
getJobCron
())
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
.
getNextValidTimeAfter
(
new
Date
(
jobInfo
.
getTriggerNextTime
()))
jobInfo
.
setTriggerNextTime
(
nextValidTime
.
getTime
());
.
getTime
()
}
else
{
);
jobInfo
.
setTriggerStatus
(
0
);
jobInfo
.
setTriggerLastTime
(
0
);
jobInfo
.
setTriggerNextTime
(
0
);
}
}
}
...
@@ -129,12 +135,15 @@ public class JobScheduleHelper {
...
@@ -129,12 +135,15 @@ public class JobScheduleHelper {
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
// 3、fresh next
// 3、fresh next
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
jobInfo
.
getTriggerNextTime
()));
jobInfo
.
setTriggerNextTime
(
if
(
nextValidTime
!=
null
)
{
new
CronExpression
(
jobInfo
.
getJobCron
())
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
.
getNextValidTimeAfter
(
new
Date
(
jobInfo
.
getTriggerNextTime
()))
jobInfo
.
setTriggerNextTime
(
nextValidTime
.
getTime
());
.
getTime
()
}
else
{
);
jobInfo
.
setTriggerStatus
(
0
);
jobInfo
.
setTriggerLastTime
(
0
);
jobInfo
.
setTriggerNextTime
(
0
);
}
}
}
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
View file @
5b280137
...
@@ -194,7 +194,11 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -194,7 +194,11 @@ public class XxlJobServiceImpl implements XxlJobService {
long
nextTriggerTime
=
exists_jobInfo
.
getTriggerNextTime
();
long
nextTriggerTime
=
exists_jobInfo
.
getTriggerNextTime
();
if
(
exists_jobInfo
.
getTriggerStatus
()
==
1
&&
!
jobInfo
.
getJobCron
().
equals
(
exists_jobInfo
.
getJobCron
())
)
{
if
(
exists_jobInfo
.
getTriggerStatus
()
==
1
&&
!
jobInfo
.
getJobCron
().
equals
(
exists_jobInfo
.
getJobCron
())
)
{
try
{
try
{
nextTriggerTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
System
.
currentTimeMillis
()
+
JobScheduleHelper
.
PRE_READ_MS
)).
getTime
();
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
System
.
currentTimeMillis
()
+
JobScheduleHelper
.
PRE_READ_MS
));
if
(
nextValidTime
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_never_fire"
));
}
nextTriggerTime
=
nextValidTime
.
getTime
();
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_unvalid"
)+
" | "
+
e
.
getMessage
());
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_unvalid"
)+
" | "
+
e
.
getMessage
());
...
@@ -240,7 +244,11 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -240,7 +244,11 @@ public class XxlJobServiceImpl implements XxlJobService {
// next trigger time (5s后生效,避开预读周期)
// next trigger time (5s后生效,避开预读周期)
long
nextTriggerTime
=
0
;
long
nextTriggerTime
=
0
;
try
{
try
{
nextTriggerTime
=
new
CronExpression
(
xxlJobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
System
.
currentTimeMillis
()
+
JobScheduleHelper
.
PRE_READ_MS
)).
getTime
();
Date
nextValidTime
=
new
CronExpression
(
xxlJobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
System
.
currentTimeMillis
()
+
JobScheduleHelper
.
PRE_READ_MS
));
if
(
nextValidTime
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_never_fire"
));
}
nextTriggerTime
=
nextValidTime
.
getTime
();
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_unvalid"
)+
" | "
+
e
.
getMessage
());
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_unvalid"
)+
" | "
+
e
.
getMessage
());
...
...
xxl-job-admin/src/main/resources/i18n/message.properties
View file @
5b280137
...
@@ -109,6 +109,7 @@ jobinfo_field_jobdesc=任务描述
...
@@ -109,6 +109,7 @@ jobinfo_field_jobdesc=任务描述
jobinfo_field_gluetype
=
运行模式
jobinfo_field_gluetype
=
运行模式
jobinfo_field_executorparam
=
任务参数
jobinfo_field_executorparam
=
任务参数
jobinfo_field_cron_unvalid
=
Cron格式非法
jobinfo_field_cron_unvalid
=
Cron格式非法
jobinfo_field_cron_never_fire
=
Cron非法,永远不会触发
jobinfo_field_author
=
负责人
jobinfo_field_author
=
负责人
jobinfo_field_timeout
=
任务超时时间
jobinfo_field_timeout
=
任务超时时间
jobinfo_field_alarmemail
=
报警邮件
jobinfo_field_alarmemail
=
报警邮件
...
...
xxl-job-admin/src/main/resources/i18n/message_en.properties
View file @
5b280137
...
@@ -110,6 +110,7 @@ jobinfo_field_timeout=Job timeout period
...
@@ -110,6 +110,7 @@ jobinfo_field_timeout=Job timeout period
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
jobinfo_field_cron_never_fire
=
The Cron will never fire
jobinfo_field_author
=
Author
jobinfo_field_author
=
Author
jobinfo_field_alarmemail
=
Alarm email
jobinfo_field_alarmemail
=
Alarm email
jobinfo_field_alarmemail_placeholder
=
Please enter alarm mail, if there are more than one comma separated
jobinfo_field_alarmemail_placeholder
=
Please enter alarm mail, if there are more than one comma separated
...
...
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml
View file @
5b280137
...
@@ -219,7 +219,8 @@
...
@@ -219,7 +219,8 @@
UPDATE xxl_job_info
UPDATE xxl_job_info
SET
SET
trigger_last_time = #{triggerLastTime},
trigger_last_time = #{triggerLastTime},
trigger_next_time = #{triggerNextTime}
trigger_next_time = #{triggerNextTime},
trigger_status = #{triggerStatus}
WHERE id = #{id}
WHERE id = #{id}
</update>
</update>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment