master
xuxueli 7 years ago
parent 38f896532c
commit 2984ac5c5f
  1. 124
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java

@ -117,73 +117,73 @@ public class XxlJobTrigger {
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId()); logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
} }
return; } else {
} // 1、save log-id
XxlJobLog jobLog = new XxlJobLog();
// 1、save log-id jobLog.setJobGroup(jobInfo.getJobGroup());
XxlJobLog jobLog = new XxlJobLog(); jobLog.setJobId(jobInfo.getId());
jobLog.setJobGroup(jobInfo.getJobGroup()); XxlJobDynamicScheduler.xxlJobLogDao.save(jobLog);
jobLog.setJobId(jobInfo.getId()); logger.debug(">>>>>>>>>>> xxl-job trigger start, jobId:{}", jobLog.getId());
XxlJobDynamicScheduler.xxlJobLogDao.save(jobLog);
logger.debug(">>>>>>>>>>> xxl-job trigger start, jobId:{}", jobLog.getId()); // 2、prepare trigger-info
//jobLog.setExecutorAddress(executorAddress);
// 2、prepare trigger-info jobLog.setGlueType(jobInfo.getGlueType());
//jobLog.setExecutorAddress(executorAddress); jobLog.setExecutorHandler(jobInfo.getExecutorHandler());
jobLog.setGlueType(jobInfo.getGlueType()); jobLog.setExecutorParam(jobInfo.getExecutorParam());
jobLog.setExecutorHandler(jobInfo.getExecutorHandler()); jobLog.setTriggerTime(new Date());
jobLog.setExecutorParam(jobInfo.getExecutorParam());
jobLog.setTriggerTime(new Date()); ReturnT<String> triggerResult = new ReturnT<String>(null);
StringBuffer triggerMsgSb = new StringBuffer();
ReturnT<String> triggerResult = new ReturnT<String>(null); triggerMsgSb.append("调度机器:").append(IpUtil.getIp());
StringBuffer triggerMsgSb = new StringBuffer(); triggerMsgSb.append("<br>执行器-注册方式:").append( (group.getAddressType() == 0)?"自动注册":"手动录入" );
triggerMsgSb.append("调度机器:").append(IpUtil.getIp()); triggerMsgSb.append("<br>执行器-地址列表:").append(group.getRegistryList());
triggerMsgSb.append("<br>执行器-注册方式:").append( (group.getAddressType() == 0)?"自动注册":"手动录入" ); triggerMsgSb.append("<br>路由策略:").append(executorRouteStrategyEnum.getTitle());
triggerMsgSb.append("<br>执行器-地址列表:").append(group.getRegistryList()); triggerMsgSb.append("<br>阻塞处理策略:").append(blockStrategy.getTitle());
triggerMsgSb.append("<br>路由策略:").append(executorRouteStrategyEnum.getTitle()); triggerMsgSb.append("<br>失败处理策略:").append(failStrategy.getTitle());
triggerMsgSb.append("<br>阻塞处理策略:").append(blockStrategy.getTitle());
triggerMsgSb.append("<br>失败处理策略:").append(failStrategy.getTitle()); // 3、trigger-valid
if (triggerResult.getCode()==ReturnT.SUCCESS_CODE && CollectionUtils.isEmpty(addressList)) {
// 3、trigger-valid triggerResult.setCode(ReturnT.FAIL_CODE);
if (triggerResult.getCode()==ReturnT.SUCCESS_CODE && CollectionUtils.isEmpty(addressList)) { triggerMsgSb.append("<br>----------------------<br>").append("调度失败:").append("执行器地址为空");
triggerResult.setCode(ReturnT.FAIL_CODE); }
triggerMsgSb.append("<br>----------------------<br>").append("调度失败:").append("执行器地址为空");
}
if (triggerResult.getCode() == ReturnT.SUCCESS_CODE) { if (triggerResult.getCode() == ReturnT.SUCCESS_CODE) {
// 4.1、trigger-param // 4.1、trigger-param
TriggerParam triggerParam = new TriggerParam(); TriggerParam triggerParam = new TriggerParam();
triggerParam.setJobId(jobInfo.getId()); triggerParam.setJobId(jobInfo.getId());
triggerParam.setExecutorHandler(jobInfo.getExecutorHandler()); triggerParam.setExecutorHandler(jobInfo.getExecutorHandler());
triggerParam.setExecutorParams(jobInfo.getExecutorParam()); triggerParam.setExecutorParams(jobInfo.getExecutorParam());
triggerParam.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy()); triggerParam.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
triggerParam.setLogId(jobLog.getId()); triggerParam.setLogId(jobLog.getId());
triggerParam.setLogDateTim(jobLog.getTriggerTime().getTime()); triggerParam.setLogDateTim(jobLog.getTriggerTime().getTime());
triggerParam.setGlueType(jobInfo.getGlueType()); triggerParam.setGlueType(jobInfo.getGlueType());
triggerParam.setGlueSource(jobInfo.getGlueSource()); triggerParam.setGlueSource(jobInfo.getGlueSource());
triggerParam.setGlueUpdatetime(jobInfo.getGlueUpdatetime().getTime()); triggerParam.setGlueUpdatetime(jobInfo.getGlueUpdatetime().getTime());
triggerParam.setBroadcastIndex(0); triggerParam.setBroadcastIndex(0);
triggerParam.setBroadcastTotal(1); triggerParam.setBroadcastTotal(1);
// 4.2、trigger-run (route run / trigger remote executor) // 4.2、trigger-run (route run / trigger remote executor)
triggerResult = executorRouteStrategyEnum.getRouter().routeRun(triggerParam, addressList);
triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>触发调度<<<<<<<<<<< </span><br>").append(triggerResult.getMsg());
// 4.3、trigger (fail retry)
if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && failStrategy == ExecutorFailStrategyEnum.FAIL_RETRY) {
triggerResult = executorRouteStrategyEnum.getRouter().routeRun(triggerParam, addressList); triggerResult = executorRouteStrategyEnum.getRouter().routeRun(triggerParam, addressList);
triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>调度失败重试<<<<<<<<<<< </span><br>").append(triggerResult.getMsg()); triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>触发调度<<<<<<<<<<< </span><br>").append(triggerResult.getMsg());
// 4.3、trigger (fail retry)
if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && failStrategy == ExecutorFailStrategyEnum.FAIL_RETRY) {
triggerResult = executorRouteStrategyEnum.getRouter().routeRun(triggerParam, addressList);
triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>调度失败重试<<<<<<<<<<< </span><br>").append(triggerResult.getMsg());
}
} }
}
// 5、save trigger-info // 5、save trigger-info
jobLog.setExecutorAddress(triggerResult.getContent()); jobLog.setExecutorAddress(triggerResult.getContent());
jobLog.setTriggerCode(triggerResult.getCode()); jobLog.setTriggerCode(triggerResult.getCode());
jobLog.setTriggerMsg(triggerMsgSb.toString()); jobLog.setTriggerMsg(triggerMsgSb.toString());
XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(jobLog); XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(jobLog);
// 6、monitor triger
JobFailMonitorHelper.monitor(jobLog.getId());
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
}
// 6、monitor triger
JobFailMonitorHelper.monitor(jobLog.getId());
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
} }
/** /**

Loading…
Cancel
Save