[ server ] [ scheduler ]- script scheduler accomplish - 1
This commit is contained in:
@@ -53,7 +53,7 @@ public class SchedulerController {
|
||||
@ApiOperation(value = "[脚本]-删除定时脚本任务")
|
||||
@PostMapping(value = "/script/delete")
|
||||
public R<Boolean> deleteScriptScheduler(
|
||||
@RequestParam(value = "scriptJobUUID") @ApiParam(value = "scriptJobUUID", name = "定时脚本任务UUID") String scriptJobUUID
|
||||
@RequestParam(value = "scriptJobUUID") @ApiParam(value = "定时脚本任务UUID", name = "scriptJobUUID") String scriptJobUUID
|
||||
) {
|
||||
|
||||
return R.ok(octopusQuartzService.deleteScriptScheduleMission(scriptJobUUID));
|
||||
|
||||
@@ -26,7 +26,7 @@ public class QuartzSchedulerUtils {
|
||||
* @param scriptSchedulerDTO dto
|
||||
* @return dto中存储的 未来ExecutionKey对象
|
||||
*/
|
||||
public HashMap<String, String> getFutureExecutionResultKey(ScriptSchedulerDTO scriptSchedulerDTO) {
|
||||
public HashMap<String, String> generateAndSetFutureExecutionResultKey(ScriptSchedulerDTO scriptSchedulerDTO) {
|
||||
|
||||
ArrayList<LocalDateTime> time = getLastNextExecutionTime(
|
||||
scriptSchedulerDTO.getSchedulerUuid(),
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static io.wdd.rpc.scheduler.service.QuartzSchedulerServiceImpl.SCRIPT_SCHEDULER_MISSION_KEY;
|
||||
|
||||
public class AgentScriptSchedulerJob extends QuartzJobBean {
|
||||
|
||||
@Resource
|
||||
@@ -24,7 +26,7 @@ public class AgentScriptSchedulerJob extends QuartzJobBean {
|
||||
.getJobDataMap();
|
||||
|
||||
// ScriptScheduleDTO
|
||||
ScriptSchedulerDTO scriptSchedulerDTO = (ScriptSchedulerDTO) jobDataMap.get("scriptSchedulerDTO");
|
||||
ScriptSchedulerDTO scriptSchedulerDTO = (ScriptSchedulerDTO) jobDataMap.get(SCRIPT_SCHEDULER_MISSION_KEY);
|
||||
|
||||
// 调用实际任务执行器
|
||||
agentApplyScheduledScript.apply(scriptSchedulerDTO);
|
||||
|
||||
@@ -48,6 +48,10 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
/**
|
||||
* 保存 定时脚本任务的中间DTO,在Quartz框架中JobDataMap的Key名称
|
||||
*/
|
||||
public static final String SCRIPT_SCHEDULER_MISSION_KEY = "scriptSchedulerDTO";
|
||||
/**
|
||||
* --------------------------------------------------------------
|
||||
* 页面定时任务部分
|
||||
@@ -68,7 +72,7 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
// bind job and trigger
|
||||
HashMap<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put(
|
||||
"scriptSchedulerDTO",
|
||||
SCRIPT_SCHEDULER_MISSION_KEY,
|
||||
scriptSchedulerDTO
|
||||
);
|
||||
this.addMission(
|
||||
@@ -83,7 +87,7 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
dataMap
|
||||
);
|
||||
|
||||
HashMap<String, String> futureExecutionResultKey = quartzSchedulerUtils.getFutureExecutionResultKey(scriptSchedulerDTO);
|
||||
HashMap<String, String> futureExecutionResultKey = quartzSchedulerUtils.generateAndSetFutureExecutionResultKey(scriptSchedulerDTO);
|
||||
|
||||
log.info(
|
||||
"futureExecutionResultKey is => {}",
|
||||
@@ -602,6 +606,9 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
// 该Job存在
|
||||
// 修改JobDetail信息
|
||||
ScriptSchedulerDTO scriptSchedulerDTO = validateAndConvertToScriptSchedulerDTO(scriptSchedulerVO);
|
||||
JobDataMap map = jobDetail.getJobDataMap();
|
||||
map.put(SCRIPT_SCHEDULER_MISSION_KEY,
|
||||
scriptSchedulerDTO);
|
||||
|
||||
// 修改 Mission相应的 cron时间信息
|
||||
updateMission(
|
||||
@@ -610,6 +617,9 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
scriptSchedulerDTO.getCronExpress()
|
||||
);
|
||||
|
||||
// 修改任务计划执行时间Key
|
||||
quartzSchedulerUtils.generateAndSetFutureExecutionResultKey(scriptSchedulerDTO);
|
||||
|
||||
return jobDetail;
|
||||
}
|
||||
|
||||
@@ -670,7 +680,8 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
|
||||
return scheduler
|
||||
.getTriggerKeys(
|
||||
GroupMatcher.groupEquals(JOB_GROUP_NAME)
|
||||
// GroupMatcher.groupEquals(JOB_GROUP_NAME)
|
||||
GroupMatcher.anyGroup()
|
||||
)
|
||||
.stream()
|
||||
.map(
|
||||
|
||||
@@ -42,7 +42,7 @@ public class AgentApplyScheduledScript {
|
||||
scriptSchedulerDTO.setResultKeyList(resultKeyList);
|
||||
|
||||
// 更新DTO中的下次执行时间 否则会出错
|
||||
HashMap<String, String> futureExecutionResultKey = quartzSchedulerUtils.getFutureExecutionResultKey(scriptSchedulerDTO);
|
||||
HashMap<String, String> futureExecutionResultKey = quartzSchedulerUtils.generateAndSetFutureExecutionResultKey(scriptSchedulerDTO);
|
||||
|
||||
log.info(
|
||||
"futureExecutionResultKey in scheduled work is => {}",
|
||||
|
||||
Reference in New Issue
Block a user