From 23490980341c700631629cffe1741413e4b94dfa Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Thu, 9 Apr 2020 21:54:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=89=8B=E5=8A=A8=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E4=B8=80=E6=AC=A1=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=87=E5=AE=9A=E6=9C=AC=E6=AC=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E6=9C=BA=E5=99=A8=E5=9C=B0=E5=9D=80=EF=BC=8C?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=88=99=E4=BB=8E=E6=89=A7=E8=A1=8C=E5=99=A8?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/XXL-JOB官方文档.md | 3 ++- .../job/admin/controller/JobInfoController.java | 4 ++-- .../admin/core/thread/JobFailMonitorHelper.java | 2 +- .../admin/core/thread/JobScheduleHelper.java | 4 ++-- .../admin/core/thread/JobTriggerPoolHelper.java | 13 +++++++++---- .../job/admin/core/trigger/XxlJobTrigger.java | 17 ++++++++++++++++- .../job/admin/service/impl/AdminBizImpl.java | 2 +- .../main/resources/i18n/message_en.properties | 1 + .../resources/i18n/message_zh_CN.properties | 1 + .../resources/i18n/message_zh_TC.properties | 1 + .../main/resources/static/js/jobinfo.index.1.js | 3 ++- .../templates/jobinfo/jobinfo.index.ftl | 6 ++++++ 12 files changed, 44 insertions(+), 13 deletions(-) diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index 9883a8d3..dbf8e54b 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -1731,8 +1731,9 @@ data: post-data - 16、执行器初始化逻辑优化:修复懒加载的Bean被提前初始化问题; - 17、任务复制功能:点击复制是弹出新建任务弹框,并初始化被复制任务信息; - 18、执行器UI交互优化,移除冗余order属性; -- 19、[迭代中]任务执行一次的时候指定IP; +- 19、任务手动执行一次的时候,支持指定本次执行的机器地址,为空则从执行器获取 - 20、[迭代中]任务结果丢失处理:针对长期处于运行中的任务(设置过期时间时,运行超过"过期时间+1min";未设置超时时间时,运行超过"30min"),主动检测该执行器是否在线,如果不在线主动标记失败; +- 21、[迭代中]调度中心与执行器通讯规范为双向restful,方便跨语言,以及第三方执行器实现;通讯组件xxl-rpc方案调整为Jetty+Gson方案; ### TODO LIST diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java index d6786cfd..3cf8029a 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java @@ -132,13 +132,13 @@ public class JobInfoController { @RequestMapping("/trigger") @ResponseBody //@PermissionLimit(limit = false) - public ReturnT triggerJob(int id, String executorParam) { + public ReturnT triggerJob(int id, String executorParam, String addressList) { // force cover job param if (executorParam == null) { executorParam = ""; } - JobTriggerPoolHelper.trigger(id, TriggerTypeEnum.MANUAL, -1, null, executorParam); + JobTriggerPoolHelper.trigger(id, TriggerTypeEnum.MANUAL, -1, null, executorParam, addressList); return ReturnT.SUCCESS; } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java index c56eac19..33e4d250 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java @@ -52,7 +52,7 @@ public class JobFailMonitorHelper { // 1、fail retry monitor if (log.getExecutorFailRetryCount() > 0) { - JobTriggerPoolHelper.trigger(log.getJobId(), TriggerTypeEnum.RETRY, (log.getExecutorFailRetryCount()-1), log.getExecutorShardingParam(), log.getExecutorParam()); + JobTriggerPoolHelper.trigger(log.getJobId(), TriggerTypeEnum.RETRY, (log.getExecutorFailRetryCount()-1), log.getExecutorShardingParam(), log.getExecutorParam(), null); String retryMsg = "

