Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
tool
/
xxl-job
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f7c2e5e8
authored
Jul 19, 2019
by
xuxueli
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update document
1 parent
107a2092
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java
View file @
f7c2e5e
...
@@ -67,16 +67,16 @@ public class JobScheduleHelper {
...
@@ -67,16 +67,16 @@ public class JobScheduleHelper {
// tx start
// tx start
// 1、
预读5s内调度任务
// 1、
pre read
long
nowTime
=
System
.
currentTimeMillis
();
long
nowTime
=
System
.
currentTimeMillis
();
List
<
XxlJobInfo
>
scheduleList
=
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobInfoDao
().
scheduleJobQuery
(
nowTime
+
PRE_READ_MS
);
List
<
XxlJobInfo
>
scheduleList
=
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobInfoDao
().
scheduleJobQuery
(
nowTime
+
PRE_READ_MS
);
if
(
scheduleList
!=
null
&&
scheduleList
.
size
()>
0
)
{
if
(
scheduleList
!=
null
&&
scheduleList
.
size
()>
0
)
{
// 2、
推送时间轮
// 2、
push time-ring
for
(
XxlJobInfo
jobInfo:
scheduleList
)
{
for
(
XxlJobInfo
jobInfo:
scheduleList
)
{
//
时间轮刻度计算
//
time-ring jump
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
()
+
PRE_READ_MS
)
{
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
()
+
PRE_READ_MS
)
{
//
过期超5s:本地忽略,当前时间开始计算下次触发时间
//
2.1、trigger-expire > 5s:pass && make next-trigger-time
// fresh next
// fresh next
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
());
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
());
...
@@ -90,7 +90,7 @@ public class JobScheduleHelper {
...
@@ -90,7 +90,7 @@ public class JobScheduleHelper {
}
}
}
else
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
())
{
}
else
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
())
{
//
过期5s内 :立即触发一次,当前时间开始计算下次触发时间;
//
2.2、trigger-expire < 5s:direct-trigger && make next-trigger-time
CronExpression
cronExpression
=
new
CronExpression
(
jobInfo
.
getJobCron
());
CronExpression
cronExpression
=
new
CronExpression
(
jobInfo
.
getJobCron
());
long
nextTime
=
cronExpression
.
getNextValidTimeAfter
(
new
Date
()).
getTime
();
long
nextTime
=
cronExpression
.
getNextValidTimeAfter
(
new
Date
()).
getTime
();
...
@@ -104,7 +104,7 @@ public class JobScheduleHelper {
...
@@ -104,7 +104,7 @@ public class JobScheduleHelper {
jobInfo
.
setTriggerNextTime
(
nextTime
);
jobInfo
.
setTriggerNextTime
(
nextTime
);
//
下次5s内:预读一次;
//
next-trigger-time in 5s, pre-read again
if
(
jobInfo
.
getTriggerNextTime
()
-
nowTime
<
PRE_READ_MS
)
{
if
(
jobInfo
.
getTriggerNextTime
()
-
nowTime
<
PRE_READ_MS
)
{
// 1、make ring second
// 1、make ring second
...
@@ -127,7 +127,7 @@ public class JobScheduleHelper {
...
@@ -127,7 +127,7 @@ public class JobScheduleHelper {
}
}
}
else
{
}
else
{
//
未过期:正常触发,递增计算下次触发时间
//
2.3、trigger-pre-read:time-ring trigger && make next-trigger-time
// 1、make ring second
// 1、make ring second
int
ringSecond
=
(
int
)((
jobInfo
.
getTriggerNextTime
()/
1000
)%
60
);
int
ringSecond
=
(
int
)((
jobInfo
.
getTriggerNextTime
()/
1000
)%
60
);
...
@@ -150,7 +150,7 @@ public class JobScheduleHelper {
...
@@ -150,7 +150,7 @@ public class JobScheduleHelper {
}
}
// 3、
更新trigger信息
// 3、
update trigger info
for
(
XxlJobInfo
jobInfo:
scheduleList
)
{
for
(
XxlJobInfo
jobInfo:
scheduleList
)
{
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobInfoDao
().
scheduleUpdate
(
jobInfo
);
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobInfoDao
().
scheduleUpdate
(
jobInfo
);
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment