Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ private List<Long> getExecutionDelaySeconds(long windowStartTimeMs, long windowE

// Calculate the trigger time list
for (long triggerTime = firstTriggerTime; triggerTime <= windowEndTimeMs; triggerTime += intervalMs) {
if (triggerTime >= currentTimeMs && (null == timerDefinition.getEndTimeMs()
|| triggerTime < timerDefinition.getEndTimeMs())) {
if (null == timerDefinition.getEndTimeMs()
|| triggerTime < timerDefinition.getEndTimeMs()) {
timerDefinition.setLatestSchedulerTimeMs(triggerTime);
timestamps.add(queryDelayTimeSecond(currentTimeMs, triggerTime));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void scheduleOneJob(T job) throws JobException {
schedulerInstantJob(job, TaskType.SCHEDULED, null);
}
//if it's timer job and trigger last window already start, we will scheduler it immediately
cycleTimerJobScheduler(job);
cycleTimerJobScheduler(job, System.currentTimeMillis());
}

@Override
Expand All @@ -139,9 +139,9 @@ public void close() throws IOException {
}


private void cycleTimerJobScheduler(T job) {
private void cycleTimerJobScheduler(T job, long startTimeWindowMs) {
List<Long> delaySeconds = job.getJobConfig().getTriggerDelayTimes(System.currentTimeMillis(),
System.currentTimeMillis(), latestBatchSchedulerTimerTaskTimeMs);
startTimeWindowMs, latestBatchSchedulerTimerTaskTimeMs);
if (CollectionUtils.isNotEmpty(delaySeconds)) {
delaySeconds.forEach(delaySecond -> {
TimerJobSchedulerTask<T> timerJobSchedulerTask = new TimerJobSchedulerTask<>(timerJobDisruptor, job);
Expand Down Expand Up @@ -170,6 +170,8 @@ public void schedulerInstantJob(T job, TaskType taskType, C context) {
* We will get the task in the next time window, and then hand it over to the time wheel for timing trigger
*/
private void executeTimerJobIdsWithinLastTenMinutesWindow() {

long lastTimeWindowMs = latestBatchSchedulerTimerTaskTimeMs;
if (latestBatchSchedulerTimerTaskTimeMs < System.currentTimeMillis()) {
this.latestBatchSchedulerTimerTaskTimeMs = System.currentTimeMillis();
}
Expand All @@ -186,7 +188,7 @@ private void executeTimerJobIdsWithinLastTenMinutesWindow() {
if (!job.getJobStatus().equals(JobStatus.RUNNING) && !job.getJobConfig().checkIsTimerJob()) {
continue;
}
cycleTimerJobScheduler(job);
cycleTimerJobScheduler(job, lastTimeWindowMs);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testGetTriggerDelayTimesRecurring() {
Assertions.assertArrayEquals(new Long[]{ 500L}, delayTimes.toArray());
delayTimes = configuration.getTriggerDelayTimes(
1001000L, 0L, 1000000L);
Assertions.assertEquals(0, delayTimes.size());
Assertions.assertEquals(1, delayTimes.size());
}

}