>>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_type_retry") +"<<<<<<<<<<<
"; log.setTriggerMsg(log.getTriggerMsg() + retryMsg); XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(log); diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java index 765161a9..e425b323 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java @@ -93,7 +93,7 @@ public class JobScheduleHelper { // 2.2、trigger-expire < 5s:direct-trigger && make next-trigger-time // 1、trigger - JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null); + JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null, null); logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = " + jobInfo.getId() ); // 2、fresh next @@ -241,7 +241,7 @@ public class JobScheduleHelper { // do trigger for (int jobId: ringItemData) { // do trigger - JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null); + JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null, null); } // clear ringItemData.clear(); diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobTriggerPoolHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobTriggerPoolHelper.java index d4d4db94..398713dd 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobTriggerPoolHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobTriggerPoolHelper.java @@ -69,7 +69,12 @@ public class JobTriggerPoolHelper { /** * add trigger */ - public void addTrigger(final int jobId, final TriggerTypeEnum triggerType, final int failRetryCount, final String executorShardingParam, final String executorParam) { + public void addTrigger(final int jobId, + final TriggerTypeEnum triggerType, + final int failRetryCount, + final String executorShardingParam, + final String executorParam, + final String addressList) { // choose thread pool ThreadPoolExecutor triggerPool_ = fastTriggerPool; @@ -87,7 +92,7 @@ public class JobTriggerPoolHelper { try { // do trigger - XxlJobTrigger.trigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam); + XxlJobTrigger.trigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam, addressList); } catch (Exception e) { logger.error(e.getMessage(), e); } finally { @@ -138,8 +143,8 @@ public class JobTriggerPoolHelper { * null: use job param * not null: cover job param */ - public static void trigger(int jobId, TriggerTypeEnum triggerType, int failRetryCount, String executorShardingParam, String executorParam) { - helper.addTrigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam); + public static void trigger(int jobId, TriggerTypeEnum triggerType, int failRetryCount, String executorShardingParam, String executorParam, String addressList) { + helper.addTrigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam, addressList); } } 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 d2a92b8a..321ea5d3 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 @@ -37,8 +37,17 @@ public class XxlJobTrigger { * @param executorParam * null: use job param * not null: cover job param + * @param addressList + * null: use executor addressList + * not null: cover */ - public static void trigger(int jobId, TriggerTypeEnum triggerType, int failRetryCount, String executorShardingParam, String executorParam) { + public static void trigger(int jobId, + TriggerTypeEnum triggerType, + int failRetryCount, + String executorShardingParam, + String executorParam, + String addressList) { + // load data XxlJobInfo jobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(jobId); if (jobInfo == null) { @@ -51,6 +60,12 @@ public class XxlJobTrigger { int finalFailRetryCount = failRetryCount>=0?failRetryCount:jobInfo.getExecutorFailRetryCount(); XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(jobInfo.getJobGroup()); + // cover addressList + if (addressList!=null && addressList.trim().length()>0) { + group.setAddressType(1); + group.setAddressList(addressList.trim()); + } + // sharding param int[] shardingParam = null; if (executorShardingParam!=null){ diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java index 1cdeac82..e8ecdd38 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java @@ -74,7 +74,7 @@ public class AdminBizImpl implements AdminBiz { int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1; if (childJobId > 0) { - JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null); + JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null); ReturnT triggerChildResult = ReturnT.SUCCESS; // add msg diff --git a/xxl-job-admin/src/main/resources/i18n/message_en.properties b/xxl-job-admin/src/main/resources/i18n/message_en.properties index 74afcc6a..a9b45896 100644 --- a/xxl-job-admin/src/main/resources/i18n/message_en.properties +++ b/xxl-job-admin/src/main/resources/i18n/message_en.properties @@ -135,6 +135,7 @@ jobinfo_opt_stop=Stop jobinfo_opt_start=Start jobinfo_opt_log=Query Log jobinfo_opt_run=Run Once +jobinfo_opt_run_tips=Please input the address for this trigger. Null will be obtained from the executor jobinfo_opt_registryinfo=Registry Info jobinfo_opt_next_time=Next trigger time jobinfo_glue_remark=Resource Remark diff --git a/xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties b/xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties index 386fbf62..12cfcc20 100644 --- a/xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties +++ b/xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties @@ -135,6 +135,7 @@ jobinfo_opt_stop=停止 jobinfo_opt_start=启动 jobinfo_opt_log=查询日志 jobinfo_opt_run=执行一次 +jobinfo_opt_run_tips=请输入本次执行的机器地址,为空则从执行器获取 jobinfo_opt_registryinfo=注册节点 jobinfo_opt_next_time=下次执行时间 jobinfo_glue_remark=源码备注 diff --git a/xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties b/xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties index fc9293dc..d8d74f3a 100755 --- a/xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties +++ b/xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties @@ -135,6 +135,7 @@ jobinfo_opt_stop=停止 jobinfo_opt_start=啟動 jobinfo_opt_log=查詢日誌 jobinfo_opt_run=執行一次 +jobinfo_opt_run_tips=請輸入本次執行的機器地址,為空則從執行器獲取 jobinfo_opt_registryinfo=注冊節點 jobinfo_opt_next_time=下次執行時間 jobinfo_glue_remark=源碼備註 diff --git a/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js b/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js index b0082792..926bcac5 100644 --- a/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js +++ b/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js @@ -262,7 +262,8 @@ $(function() { url : base_url + "/jobinfo/trigger", data : { "id" : $("#jobTriggerModal .form input[name='id']").val(), - "executorParam" : $("#jobTriggerModal .textarea[name='executorParam']").val() + "executorParam" : $("#jobTriggerModal .textarea[name='executorParam']").val(), + "addressList" : $("#jobTriggerModal .textarea[name='addressList']").val() }, dataType : "json", success : function(data){ diff --git a/xxl-job-admin/src/main/resources/templates/jobinfo/jobinfo.index.ftl b/xxl-job-admin/src/main/resources/templates/jobinfo/jobinfo.index.ftl index be9dba51..0fdf2239 100644 --- a/xxl-job-admin/src/main/resources/templates/jobinfo/jobinfo.index.ftl +++ b/xxl-job-admin/src/main/resources/templates/jobinfo/jobinfo.index.ftl @@ -407,6 +407,12 @@ exit 0 +
+ +
+ +
+