[server] 修复bug
This commit is contained in:
@@ -94,13 +94,13 @@ public class ProxyNodeSet {
|
||||
|
||||
chengduAgent = ProxyNode
|
||||
.builder()
|
||||
.location("Chengdu")
|
||||
.location("Tokyo")
|
||||
.num(99)
|
||||
.publicIPv4("183.220.112.113")
|
||||
.publicIPv4("34.146.3.239")
|
||||
.proxyNodeType(ProxyNodeType.EXTERNAL)
|
||||
.name("chengdu-agent")
|
||||
.agentName("Chengdu-amd64-77")
|
||||
.agentTopicName("Chengdu-amd64-77-remote")
|
||||
.name("tokyo-07")
|
||||
.agentName("Tokyo-amd64-07")
|
||||
.agentTopicName("Tokyo-amd64-07-f66a41")
|
||||
.build();
|
||||
|
||||
ProxyNodeMap.put(chengdu.getNum(), chengdu);
|
||||
|
||||
@@ -88,7 +88,8 @@ public class CoreExecutionServiceImpl implements CoreExecutionService {
|
||||
"agentTopicName异常! 输入为 => {}",
|
||||
agentTopicName
|
||||
);
|
||||
throw new MyRuntimeException("agentTopicName异常!" + agentTopicName);
|
||||
return null;
|
||||
//throw new MyRuntimeException("agentTopicName异常!" + agentTopicName);
|
||||
}
|
||||
|
||||
// 归一化type类型 不行
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.wdd.rpc.scheduler.beans;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -54,6 +55,7 @@ public class ScriptSchedulerVO {
|
||||
* 脚本任务的内容
|
||||
*/
|
||||
@TableField(value = "script_content")
|
||||
@ApiModelProperty("单行命令之间使用 空格 分隔, 每一行之间使用 \\n 分隔")
|
||||
@Nullable
|
||||
private String scriptContent;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import io.wdd.server.beans.po.ScriptSchedulerPO;
|
||||
import io.wdd.server.service.ScriptSchedulerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quartz.*;
|
||||
@@ -33,20 +32,16 @@ import static org.quartz.TriggerBuilder.newTrigger;
|
||||
@Service
|
||||
public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
|
||||
@Resource
|
||||
ScriptSchedulerService scriptSchedulerService;
|
||||
|
||||
@Resource
|
||||
QuartzSchedulerUtils quartzSchedulerUtils;
|
||||
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
/**
|
||||
* 保存 定时脚本任务的中间DTO,在Quartz框架中JobDataMap的Key名称
|
||||
*/
|
||||
public static final String SCRIPT_SCHEDULER_MISSION_KEY = "scriptSchedulerDTO";
|
||||
|
||||
@Resource
|
||||
ScriptSchedulerService scriptSchedulerService;
|
||||
@Resource
|
||||
QuartzSchedulerUtils quartzSchedulerUtils;
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
@Override
|
||||
public HashMap<String, String> createScriptScheduledMission(ScriptSchedulerVO scriptSchedulerVO) {
|
||||
@@ -75,6 +70,7 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
dataMap
|
||||
);
|
||||
|
||||
// 生成下一次真正执行的任务ResultKey
|
||||
HashMap<String, String> futureExecutionResultKey = quartzSchedulerUtils.generateAndSetFutureExecutionResultKey(scriptSchedulerDTO);
|
||||
|
||||
log.debug(
|
||||
@@ -82,8 +78,14 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
futureExecutionResultKey
|
||||
);
|
||||
|
||||
log.info("[ 定时脚本任务 ] - 新建任务成功, 任务DTO为 => {}", scriptSchedulerDTO);
|
||||
log.info("[ 定时脚本任务 ] - 新建任务成功, 任务内容为 => {}", jobDetail);
|
||||
log.info(
|
||||
"[ 定时脚本任务 ] - 新建任务成功, 任务DTO为 => {}",
|
||||
scriptSchedulerDTO
|
||||
);
|
||||
log.info(
|
||||
"[ 定时脚本任务 ] - 新建任务成功, 任务内容为 => {}",
|
||||
jobDetail
|
||||
);
|
||||
|
||||
// persistent the script scheduled mission
|
||||
// dto should store more info
|
||||
@@ -132,23 +134,31 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
}
|
||||
|
||||
// 归一化 completeCommandList
|
||||
List<List<String>> completeCommandList = FunctionReader.ReadStringToCommandList(scriptSchedulerVO.getScriptContent());
|
||||
List<List<String>> completeCommandList = FunctionReader
|
||||
.ReadStringToCommandList(scriptSchedulerVO.getScriptContent());
|
||||
|
||||
if (completeCommandList.size() == 0) {
|
||||
throw new MyRuntimeException("completeCommandList parse wrong !");
|
||||
throw new MyRuntimeException("完整的命令脚本列表解析错误!");
|
||||
}
|
||||
|
||||
// 执行机器目标归一化
|
||||
String[] targetMachineSplit = scriptSchedulerVO
|
||||
.getTargetMachine()
|
||||
.split(",");
|
||||
if (targetMachineSplit.length == 0) {
|
||||
List<String> goodTargetMachine = Arrays
|
||||
.stream(targetMachineSplit)
|
||||
.map(
|
||||
machine -> machine.replace(
|
||||
" ",
|
||||
""
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
if (goodTargetMachine.size() == 0) {
|
||||
throw new MyRuntimeException("target machine wrong !");
|
||||
}
|
||||
ArrayList<String> targetMachineList = new ArrayList<>();
|
||||
Collections.addAll(
|
||||
targetMachineList,
|
||||
targetMachineSplit
|
||||
);
|
||||
// 防止于最终对线中
|
||||
ArrayList<String> targetMachineList = new ArrayList<>(goodTargetMachine);
|
||||
|
||||
// 生成DTO对象
|
||||
ScriptSchedulerDTO dto = new ScriptSchedulerDTO();
|
||||
@@ -317,7 +327,7 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
trigger
|
||||
);
|
||||
|
||||
return jobDetail;
|
||||
return jobDetail;
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -576,8 +586,10 @@ public class QuartzSchedulerServiceImpl implements QuartzSchedulerService {
|
||||
// 修改JobDetail信息
|
||||
ScriptSchedulerDTO scriptSchedulerDTO = validateAndConvertToScriptSchedulerDTO(scriptSchedulerVO);
|
||||
JobDataMap map = jobDetail.getJobDataMap();
|
||||
map.put(SCRIPT_SCHEDULER_MISSION_KEY,
|
||||
scriptSchedulerDTO);
|
||||
map.put(
|
||||
SCRIPT_SCHEDULER_MISSION_KEY,
|
||||
scriptSchedulerDTO
|
||||
);
|
||||
|
||||
// 修改 Mission相应的 cron时间信息
|
||||
updateMission(
|
||||
|
||||
Reference in New Issue
Block a user