|
|
@ -5,7 +5,6 @@ import com.xxl.job.admin.core.model.XxlJobGroup;
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
|
|
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
|
|
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
|
|
|
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
|
|
|
|
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
|
|
|
|
import com.xxl.job.admin.core.util.JobKeyUtil;
|
|
|
|
|
|
|
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
|
|
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
|
|
|
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
|
|
|
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
|
|
|
import com.xxl.job.admin.dao.XxlJobLogDao;
|
|
|
|
import com.xxl.job.admin.dao.XxlJobLogDao;
|
|
|
@ -104,19 +103,20 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
|
|
|
|
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// childJobKey valid
|
|
|
|
// ChildJobId valid
|
|
|
|
if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) {
|
|
|
|
if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
|
|
|
String[] childJobKeys = jobInfo.getChildJobKey().split(",");
|
|
|
|
String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
|
|
|
for (String childJobKeyItem: childJobKeys) {
|
|
|
|
for (String childJobIdItem: childJobIds) {
|
|
|
|
int childJobId = JobKeyUtil.parseJobId(childJobKeyItem);
|
|
|
|
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
|
|
|
if (childJobId <= 0) {
|
|
|
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务Key({0})格式错误", childJobKeyItem));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(childJobId);
|
|
|
|
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务Key({0})无效", childJobKeyItem));
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})无效", childJobIdItem));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})格式错误", childJobIdItem));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// add in db
|
|
|
|
// add in db
|
|
|
@ -167,19 +167,24 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, "失败处理策略非法");
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, "失败处理策略非法");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// childJobKey valid
|
|
|
|
// ChildJobId valid
|
|
|
|
if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) {
|
|
|
|
if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
|
|
|
String[] childJobKeys = jobInfo.getChildJobKey().split(",");
|
|
|
|
String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
|
|
|
for (String childJobKeyItem: childJobKeys) {
|
|
|
|
for (String childJobIdItem: childJobIds) {
|
|
|
|
int childJobId = JobKeyUtil.parseJobId(childJobKeyItem);
|
|
|
|
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
|
|
|
if (childJobId <= 0) {
|
|
|
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务Key({0})格式错误", childJobKeyItem));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(childJobId);
|
|
|
|
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务Key({0})无效", childJobKeyItem));
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})无效", childJobIdItem));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// avoid cycle relate
|
|
|
|
|
|
|
|
if (childJobInfo.getId() == jobInfo.getId()) {
|
|
|
|
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})不可与父任务重复", childJobIdItem));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})格式错误", childJobIdItem));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// stage job info
|
|
|
|
// stage job info
|
|
|
@ -198,7 +203,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam());
|
|
|
|
exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam());
|
|
|
|
exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
|
|
|
|
exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
|
|
|
|
exists_jobInfo.setExecutorFailStrategy(jobInfo.getExecutorFailStrategy());
|
|
|
|
exists_jobInfo.setExecutorFailStrategy(jobInfo.getExecutorFailStrategy());
|
|
|
|
exists_jobInfo.setChildJobKey(jobInfo.getChildJobKey());
|
|
|
|
exists_jobInfo.setChildJobId(jobInfo.getChildJobId());
|
|
|
|
xxlJobInfoDao.update(exists_jobInfo);
|
|
|
|
xxlJobInfoDao.update(exists_jobInfo);
|
|
|
|
|
|
|
|
|
|
|
|
// fresh quartz
|
|
|
|
// fresh quartz
|
|
|
|