任务失败重试优化:收敛并废弃现有失败重试策略,新增任务属性 "失败重试次数",支持自定义失败重试次数,任务失败时将会根据该值进行失败重试;

v1.9.2
xuxueli 6 years ago
parent 3ff35766b8
commit c2d6b3ac14

@ -951,7 +951,6 @@ echo "分片总数 total = $3"
--- | --- | --- --- | --- | ---
成功 | IJobHandler.SUCCESS | 0 成功 | IJobHandler.SUCCESS | 0
失败 | IJobHandler.FAIL | -1其他 失败 | IJobHandler.FAIL | -1其他
失败重试 | IJobHandler.FAIL_RETRY | 101
### 5.16 任务超时控制 ### 5.16 任务超时控制
支持设置任务超时时间,任务运行超时的情况下,将会主动中断任务; 支持设置任务超时时间,任务运行超时的情况下,将会主动中断任务;
@ -1241,7 +1240,9 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 22、告警邮件固定使用 UTF-8 编码格式,修复由机器编码导致的邮件乱码问题; - 22、告警邮件固定使用 UTF-8 编码格式,修复由机器编码导致的邮件乱码问题;
- 23、新增任务运行模式 "GLUE模式(PHP) "支持php脚本任务 - 23、新增任务运行模式 "GLUE模式(PHP) "支持php脚本任务
- 24、执行器手动设置IP时取消绑定Host的操作该IP仅供执行器注册使用修复指定外网IP时无法绑定执行器Host的问题 - 24、执行器手动设置IP时取消绑定Host的操作该IP仅供执行器注册使用修复指定外网IP时无法绑定执行器Host的问题
- 25、[迭代中]任务失败重试优化:收敛并废弃现有失败重试策略,新增任务属性 "失败重试次数",支持自定义失败重试次数,任务失败时将会根据该值进行失败重试; - 25、任务失败重试优化收敛并废弃现有失败重试策略如调度失败、执行失败、状态码失败等新增任务属性 "失败重试次数",支持自定义失败重试次数,任务失败时将会根据该值进行失败重试;
- 26、【迭代中】父子任务循环限制放开支持特殊场景
- 27、【迭代中】API服务支持动态参数
### TODO LIST ### TODO LIST

@ -162,7 +162,6 @@ CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_INFO` (
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler', `executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数', `executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
`executor_block_strategy` varchar(50) DEFAULT NULL COMMENT '阻塞处理策略', `executor_block_strategy` varchar(50) DEFAULT NULL COMMENT '阻塞处理策略',
`executor_fail_strategy` varchar(50) DEFAULT NULL COMMENT '失败处理策略',
`executor_timeout` int(11) NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒', `executor_timeout` int(11) NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒',
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数', `executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
`glue_type` varchar(50) NOT NULL COMMENT 'GLUE类型', `glue_type` varchar(50) NOT NULL COMMENT 'GLUE类型',
@ -181,6 +180,7 @@ CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_LOG` (
`executor_address` varchar(255) DEFAULT NULL COMMENT '执行器地址,本次执行的地址', `executor_address` varchar(255) DEFAULT NULL COMMENT '执行器地址,本次执行的地址',
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler', `executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数', `executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
`trigger_time` datetime DEFAULT NULL COMMENT '调度-时间', `trigger_time` datetime DEFAULT NULL COMMENT '调度-时间',
`trigger_code` int(11) NOT NULL COMMENT '调度-结果', `trigger_code` int(11) NOT NULL COMMENT '调度-结果',
`trigger_msg` varchar(2048) DEFAULT NULL COMMENT '调度-日志', `trigger_msg` varchar(2048) DEFAULT NULL COMMENT '调度-日志',

@ -3,6 +3,7 @@ package com.xxl.job.admin.controller;
import com.xxl.job.admin.core.model.XxlJobGroup; 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.thread.JobTriggerPoolHelper;
import com.xxl.job.admin.dao.XxlJobGroupDao; import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.service.XxlJobService; import com.xxl.job.admin.service.XxlJobService;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
@ -89,7 +90,8 @@ public class JobInfoController {
@RequestMapping("/trigger") @RequestMapping("/trigger")
@ResponseBody @ResponseBody
public ReturnT<String> triggerJob(int id) { public ReturnT<String> triggerJob(int id) {
return xxlJobService.triggerJob(id); JobTriggerPoolHelper.trigger(id, -1);
return ReturnT.SUCCESS;
} }
} }

