任务调度备注中标注任务触发类型,如Cron触发、父任务触发、API触发等等,方便排查调度日志;

v1.9.2
xuxueli 6 years ago
parent 9ac897f5db
commit ae7fe92fa5

@ -1238,6 +1238,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 22、新增左侧菜单"运行报表"
- 23、执行器手动设置IP时取消绑定Host的操作该IP仅供执行器注册使用修复指定外网IP时无法绑定执行器Host的问题
- 24、取消父子任务不可重复的限制支持循环任务触发等特殊场景
- 25、任务调度备注中标注任务触发类型如Cron触发、父任务触发、API触发等等方便排查调度日志
- 26、【迭代中】分片任务失败重试优化仅重试当前失败的分片
### TODO LIST

@ -4,6 +4,7 @@ import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
import com.xxl.job.admin.core.util.I18nUtil;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.service.XxlJobService;
import com.xxl.job.core.biz.model.ReturnT;
@ -90,7 +91,7 @@ public class JobInfoController {
@RequestMapping("/trigger")
@ResponseBody
public ReturnT<String> triggerJob(int id) {
JobTriggerPoolHelper.trigger(id, -1);
JobTriggerPoolHelper.trigger(id, -1, I18nUtil.getString("jobconf_trigger_type_manual"));
return ReturnT.SUCCESS;
}

@ -11,8 +11,6 @@ import com.xxl.job.admin.dao.XxlJobLogDao;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.LogResult;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.glue.GlueTypeEnum;
import com.xxl.job.core.rpc.netcom.NetComClientProxy;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
@ -52,7 +50,6 @@ public class JobLogController {
// 执行器列表
List<XxlJobGroup> jobGroupList = xxlJobGroupDao.findAll();
model.addAttribute("JobGroupList", jobGroupList);
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());
// 任务
if (jobId > 0) {

@ -1,6 +1,7 @@
package com.xxl.job.admin.core.jobbean;
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
import com.xxl.job.admin.core.util.I18nUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
@ -27,7 +28,7 @@ public class RemoteHttpJobBean extends QuartzJobBean {
// trigger
//XxlJobTrigger.trigger(jobId);
JobTriggerPoolHelper.trigger(jobId, -1);
JobTriggerPoolHelper.trigger(jobId, -1, I18nUtil.getString("jobconf_trigger_type_cron"));
}
}

@ -65,8 +65,25 @@ public class JobFailMonitorHelper {
} else /*if (IJobHandler.FAIL.getCode() == log.getTriggerCode()
|| IJobHandler.FAIL.getCode() == log.getHandleCode()
|| IJobHandler.FAIL_RETRY.getCode() == log.getHandleCode() )*/ {
// job fail,
failAlarm(log);
// 1、fail retry
XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(log.getJobId());
if (log.getExecutorFailRetryCount() > 0) {
// TODO分片任务失败重试优化仅重试失败分片
JobTriggerPoolHelper.trigger(log.getJobId(), (log.getExecutorFailRetryCount()-1), I18nUtil.getString("jobconf_trigger_type_retry"));
String retryMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>";
log.setTriggerMsg(log.getTriggerMsg() + retryMsg);
XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(log);
}
// 2、fail alarm
failAlarm(info, log);
logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId);
}/* else {
JobFailMonitorHelper.monitor(jobLogId);
@ -89,7 +106,9 @@ public class JobFailMonitorHelper {
XxlJobLog log = XxlJobDynamicScheduler.xxlJobLogDao.load(jobLogId);
if (ReturnT.FAIL_CODE == log.getTriggerCode()|| ReturnT.FAIL_CODE==log.getHandleCode()) {
// job fail,
failAlarm(log);
XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(log.getJobId());
failAlarm(info, log);
logger.info(">>>>>>>>>>> job monitor last, job fail, JobLogId:{}", jobLogId);
}
}
@ -148,10 +167,9 @@ public class JobFailMonitorHelper {
*
* @param jobLog
*/
private void failAlarm(XxlJobLog jobLog){
private void failAlarm(XxlJobInfo info, XxlJobLog jobLog){
// send monitor email
XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobLog.getJobId());
if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) {
String alarmContent = "Alarm Job LogId=" + jobLog.getId();

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

@ -6,7 +6,6 @@ import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
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.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.ReturnT;
@ -36,7 +35,7 @@ public class XxlJobTrigger {
* <0: use param from job info config
*
*/
public static void trigger(int jobId, int failRetryCount) {
public static void trigger(int jobId, int failRetryCount, String type) {
// load data
XxlJobInfo jobInfo = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobId); // job info
@ -57,7 +56,6 @@ public class XxlJobTrigger {
// broadcast
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum && CollectionUtils.isNotEmpty(addressList)) {
boolean onceFailed = false;
for (int i = 0; i < addressList.size(); i++) {
String address = addressList.get(i);
@ -77,6 +75,7 @@ public class XxlJobTrigger {
ReturnT<String> triggerResult = new ReturnT<String>(null);
StringBuffer triggerMsgSb = new StringBuffer();
triggerMsgSb.append(I18nUtil.getString("jobconf_trigger_type")).append("").append(type);
triggerMsgSb.append(I18nUtil.getString("jobconf_trigger_admin_adress")).append("").append(IpUtil.getIp());
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regtype")).append("")
.append( (group.getAddressType() == 0)?I18nUtil.getString("jobgroup_field_addressType_0"):I18nUtil.getString("jobgroup_field_addressType_1") );
@ -106,24 +105,13 @@ public class XxlJobTrigger {
triggerResult = runExecutor(triggerParam, address); // update03
triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_run") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg());
// 4、fail retry)
if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE) {
onceFailed = true;
}
if (addressList.size()==i+1 && onceFailed && finalFailRetryCount > 0) { // each trigger only retry once
JobTriggerPoolHelper.trigger(jobId, (finalFailRetryCount-1));
triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>");
}
// 5、save trigger-info
// 4、save trigger-info
jobLog.setExecutorAddress(triggerResult.getContent());
jobLog.setTriggerCode(triggerResult.getCode());
jobLog.setTriggerMsg(triggerMsgSb.toString());
XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(jobLog);
// 6、monitor trigger
// 5、monitor trigger
JobFailMonitorHelper.monitor(jobLog.getId());
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
@ -182,19 +170,13 @@ public class XxlJobTrigger {
}
// 4、fail retry
if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && finalFailRetryCount > 0) {
JobTriggerPoolHelper.trigger(jobId, (finalFailRetryCount-1));
triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>");
}
// 5、save trigger-info
// 4、save trigger-info
jobLog.setExecutorAddress(triggerResult.getContent());
jobLog.setTriggerCode(triggerResult.getCode());
jobLog.setTriggerMsg(triggerMsgSb.toString());
XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(jobLog);
// 6、monitor trigger
// 5、monitor trigger
JobFailMonitorHelper.monitor(jobLog.getId());
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
}

@ -7,7 +7,6 @@ import com.xxl.job.admin.core.util.I18nUtil;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogDao;
import com.xxl.job.admin.dao.XxlJobRegistryDao;
import com.xxl.job.admin.service.XxlJobService;
import com.xxl.job.core.biz.AdminBiz;
import com.xxl.job.core.biz.model.HandleCallbackParam;
import com.xxl.job.core.biz.model.RegistryParam;
@ -36,8 +35,6 @@ public class AdminBizImpl implements AdminBiz {
private XxlJobInfoDao xxlJobInfoDao;
@Resource
private XxlJobRegistryDao xxlJobRegistryDao;
@Resource
private XxlJobService xxlJobService;
@Override
@ -73,7 +70,7 @@ public class AdminBizImpl implements AdminBiz {
int childJobId = (StringUtils.isNotBlank(childJobIds[i]) && StringUtils.isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
if (childJobId > 0) {
JobTriggerPoolHelper.trigger(childJobId, 0);
JobTriggerPoolHelper.trigger(childJobId, 0, I18nUtil.getString("jobconf_trigger_type_parent"));
ReturnT<String> triggerChildResult = ReturnT.SUCCESS;
// add msg
@ -92,16 +89,6 @@ public class AdminBizImpl implements AdminBiz {
}
}
} else {
if (log.getExecutorFailRetryCount() > 0) {
int nextFailRetryCount = log.getExecutorFailRetryCount()-1;
// TODO广播路由的失败重试会导致重试暴增需要优化
JobTriggerPoolHelper.trigger(log.getJobId(), nextFailRetryCount);
callbackMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_handle_retry") +"<<<<<<<<<<< </span><br>";
}
}
// handle msg
@ -142,7 +129,7 @@ public class AdminBizImpl implements AdminBiz {
@Override
public ReturnT<String> triggerJob(int jobId) {
JobTriggerPoolHelper.trigger(jobId, -1);
JobTriggerPoolHelper.trigger(jobId, -1, I18nUtil.getString("jobconf_trigger_type_api"));
return ReturnT.SUCCESS;
}

@ -224,6 +224,12 @@ jobconf_trigger_run=触发调度
jobconf_trigger_child_run=触发子任务
jobconf_callback_child_msg1={0}/{1} [任务ID={2}], 触发{3}, 触发备注: {4} <br>
jobconf_callback_child_msg2={0}/{1} [任务ID={2}], 触发失败, 触发备注: 任务ID格式错误 <br>
jobconf_trigger_type=任务触发类型
jobconf_trigger_type_cron=Cron触发
jobconf_trigger_type_manual=手动触发
jobconf_trigger_type_parent=父任务触发
jobconf_trigger_type_api=API触发
jobconf_trigger_type_retry=失败重试触发
## help
job_help=使用教程

@ -224,6 +224,12 @@ jobconf_trigger_run=Trigger Job
jobconf_trigger_child_run=Trigger child job
jobconf_callback_child_msg1={0}/{1} [Job ID={2}], Trigger {3}, Trigger msg: {4} <br>
jobconf_callback_child_msg2={0}/{1} [Job ID={2}], Trigger Fail, Trigger msg: Job ID is illegal <br>
jobconf_trigger_type=Job trigger type
jobconf_trigger_type_cron=Cron trigger
jobconf_trigger_type_manual=Manual trigger
jobconf_trigger_type_parent=Parent job trigger
jobconf_trigger_type_api=Api trigger
jobconf_trigger_type_retry=Fail retry trigger
## help
job_help=Tutorial

@ -167,12 +167,6 @@
</div>
<@netCommon.commonScript />
<script>
var GlueTypeEnum = {};
<#list GlueTypeEnum as item>
GlueTypeEnum['${item}'] = '${item.desc}';
</#list>
</script>
<!-- DataTables -->
<script src="${request.contextPath}/static/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>

@ -98,14 +98,8 @@ $(function() {
"width":'10%',
"render": function ( data, type, row ) {
var glueTypeTitle = GlueTypeEnum[row.glueType];
if (row.executorHandler) {
glueTypeTitle = glueTypeTitle +"" + row.executorHandler;
}
var temp = '';
temp += I18n.joblog_field_executorAddress + '' + (row.executorAddress?row.executorAddress:'');
temp += '<br>'+ I18n.jobinfo_field_gluetype +'' + glueTypeTitle;
temp += '<br>'+ I18n.jobinfo_field_executorparam +'' + row.executorParam;
return '<a class="logTips" href="javascript:;" >'+ row.jobId +'<span style="display:none;">'+ temp +'</span></a>';

@ -1,7 +1,6 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.XxlJobLogDao;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -32,7 +31,6 @@ public class XxlJobLogDaoTest {
int ret1 = xxlJobLogDao.save(log);
XxlJobLog dto = xxlJobLogDao.load(log.getId());
log.setGlueType("1");
log.setTriggerTime(new Date());
log.setTriggerCode(1);
log.setTriggerMsg("1");

Loading…
Cancel
Save