fix(X-Pack): 定时报告任务停止实例未停止

This commit is contained in:
fit2cloud-chenyw 2024-05-17 10:20:40 +08:00
parent 4096ef1045
commit 349bb2126d
3 changed files with 18 additions and 4 deletions

View File

@ -29,7 +29,8 @@ public class DeTaskExecutor {
}
@XpackInteract(value = "xpackTaskExecutor", replace = true)
public void init() {}
public void init() {
}
public void addOrUpdateTask(Long taskId, String cron, Long startTime, Long endTime) {
if (CronUtils.taskExpire(endTime)) {
@ -46,10 +47,14 @@ public class DeTaskExecutor {
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, DeXpackScheduleJob.class, cron, new Date(startTime), end, jobDataMap);
}
public void fireNow(Long taskId) throws Exception {
public boolean fireNow(Long taskId) throws Exception {
String key = taskId.toString();
JobKey jobKey = new JobKey(key, JOB_GROUP);
scheduleManager.fireNow(jobKey);
if (scheduleManager.exist(jobKey)) {
scheduleManager.fireNow(jobKey);
return true;
}
return false;
}
public void addTempTask(Long taskId, Long startTime) {

View File

@ -431,4 +431,13 @@ public class ScheduleManager {
scheduler.triggerJob(jobKey);
}
public boolean exist(JobKey jobKey) {
try {
return scheduler.checkExists(jobKey);
} catch (SchedulerException e) {
LogUtil.error(e.getMessage(), new Throwable(e));
return false;
}
}
}

@ -1 +1 @@
Subproject commit 16f95eb5481cda834434b2c6f956b66a411ad67b
Subproject commit 96a9aef239d74efa6d6e7c3780d42409b065ae2a