@ -1,36 +0,0 @@
package com.xxl.job.admin.core.enums;
/**
* Created by xuxueli on 17/5/9.
*/
@Deprecated
public enum ExecutorFailStrategyEnum {
NULL("NULL"),
FAIL_TRIGGER_RETRY("FAIL_TRIGGER_RETRY"),
FAIL_HANDLE_RETRY("FAIL_HANDLE_RETRY");
private final String title;
private ExecutorFailStrategyEnum(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public static ExecutorFailStrategyEnum match(String name, ExecutorFailStrategyEnum defaultItem) {
if (name != null) {
for (ExecutorFailStrategyEnum item: ExecutorFailStrategyEnum.values()) {
if (item.name().equals(name)) {
return item;
}
}
}
return defaultItem;
}
}

@ -27,7 +27,7 @@ public class RemoteHttpJobBean extends QuartzJobBean {
// trigger // trigger
//XxlJobTrigger.trigger(jobId); //XxlJobTrigger.trigger(jobId);
JobTriggerPoolHelper.trigger(jobId); JobTriggerPoolHelper.trigger(jobId, -1);
} }
} }

@ -25,7 +25,6 @@ public class XxlJobInfo {
private String executorHandler; // 执行器任务Handler名称 private String executorHandler; // 执行器任务Handler名称
private String executorParam; // 执行器,任务参数 private String executorParam; // 执行器,任务参数
private String executorBlockStrategy; // 阻塞处理策略 private String executorBlockStrategy; // 阻塞处理策略
private String executorFailStrategy; // 失败处理策略
private int executorTimeout; // 任务执行超时时间,单位秒 private int executorTimeout; // 任务执行超时时间,单位秒
private int executorFailRetryCount; // 失败重试次数 private int executorFailRetryCount; // 失败重试次数
@ -136,14 +135,6 @@ public class XxlJobInfo {
this.executorBlockStrategy = executorBlockStrategy; this.executorBlockStrategy = executorBlockStrategy;
} }
public String getExecutorFailStrategy() {
return executorFailStrategy;
}
public void setExecutorFailStrategy(String executorFailStrategy) {
this.executorFailStrategy = executorFailStrategy;
}
public int getExecutorTimeout() { public int getExecutorTimeout() {
return executorTimeout; return executorTimeout;
} }

@ -21,6 +21,7 @@ public class XxlJobLog {
private String executorAddress; private String executorAddress;
private String executorHandler; private String executorHandler;
private String executorParam; private String executorParam;
private int executorFailRetryCount;
// trigger info // trigger info
private Date triggerTime; private Date triggerTime;
@ -88,6 +89,14 @@ public class XxlJobLog {
this.executorParam = executorParam; this.executorParam = executorParam;
} }
public int getExecutorFailRetryCount() {
return executorFailRetryCount;
}
public void setExecutorFailRetryCount(int executorFailRetryCount) {
this.executorFailRetryCount = executorFailRetryCount;
}
public Date getTriggerTime() { public Date getTriggerTime() {
return triggerTime; return triggerTime;
} }

