forked from github/dataease
perf(X-Pack): 阈值告警定时任务
This commit is contained in:
parent
370438d21b
commit
f250417851
@ -22,6 +22,8 @@ public class DeTaskExecutor {
|
||||
private static final String RETRY_JOB_GROUP = "RETRY_REPORT_TASK";
|
||||
private static final String TEMP_JOB_GROUP = "TEMP_REPORT_TASK";
|
||||
|
||||
private static final String THRESHOLD_JOB_GROUP = "THRESHOLD_TASK";
|
||||
|
||||
@Resource
|
||||
private ScheduleManager scheduleManager;
|
||||
|
||||
@ -34,6 +36,21 @@ public class DeTaskExecutor {
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public void addThresholdTask(Long taskId, String cron, Long startTime, Long endTime) {
|
||||
String key = taskId.toString();
|
||||
JobKey jobKey = new JobKey(key, THRESHOLD_JOB_GROUP);
|
||||
TriggerKey triggerKey = new TriggerKey(key, THRESHOLD_JOB_GROUP);
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("taskId", taskId);
|
||||
jobDataMap.put("threshold", taskId);
|
||||
Date end = null;
|
||||
if (CronUtils.taskExpire(endTime)) {
|
||||
return;
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(endTime)) end = new Date(endTime);
|
||||
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, DeXpackScheduleJob.class, cron, new Date(startTime), end, jobDataMap);
|
||||
}
|
||||
|
||||
public void addOrUpdateTask(Long taskId, String cron, Long startTime, Long endTime) {
|
||||
if (CronUtils.taskExpire(endTime)) {
|
||||
return;
|
||||
@ -106,6 +123,13 @@ public class DeTaskExecutor {
|
||||
scheduleManager.removeJob(jobKey, triggerKey);
|
||||
}
|
||||
|
||||
public void removeThresholdTask(Long taskId) {
|
||||
String key = taskId.toString();
|
||||
JobKey jobKey = new JobKey(key, THRESHOLD_JOB_GROUP);
|
||||
TriggerKey triggerKey = new TriggerKey(key, THRESHOLD_JOB_GROUP);
|
||||
scheduleManager.removeJob(jobKey, triggerKey);
|
||||
}
|
||||
|
||||
public void clearRetryTask() throws Exception {
|
||||
scheduleManager.clearByGroup(RETRY_JOB_GROUP);
|
||||
}
|
||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
||||
Subproject commit 97d1dee3db56b863d7a4b4b56248fd4e6a18a843
|
||||
Subproject commit 11a3b6a066147549ac484dce7d8b4bbc2508f93a
|
Loading…
Reference in New Issue
Block a user