Compare commits
No commits in common. "0ddcbe43bf693eaccee38ca279fe60e422d4fc04" and "d7a852d55618bb8b3b929237212624d8b94e0d75" have entirely different histories.
0ddcbe43bf
...
d7a852d556
@ -9,10 +9,13 @@ import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.matchers.GroupMatcher;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.quartz.JobBuilder.newJob;
|
||||
import static org.quartz.TriggerBuilder.newTrigger;
|
||||
@ -65,7 +68,7 @@ public class QuartzSchedulerManager {
|
||||
List<PipelineSchedulingProperties> list = pipelineSchedulingPropertiesDao.selectList(wrapper);
|
||||
|
||||
//为空则数据入库,否则仅为重新添加任务进调度器
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
PipelineSchedulingProperties pipelineSchedulingProperties = new PipelineSchedulingProperties();
|
||||
pipelineSchedulingProperties.setPipelineId(req.getPipelineId());
|
||||
pipelineSchedulingProperties.setCron(req.getCron());
|
||||
@ -129,4 +132,24 @@ public class QuartzSchedulerManager {
|
||||
|
||||
log.info("任务 [{}] 已重启", req.getPipelineId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断任务是否已停止
|
||||
*/
|
||||
public boolean isTaskPaused(PipelineSchedulingReq req) throws SchedulerException {
|
||||
JobKey jobKey = JobKey.jobKey(req.getPipelineId(), JOB_GROUP_NAME);
|
||||
return !scheduler.isStarted() || scheduler.getJobDetail(jobKey) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有任务 ID
|
||||
*/
|
||||
public Set<String> getAllTaskIds() throws SchedulerException {
|
||||
Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(JOB_GROUP_NAME));
|
||||
Set<String> taskIds = new HashSet<>();
|
||||
for (JobKey jobKey : jobKeys) {
|
||||
taskIds.add(jobKey.getName());
|
||||
}
|
||||
return taskIds;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package cd.casic.ci.process.engine.scheduler.job;
|
||||
|
||||
import cd.casic.ci.process.engine.executor.PipelineExecutor;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
@ -28,7 +27,6 @@ public class PipelineSchedulingJob implements Job {
|
||||
|
||||
if (pipelineId != null && executor != null) {
|
||||
executor.execute(pipelineId);
|
||||
System.out.println("定时任务开始执行,当前执行时间为" + new LocalDateTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user