@ -28,11 +28,11 @@ public class JobTriggerPoolHelper {
new ThreadPoolExecutor.CallerRunsPolicy()); new ThreadPoolExecutor.CallerRunsPolicy());
public void addTrigger(final int jobId){ public void addTrigger(final int jobId, final int failRetryCount){
triggerPool.execute(new Runnable() { triggerPool.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
XxlJobTrigger.trigger(jobId); XxlJobTrigger.trigger(jobId, failRetryCount);
} }
}); });
} }
@ -47,9 +47,16 @@ public class JobTriggerPoolHelper {
private static JobTriggerPoolHelper helper = new JobTriggerPoolHelper(); private static JobTriggerPoolHelper helper = new JobTriggerPoolHelper();
/**
public static void trigger(int jobId) { *
helper.addTrigger(jobId); * @param jobId
* @param failRetryCount
* >=0: use this param
* <0: use param from job info config
*
*/
public static void trigger(int jobId, int failRetryCount) {
helper.addTrigger(jobId, failRetryCount);
} }
public static void toStop(){ public static void toStop(){

@ -1,12 +1,12 @@
package com.xxl.job.admin.core.trigger; package com.xxl.job.admin.core.trigger;
import com.xxl.job.admin.core.enums.ExecutorFailStrategyEnum;
import com.xxl.job.admin.core.model.XxlJobGroup; 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.model.XxlJobLog; import com.xxl.job.admin.core.model.XxlJobLog;
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.thread.JobFailMonitorHelper; import com.xxl.job.admin.core.thread.JobFailMonitorHelper;
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
import com.xxl.job.admin.core.util.I18nUtil; import com.xxl.job.admin.core.util.I18nUtil;
import com.xxl.job.core.biz.ExecutorBiz; import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
@ -31,8 +31,12 @@ public class XxlJobTrigger {
* trigger job * trigger job
* *
* @param jobId * @param jobId
* @param failRetryCount
* >=0: use this param
* <0: use param from job info config
*
*/ */
public static void trigger(int jobId) { public static void trigger(int jobId, int failRetryCount) {
// load data // load data
XxlJobInfo jobInfo = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobId); // job info XxlJobInfo jobInfo = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobId); // job info
@ -40,10 +44,14 @@ public class XxlJobTrigger {
logger.warn(">>>>>>>>>>>> trigger fail, jobId invalidjobId={}", jobId); logger.warn(">>>>>>>>>>>> trigger fail, jobId invalidjobId={}", jobId);
return; return;
} }
int finalFailRetryCount = jobInfo.getExecutorFailRetryCount();
if (failRetryCount >= 0) {
finalFailRetryCount = failRetryCount;
}
XxlJobGroup group = XxlJobDynamicScheduler.xxlJobGroupDao.load(jobInfo.getJobGroup()); // group info XxlJobGroup group = XxlJobDynamicScheduler.xxlJobGroupDao.load(jobInfo.getJobGroup()); // group info
ExecutorBlockStrategyEnum blockStrategy = ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), ExecutorBlockStrategyEnum.SERIAL_EXECUTION); // block strategy ExecutorBlockStrategyEnum blockStrategy = ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), ExecutorBlockStrategyEnum.SERIAL_EXECUTION); // block strategy
ExecutorFailStrategyEnum failStrategy = ExecutorFailStrategyEnum.match(jobInfo.getExecutorFailStrategy(), ExecutorFailStrategyEnum.NULL); // fail strategy
ExecutorRouteStrategyEnum executorRouteStrategyEnum = ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null); // route strategy ExecutorRouteStrategyEnum executorRouteStrategyEnum = ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null); // route strategy
ArrayList<String> addressList = (ArrayList<String>) group.getRegistryList(); ArrayList<String> addressList = (ArrayList<String>) group.getRegistryList();
@ -64,6 +72,7 @@ public class XxlJobTrigger {
jobLog.setGlueType(jobInfo.getGlueType()); jobLog.setGlueType(jobInfo.getGlueType());
jobLog.setExecutorHandler(jobInfo.getExecutorHandler()); jobLog.setExecutorHandler(jobInfo.getExecutorHandler());
jobLog.setExecutorParam(jobInfo.getExecutorParam()); jobLog.setExecutorParam(jobInfo.getExecutorParam());
jobLog.setExecutorFailRetryCount(finalFailRetryCount);
jobLog.setTriggerTime(new Date()); jobLog.setTriggerTime(new Date());
ReturnT<String> triggerResult = new ReturnT<String>(null); ReturnT<String> triggerResult = new ReturnT<String>(null);
@ -74,7 +83,7 @@ public class XxlJobTrigger {
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append("").append(group.getRegistryList()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append("").append(group.getRegistryList());
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append("").append(executorRouteStrategyEnum.getTitle()).append("("+i+"/"+addressList.size()+")"); // update01 triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append("").append(executorRouteStrategyEnum.getTitle()).append("("+i+"/"+addressList.size()+")"); // update01
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append("").append(blockStrategy.getTitle()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append("").append(blockStrategy.getTitle());
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append("").append(jobInfo.getExecutorFailRetryCount()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append("").append(finalFailRetryCount);
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append("").append(jobInfo.getExecutorTimeout()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append("").append(jobInfo.getExecutorTimeout());
// 3、trigger-valid // 3、trigger-valid
@ -104,9 +113,9 @@ public class XxlJobTrigger {
triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_run") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg()); triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_run") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg());
// 4.3、trigger (fail retry) // 4.3、trigger (fail retry)
if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && failStrategy == ExecutorFailStrategyEnum.FAIL_TRIGGER_RETRY) { if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && finalFailRetryCount > 0) {
triggerResult = runExecutor(triggerParam, address); // update04 JobTriggerPoolHelper.trigger(jobId, (finalFailRetryCount-1));
triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg()); triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>");
} }
} }
@ -134,6 +143,7 @@ public class XxlJobTrigger {
jobLog.setGlueType(jobInfo.getGlueType()); jobLog.setGlueType(jobInfo.getGlueType());
jobLog.setExecutorHandler(jobInfo.getExecutorHandler()); jobLog.setExecutorHandler(jobInfo.getExecutorHandler());
jobLog.setExecutorParam(jobInfo.getExecutorParam()); jobLog.setExecutorParam(jobInfo.getExecutorParam());
jobLog.setExecutorFailRetryCount(finalFailRetryCount);
jobLog.setTriggerTime(new Date()); jobLog.setTriggerTime(new Date());
ReturnT<String> triggerResult = new ReturnT<String>(null); ReturnT<String> triggerResult = new ReturnT<String>(null);
@ -144,7 +154,7 @@ public class XxlJobTrigger {
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append("").append(group.getRegistryList()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append("").append(group.getRegistryList());
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append("").append(executorRouteStrategyEnum.getTitle()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append("").append(executorRouteStrategyEnum.getTitle());
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append("").append(blockStrategy.getTitle()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append("").append(blockStrategy.getTitle());
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append("").append(jobInfo.getExecutorFailRetryCount()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append("").append(finalFailRetryCount);
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append("").append(jobInfo.getExecutorTimeout()); triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append("").append(jobInfo.getExecutorTimeout());
// 3、trigger-valid // 3、trigger-valid
@ -174,9 +184,9 @@ public class XxlJobTrigger {
triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_run") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg()); triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_run") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg());
// 4.3、trigger (fail retry) // 4.3、trigger (fail retry)
if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && failStrategy == ExecutorFailStrategyEnum.FAIL_TRIGGER_RETRY) { if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && finalFailRetryCount > 0) {
triggerResult = executorRouteStrategyEnum.getRouter().routeRun(triggerParam, addressList); JobTriggerPoolHelper.trigger(jobId, (finalFailRetryCount-1));
triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg()); triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>");
} }
} }

