From 2984ac5c5f2a8b5f58b718e74dca904c79f900b0 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Mon, 25 Dec 2017 11:20:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0RM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/admin/core/trigger/XxlJobTrigger.java | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java index 784fb5fa..bf3c8567 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java +++ b/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()); } - return; - } - - // 1、save log-id - XxlJobLog jobLog = new XxlJobLog(); - jobLog.setJobGroup(jobInfo.getJobGroup()); - jobLog.setJobId(jobInfo.getId()); - XxlJobDynamicScheduler.xxlJobLogDao.save(jobLog); - logger.debug(">>>>>>>>>>> xxl-job trigger start, jobId:{}", jobLog.getId()); - - // 2、prepare trigger-info - //jobLog.setExecutorAddress(executorAddress); - jobLog.setGlueType(jobInfo.getGlueType()); - jobLog.setExecutorHandler(jobInfo.getExecutorHandler()); - jobLog.setExecutorParam(jobInfo.getExecutorParam()); - jobLog.setTriggerTime(new Date()); - - ReturnT triggerResult = new ReturnT(null); - StringBuffer triggerMsgSb = new StringBuffer(); - triggerMsgSb.append("调度机器:").append(IpUtil.getIp()); - triggerMsgSb.append("
执行器-注册方式:").append( (group.getAddressType() == 0)?"自动注册":"手动录入" ); - triggerMsgSb.append("
执行器-地址列表:").append(group.getRegistryList()); - triggerMsgSb.append("
路由策略:").append(executorRouteStrategyEnum.getTitle()); - triggerMsgSb.append("
阻塞处理策略:").append(blockStrategy.getTitle()); - triggerMsgSb.append("
失败处理策略:").append(failStrategy.getTitle()); - - // 3、trigger-valid - if (triggerResult.getCode()==ReturnT.SUCCESS_CODE && CollectionUtils.isEmpty(addressList)) { - triggerResult.setCode(ReturnT.FAIL_CODE); - triggerMsgSb.append("
----------------------
").append("调度失败:").append("执行器地址为空"); - } + } else { + // 1、save log-id + XxlJobLog jobLog = new XxlJobLog(); + jobLog.setJobGroup(jobInfo.getJobGroup()); + jobLog.setJobId(jobInfo.getId()); + XxlJobDynamicScheduler.xxlJobLogDao.save(jobLog); + logger.debug(">>>>>>>>>>> xxl-job trigger start, jobId:{}", jobLog.getId()); + + // 2、prepare trigger-info + //jobLog.setExecutorAddress(executorAddress); + jobLog.setGlueType(jobInfo.getGlueType()); + jobLog.setExecutorHandler(jobInfo.getExecutorHandler()); + jobLog.setExecutorParam(jobInfo.getExecutorParam()); + jobLog.setTriggerTime(new Date()); + + ReturnT triggerResult = new ReturnT(null); + StringBuffer triggerMsgSb = new StringBuffer(); + triggerMsgSb.append("调度机器:").append(IpUtil.getIp()); + triggerMsgSb.append("
执行器-注册方式:").append( (group.getAddressType() == 0)?"自动注册":"手动录入" ); + triggerMsgSb.append("
执行器-地址列表:").append(group.getRegistryList()); + triggerMsgSb.append("
路由策略:").append(executorRouteStrategyEnum.getTitle()); + triggerMsgSb.append("
阻塞处理策略:").append(blockStrategy.getTitle()); + triggerMsgSb.append("
失败处理策略:").append(failStrategy.getTitle()); + + // 3、trigger-valid + if (triggerResult.getCode()==ReturnT.SUCCESS_CODE && CollectionUtils.isEmpty(addressList)) { + triggerResult.setCode(ReturnT.FAIL_CODE); + triggerMsgSb.append("
----------------------
").append("调度失败:").append("执行器地址为空"); + } - if (triggerResult.getCode() == ReturnT.SUCCESS_CODE) { - // 4.1、trigger-param - TriggerParam triggerParam = new TriggerParam(); - triggerParam.setJobId(jobInfo.getId()); - triggerParam.setExecutorHandler(jobInfo.getExecutorHandler()); - triggerParam.setExecutorParams(jobInfo.getExecutorParam()); - triggerParam.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy()); - triggerParam.setLogId(jobLog.getId()); - triggerParam.setLogDateTim(jobLog.getTriggerTime().getTime()); - triggerParam.setGlueType(jobInfo.getGlueType()); - triggerParam.setGlueSource(jobInfo.getGlueSource()); - triggerParam.setGlueUpdatetime(jobInfo.getGlueUpdatetime().getTime()); - triggerParam.setBroadcastIndex(0); - triggerParam.setBroadcastTotal(1); - - // 4.2、trigger-run (route run / trigger remote executor) - triggerResult = executorRouteStrategyEnum.getRouter().routeRun(triggerParam, addressList); - triggerMsgSb.append("

>>>>>>>>>>>触发调度<<<<<<<<<<<
").append(triggerResult.getMsg()); - - // 4.3、trigger (fail retry) - if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && failStrategy == ExecutorFailStrategyEnum.FAIL_RETRY) { + if (triggerResult.getCode() == ReturnT.SUCCESS_CODE) { + // 4.1、trigger-param + TriggerParam triggerParam = new TriggerParam(); + triggerParam.setJobId(jobInfo.getId()); + triggerParam.setExecutorHandler(jobInfo.getExecutorHandler()); + triggerParam.setExecutorParams(jobInfo.getExecutorParam()); + triggerParam.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy()); + triggerParam.setLogId(jobLog.getId()); + triggerParam.setLogDateTim(jobLog.getTriggerTime().getTime()); + triggerParam.setGlueType(jobInfo.getGlueType()); + triggerParam.setGlueSource(jobInfo.getGlueSource()); + triggerParam.setGlueUpdatetime(jobInfo.getGlueUpdatetime().getTime()); + triggerParam.setBroadcastIndex(0); + triggerParam.setBroadcastTotal(1); + + // 4.2、trigger-run (route run / trigger remote executor) triggerResult = executorRouteStrategyEnum.getRouter().routeRun(triggerParam, addressList); - triggerMsgSb.append("

>>>>>>>>>>>调度失败重试<<<<<<<<<<<
").append(triggerResult.getMsg()); + triggerMsgSb.append("

>>>>>>>>>>>触发调度<<<<<<<<<<<
").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("

>>>>>>>>>>>调度失败重试<<<<<<<<<<<
").append(triggerResult.getMsg()); + } } - } - // 5、save trigger-info - jobLog.setExecutorAddress(triggerResult.getContent()); - jobLog.setTriggerCode(triggerResult.getCode()); - jobLog.setTriggerMsg(triggerMsgSb.toString()); - XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(jobLog); + // 5、save trigger-info + jobLog.setExecutorAddress(triggerResult.getContent()); + jobLog.setTriggerCode(triggerResult.getCode()); + jobLog.setTriggerMsg(triggerMsgSb.toString()); + 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()); } /**