0528 ljc
This commit is contained in:
parent
c049f3b9dc
commit
4a6510a27b
@ -9,13 +9,10 @@ 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;
|
||||
@ -68,7 +65,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());
|
||||
@ -132,24 +129,4 @@ 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,6 +2,7 @@ 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;
|
||||
@ -27,6 +28,7 @@ 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