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
2247be23
authored
Nov 01, 2019
by
许雪里
Committed by
GitHub
Nov 01, 2019
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #1211 from qinnnyul/refactor-extract-common-method
extract method to avoid duplicated codes
parents
ac70dea4
8b9f80f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
27 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 @
2247be23
...
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
...
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -82,15 +83,7 @@ public class JobScheduleHelper {
...
@@ -82,15 +83,7 @@ public class JobScheduleHelper {
// 2.1、trigger-expire > 5s:pass && make next-trigger-time
// 2.1、trigger-expire > 5s:pass && make next-trigger-time
// fresh next
// fresh next
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
());
refreshNextValidTime
(
jobInfo
,
new
Date
());
if
(
nextValidTime
!=
null
)
{
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
jobInfo
.
setTriggerNextTime
(
nextValidTime
.
getTime
());
}
else
{
jobInfo
.
setTriggerStatus
(
0
);
jobInfo
.
setTriggerLastTime
(
0
);
jobInfo
.
setTriggerNextTime
(
0
);
}
}
else
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
())
{
}
else
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
())
{
// 2.2、trigger-expire < 5s:direct-trigger && make next-trigger-time
// 2.2、trigger-expire < 5s:direct-trigger && make next-trigger-time
...
@@ -117,15 +110,7 @@ public class JobScheduleHelper {
...
@@ -117,15 +110,7 @@ public class JobScheduleHelper {
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
// 3、fresh next
// 3、fresh next
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
jobInfo
.
getTriggerNextTime
()));
refreshNextValidTime
(
jobInfo
,
new
Date
(
jobInfo
.
getTriggerNextTime
()));
if
(
nextValidTime
!=
null
)
{
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
jobInfo
.
setTriggerNextTime
(
nextValidTime
.
getTime
());
}
else
{
jobInfo
.
setTriggerStatus
(
0
);
jobInfo
.
setTriggerLastTime
(
0
);
jobInfo
.
setTriggerNextTime
(
0
);
}
}
}
...
@@ -139,15 +124,7 @@ public class JobScheduleHelper {
...
@@ -139,15 +124,7 @@ public class JobScheduleHelper {
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
pushTimeRing
(
ringSecond
,
jobInfo
.
getId
());
// 3、fresh next
// 3、fresh next
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
new
Date
(
jobInfo
.
getTriggerNextTime
()));
refreshNextValidTime
(
jobInfo
,
new
Date
(
jobInfo
.
getTriggerNextTime
()));
if
(
nextValidTime
!=
null
)
{
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
jobInfo
.
setTriggerNextTime
(
nextValidTime
.
getTime
());
}
else
{
jobInfo
.
setTriggerStatus
(
0
);
jobInfo
.
setTriggerLastTime
(
0
);
jobInfo
.
setTriggerNextTime
(
0
);
}
}
}
...
@@ -293,6 +270,18 @@ public class JobScheduleHelper {
...
@@ -293,6 +270,18 @@ public class JobScheduleHelper {
ringThread
.
start
();
ringThread
.
start
();
}
}
private
void
refreshNextValidTime
(
XxlJobInfo
jobInfo
,
Date
date
)
throws
ParseException
{
Date
nextValidTime
=
new
CronExpression
(
jobInfo
.
getJobCron
()).
getNextValidTimeAfter
(
date
);
if
(
nextValidTime
!=
null
)
{
jobInfo
.
setTriggerLastTime
(
jobInfo
.
getTriggerNextTime
());
jobInfo
.
setTriggerNextTime
(
nextValidTime
.
getTime
());
}
else
{
jobInfo
.
setTriggerStatus
(
0
);
jobInfo
.
setTriggerLastTime
(
0
);
jobInfo
.
setTriggerNextTime
(
0
);
}
}
private
void
pushTimeRing
(
int
ringSecond
,
int
jobId
){
private
void
pushTimeRing
(
int
ringSecond
,
int
jobId
){
// push async ring
// push async ring
List
<
Integer
>
ringItemData
=
ringData
.
get
(
ringSecond
);
List
<
Integer
>
ringItemData
=
ringData
.
get
(
ringSecond
);
...
...
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