@ -67,14 +67,6 @@ public interface XxlJobService {
*/ */
public ReturnT<String> resume(int id); public ReturnT<String> resume(int id);
/**
* trigger job
*
* @param id
* @return
*/
public ReturnT<String> triggerJob(int id);
/** /**
* dashboard info * dashboard info
* *

@ -1,8 +1,8 @@
package com.xxl.job.admin.service.impl; package com.xxl.job.admin.service.impl;
import com.xxl.job.admin.core.enums.ExecutorFailStrategyEnum;
import com.xxl.job.admin.core.model.XxlJobInfo; import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog; import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
import com.xxl.job.admin.core.util.I18nUtil; import com.xxl.job.admin.core.util.I18nUtil;
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;
@ -72,7 +72,9 @@ public class AdminBizImpl implements AdminBiz {
for (int i = 0; i < childJobIds.length; i++) { for (int i = 0; i < childJobIds.length; i++) {
int childJobId = (StringUtils.isNotBlank(childJobIds[i]) && StringUtils.isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1; int childJobId = (StringUtils.isNotBlank(childJobIds[i]) && StringUtils.isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
if (childJobId > 0) { if (childJobId > 0) {
ReturnT<String> triggerChildResult = xxlJobService.triggerJob(childJobId);
JobTriggerPoolHelper.trigger(childJobId, 0);
ReturnT<String> triggerChildResult = ReturnT.SUCCESS;
// add msg // add msg
callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"), callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"),
@ -90,18 +92,14 @@ public class AdminBizImpl implements AdminBiz {
} }
} }
} else {
boolean ifHandleRetry = false;
if (IJobHandler.FAIL_RETRY.getCode() == handleCallbackParam.getExecuteResult().getCode()) {
ifHandleRetry = true;
} else { } else {
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(log.getJobId()); XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(log.getJobId());
if (ExecutorFailStrategyEnum.FAIL_HANDLE_RETRY.name().equals(xxlJobInfo.getExecutorFailStrategy())) { if (xxlJobInfo.getExecutorFailRetryCount() > 0) {
ifHandleRetry = true; int nextFailRetryCount = xxlJobInfo.getExecutorFailRetryCount()-1;
}
} JobTriggerPoolHelper.trigger(log.getJobId(), nextFailRetryCount);
if (ifHandleRetry){ ReturnT<String> retryTriggerResult = ReturnT.SUCCESS;
ReturnT<String> retryTriggerResult = xxlJobService.triggerJob(log.getJobId());
callbackMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_handle_retry") +"<<<<<<<<<<< </span><br>"; callbackMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_handle_retry") +"<<<<<<<<<<< </span><br>";
callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_msg1"), callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_msg1"),
@ -147,7 +145,8 @@ public class AdminBizImpl implements AdminBiz {
@Override @Override
public ReturnT<String> triggerJob(int jobId) { public ReturnT<String> triggerJob(int jobId) {
return xxlJobService.triggerJob(jobId); JobTriggerPoolHelper.trigger(jobId, -1);
return ReturnT.SUCCESS;
} }
} }

@ -4,7 +4,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.thread.JobTriggerPoolHelper;
import com.xxl.job.admin.core.util.I18nUtil; import com.xxl.job.admin.core.util.I18nUtil;
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;
@ -201,7 +200,6 @@ public class XxlJobServiceImpl implements XxlJobService {
exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler()); exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler());
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.setExecutorTimeout(jobInfo.getExecutorTimeout()); exists_jobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout());
exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount()); exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount());
exists_jobInfo.setChildJobId(jobInfo.getChildJobId()); exists_jobInfo.setChildJobId(jobInfo.getChildJobId());
@ -268,13 +266,13 @@ public class XxlJobServiceImpl implements XxlJobService {
} }
} }
@Override /*@Override
public ReturnT<String> triggerJob(int id) { public ReturnT<String> triggerJob(int id, int failRetryCount) {
JobTriggerPoolHelper.trigger(id); JobTriggerPoolHelper.trigger(id, failRetryCount);
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
/*XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); *//*XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
if (xxlJobInfo == null) { if (xxlJobInfo == null) {
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_unvalid")) ); return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_unvalid")) );
} }
@ -288,9 +286,9 @@ public class XxlJobServiceImpl implements XxlJobService {
} catch (SchedulerException e) { } catch (SchedulerException e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage()); return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage());
}*/ }*//*
} }*/
@Override @Override
public Map<String, Object> dashboardInfo() { public Map<String, Object> dashboardInfo() {

@ -162,7 +162,6 @@ joblog_clean_type_unvalid=清理类型参数异常
joblog_handleCode_200=成功 joblog_handleCode_200=成功
joblog_handleCode_500=失败 joblog_handleCode_500=失败
joblog_handleCode_502=失败(超时) joblog_handleCode_502=失败(超时)
joblog_handleCode_501=失败(重试)
joblog_kill_log=终止任务 joblog_kill_log=终止任务
joblog_kill_log_limit=调度失败,无法终止日志 joblog_kill_log_limit=调度失败,无法终止日志
joblog_kill_log_byman=人为操作主动终止 joblog_kill_log_byman=人为操作主动终止

@ -162,7 +162,6 @@ joblog_clean_type_unvalid=Clean type is illegal
joblog_handleCode_200=Success joblog_handleCode_200=Success
joblog_handleCode_500=Fail joblog_handleCode_500=Fail
joblog_handleCode_502=Timeout joblog_handleCode_502=Timeout
joblog_handleCode_501=Fail retry
joblog_kill_log=Kill Job joblog_kill_log=Kill Job
joblog_kill_log_limit=Trigger Fail, can not kill job joblog_kill_log_limit=Trigger Fail, can not kill job
joblog_kill_log_byman=Manual operation to active kill job joblog_kill_log_byman=Manual operation to active kill job

@ -20,7 +20,6 @@
<result column="executor_handler" property="executorHandler" /> <result column="executor_handler" property="executorHandler" />
<result column="executor_param" property="executorParam" /> <result column="executor_param" property="executorParam" />
<result column="executor_block_strategy" property="executorBlockStrategy" /> <result column="executor_block_strategy" property="executorBlockStrategy" />
<result column="executor_fail_strategy" property="executorFailStrategy" />
<result column="executor_timeout" property="executorTimeout" /> <result column="executor_timeout" property="executorTimeout" />
<result column="executor_fail_retry_count" property="executorFailRetryCount" /> <result column="executor_fail_retry_count" property="executorFailRetryCount" />
@ -45,7 +44,6 @@
t.executor_handler, t.executor_handler,
t.executor_param, t.executor_param,
t.executor_block_strategy, t.executor_block_strategy,
t.executor_fail_strategy,
t.executor_timeout, t.executor_timeout,
t.executor_fail_retry_count, t.executor_fail_retry_count,
t.glue_type, t.glue_type,
@ -102,7 +100,6 @@
executor_handler, executor_handler,
executor_param, executor_param,
executor_block_strategy, executor_block_strategy,
executor_fail_strategy,
executor_timeout, executor_timeout,
executor_fail_retry_count, executor_fail_retry_count,
glue_type, glue_type,
@ -122,7 +119,6 @@
#{executorHandler}, #{executorHandler},
#{executorParam}, #{executorParam},
#{executorBlockStrategy}, #{executorBlockStrategy},
#{executorFailStrategy},
#{executorTimeout}, #{executorTimeout},
#{executorFailRetryCount}, #{executorFailRetryCount},
#{glueType}, #{glueType},
@ -155,7 +151,6 @@
executor_handler = #{executorHandler}, executor_handler = #{executorHandler},
executor_param = #{executorParam}, executor_param = #{executorParam},
executor_block_strategy = #{executorBlockStrategy}, executor_block_strategy = #{executorBlockStrategy},
executor_fail_strategy = #{executorFailStrategy},
executor_timeout = ${executorTimeout}, executor_timeout = ${executorTimeout},
executor_fail_retry_count = ${executorFailRetryCount}, executor_fail_retry_count = ${executorFailRetryCount},
glue_type = #{glueType}, glue_type = #{glueType},

@ -14,6 +14,7 @@
<result column="executor_address" property="executorAddress" /> <result column="executor_address" property="executorAddress" />
<result column="executor_handler" property="executorHandler" /> <result column="executor_handler" property="executorHandler" />
<result column="executor_param" property="executorParam" /> <result column="executor_param" property="executorParam" />
<result column="executor_fail_retry_count" property="executorFailRetryCount" />
<result column="trigger_time" property="triggerTime" /> <result column="trigger_time" property="triggerTime" />
<result column="trigger_code" property="triggerCode" /> <result column="trigger_code" property="triggerCode" />
@ -33,6 +34,7 @@
t.executor_address, t.executor_address,
t.executor_handler, t.executor_handler,
t.executor_param, t.executor_param,
t.executor_fail_retry_count,
t.trigger_time, t.trigger_time,
t.trigger_code, t.trigger_code,
t.trigger_msg, t.trigger_msg,
@ -140,7 +142,8 @@
`trigger_msg`= #{triggerMsg}, `trigger_msg`= #{triggerMsg},
`executor_address`= #{executorAddress}, `executor_address`= #{executorAddress},
`executor_handler`=#{executorHandler}, `executor_handler`=#{executorHandler},
`executor_param`= #{executorParam} `executor_param`= #{executorParam},
`executor_fail_retry_count`= #{executorFailRetryCount}
WHERE `id`= #{id} WHERE `id`= #{id}
</update> </update>

@ -157,8 +157,6 @@ $(function() {
html = '<span style="color: green">'+ I18n.joblog_handleCode_200 +'</span>'; html = '<span style="color: green">'+ I18n.joblog_handleCode_200 +'</span>';
} else if (data == 500) { } else if (data == 500) {
html = '<span style="color: red">'+ I18n.joblog_handleCode_500 +'</span>'; html = '<span style="color: red">'+ I18n.joblog_handleCode_500 +'</span>';
} else if (data == 501) {
html = '<span style="color: red">'+ I18n.joblog_handleCode_501 +'</span>';
} else if (data == 502) { } else if (data == 502) {
html = '<span style="color: red">'+ I18n.joblog_handleCode_502 +'</span>'; html = '<span style="color: red">'+ I18n.joblog_handleCode_502 +'</span>';
} else if (data == 0) { } else if (data == 0) {

@ -1,7 +1,6 @@
package com.xxl.job.admin.dao; package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobInfo; import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@ -41,7 +40,6 @@ public class XxlJobInfoDaoTest {
info.setExecutorHandler("setExecutorHandler"); info.setExecutorHandler("setExecutorHandler");
info.setExecutorParam("setExecutorParam"); info.setExecutorParam("setExecutorParam");
info.setExecutorBlockStrategy("setExecutorBlockStrategy"); info.setExecutorBlockStrategy("setExecutorBlockStrategy");
info.setExecutorFailStrategy("setExecutorFailStrategy");
info.setGlueType("setGlueType"); info.setGlueType("setGlueType");
info.setGlueSource("setGlueSource"); info.setGlueSource("setGlueSource");
info.setGlueRemark("setGlueRemark"); info.setGlueRemark("setGlueRemark");
@ -58,7 +56,6 @@ public class XxlJobInfoDaoTest {
info2.setExecutorHandler("setExecutorHandler2"); info2.setExecutorHandler("setExecutorHandler2");
info2.setExecutorParam("setExecutorParam2"); info2.setExecutorParam("setExecutorParam2");
info2.setExecutorBlockStrategy("setExecutorBlockStrategy2"); info2.setExecutorBlockStrategy("setExecutorBlockStrategy2");
info2.setExecutorFailStrategy("setExecutorFailStrategy2");
info2.setGlueType("setGlueType2"); info2.setGlueType("setGlueType2");
info2.setGlueSource("setGlueSource2"); info2.setGlueSource("setGlueSource2");
info2.setGlueRemark("setGlueRemark2"); info2.setGlueRemark("setGlueRemark2");

@ -14,8 +14,6 @@ public abstract class IJobHandler {
public static final ReturnT<String> SUCCESS = new ReturnT<String>(200, null); public static final ReturnT<String> SUCCESS = new ReturnT<String>(200, null);
/** fail */ /** fail */
public static final ReturnT<String> FAIL = new ReturnT<String>(500, null); public static final ReturnT<String> FAIL = new ReturnT<String>(500, null);
/** fail retry */
public static final ReturnT<String> FAIL_RETRY = new ReturnT<String>(501, null);
/** fail timeout */ /** fail timeout */
public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT<String>(502, null); public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT<String>(502, null);

@ -66,8 +66,6 @@ public class ScriptJobHandler extends IJobHandler {
if (exitValue == 0) { if (exitValue == 0) {
return IJobHandler.SUCCESS; return IJobHandler.SUCCESS;
} else if (exitValue == 101) {
return IJobHandler.FAIL_RETRY;
} else { } else {
return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value("+exitValue+") is failed"); return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value("+exitValue+") is failed");
} }

Loading…
Cancel
Save