Browse Source

任务手动执行一次的时候,支持指定本次执行的机器地址,为空则从执行器获取

xuxueli 5 years ago
parent
commit
2349098034

+ 2 - 1
doc/XXL-JOB官方文档.md

@@ -1731,8 +1731,9 @@ data: post-data
 - 16、执行器初始化逻辑优化:修复懒加载的Bean被提前初始化问题;
 - 16、执行器初始化逻辑优化:修复懒加载的Bean被提前初始化问题;
 - 17、任务复制功能:点击复制是弹出新建任务弹框,并初始化被复制任务信息;
 - 17、任务复制功能:点击复制是弹出新建任务弹框,并初始化被复制任务信息;
 - 18、执行器UI交互优化,移除冗余order属性;
 - 18、执行器UI交互优化,移除冗余order属性;
-- 19、[迭代中]任务执行一次的时候指定IP;
+- 19、任务手动执行一次的时候,支持指定本次执行的机器地址,为空则从执行器获取
 - 20、[迭代中]任务结果丢失处理:针对长期处于运行中的任务(设置过期时间时,运行超过"过期时间+1min";未设置超时时间时,运行超过"30min"),主动检测该执行器是否在线,如果不在线主动标记失败;
 - 20、[迭代中]任务结果丢失处理:针对长期处于运行中的任务(设置过期时间时,运行超过"过期时间+1min";未设置超时时间时,运行超过"30min"),主动检测该执行器是否在线,如果不在线主动标记失败;
+- 21、[迭代中]调度中心与执行器通讯规范为双向restful,方便跨语言,以及第三方执行器实现;通讯组件xxl-rpc方案调整为Jetty+Gson方案;
 
 
 
 
 ### TODO LIST
 ### TODO LIST

+ 2 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java

@@ -132,13 +132,13 @@ public class JobInfoController {
 	@RequestMapping("/trigger")
 	@RequestMapping("/trigger")
 	@ResponseBody
 	@ResponseBody
 	//@PermissionLimit(limit = false)
 	//@PermissionLimit(limit = false)
-	public ReturnT<String> triggerJob(int id, String executorParam) {
+	public ReturnT<String> triggerJob(int id, String executorParam, String addressList) {
 		// force cover job param
 		// force cover job param
 		if (executorParam == null) {
 		if (executorParam == null) {
 			executorParam = "";
 			executorParam = "";
 		}
 		}
 
 
-		JobTriggerPoolHelper.trigger(id, TriggerTypeEnum.MANUAL, -1, null, executorParam);
+		JobTriggerPoolHelper.trigger(id, TriggerTypeEnum.MANUAL, -1, null, executorParam, addressList);
 		return ReturnT.SUCCESS;
 		return ReturnT.SUCCESS;
 	}
 	}
 
 

+ 1 - 1
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
 								// 1、fail retry monitor
 								if (log.getExecutorFailRetryCount() > 0) {
 								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 = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_type_retry") +"<<<<<<<<<<< </span><br>";
 									String retryMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_type_retry") +"<<<<<<<<<<< </span><br>";
 									log.setTriggerMsg(log.getTriggerMsg() + retryMsg);
 									log.setTriggerMsg(log.getTriggerMsg() + retryMsg);
 									XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(log);
 									XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(log);

+ 2 - 2
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
                                     // 2.2、trigger-expire < 5s:direct-trigger && make next-trigger-time
 
 
                                     // 1、trigger
                                     // 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() );
                                     logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = " + jobInfo.getId() );
 
 
                                     // 2、fresh next
                                     // 2、fresh next
@@ -241,7 +241,7 @@ public class JobScheduleHelper {
                             // do trigger
                             // do trigger
                             for (int jobId: ringItemData) {
                             for (int jobId: ringItemData) {
                                 // do trigger
                                 // do trigger
-                                JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null);
+                                JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null, null);
                             }
                             }
                             // clear
                             // clear
                             ringItemData.clear();
                             ringItemData.clear();

+ 9 - 4
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobTriggerPoolHelper.java

@@ -69,7 +69,12 @@ public class JobTriggerPoolHelper {
     /**
     /**
      * add trigger
      * 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
         // choose thread pool
         ThreadPoolExecutor triggerPool_ = fastTriggerPool;
         ThreadPoolExecutor triggerPool_ = fastTriggerPool;
@@ -87,7 +92,7 @@ public class JobTriggerPoolHelper {
 
 
                 try {
                 try {
                     // do trigger
                     // do trigger
-                    XxlJobTrigger.trigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam);
+                    XxlJobTrigger.trigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam, addressList);
                 } catch (Exception e) {
                 } catch (Exception e) {
                     logger.error(e.getMessage(), e);
                     logger.error(e.getMessage(), e);
                 } finally {
                 } finally {
@@ -138,8 +143,8 @@ public class JobTriggerPoolHelper {
      *          null: use job param
      *          null: use job param
      *          not null: cover 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);
     }
     }
 
 
 }
 }

+ 16 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java

@@ -37,8 +37,17 @@ public class XxlJobTrigger {
      * @param executorParam
      * @param executorParam
      *          null: use job param
      *          null: use job param
      *          not null: cover 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
         // load data
         XxlJobInfo jobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(jobId);
         XxlJobInfo jobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(jobId);
         if (jobInfo == null) {
         if (jobInfo == null) {
@@ -51,6 +60,12 @@ public class XxlJobTrigger {
         int finalFailRetryCount = failRetryCount>=0?failRetryCount:jobInfo.getExecutorFailRetryCount();
         int finalFailRetryCount = failRetryCount>=0?failRetryCount:jobInfo.getExecutorFailRetryCount();
         XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(jobInfo.getJobGroup());
         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
         // sharding param
         int[] shardingParam = null;
         int[] shardingParam = null;
         if (executorShardingParam!=null){
         if (executorShardingParam!=null){

+ 1 - 1
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;
                     int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
                     if (childJobId > 0) {
                     if (childJobId > 0) {
 
 
-                        JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null);
+                        JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null);
                         ReturnT<String> triggerChildResult = ReturnT.SUCCESS;
                         ReturnT<String> triggerChildResult = ReturnT.SUCCESS;
 
 
                         // add msg
                         // add msg

+ 1 - 0
xxl-job-admin/src/main/resources/i18n/message_en.properties

@@ -135,6 +135,7 @@ jobinfo_opt_stop=Stop
 jobinfo_opt_start=Start
 jobinfo_opt_start=Start
 jobinfo_opt_log=Query Log
 jobinfo_opt_log=Query Log
 jobinfo_opt_run=Run Once
 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_registryinfo=Registry Info
 jobinfo_opt_next_time=Next trigger time
 jobinfo_opt_next_time=Next trigger time
 jobinfo_glue_remark=Resource Remark
 jobinfo_glue_remark=Resource Remark

+ 1 - 0
xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties

@@ -135,6 +135,7 @@ jobinfo_opt_stop=停止
 jobinfo_opt_start=启动
 jobinfo_opt_start=启动
 jobinfo_opt_log=查询日志
 jobinfo_opt_log=查询日志
 jobinfo_opt_run=执行一次
 jobinfo_opt_run=执行一次
+jobinfo_opt_run_tips=请输入本次执行的机器地址,为空则从执行器获取
 jobinfo_opt_registryinfo=注册节点
 jobinfo_opt_registryinfo=注册节点
 jobinfo_opt_next_time=下次执行时间
 jobinfo_opt_next_time=下次执行时间
 jobinfo_glue_remark=源码备注
 jobinfo_glue_remark=源码备注

+ 1 - 0
xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties

@@ -135,6 +135,7 @@ jobinfo_opt_stop=停止
 jobinfo_opt_start=啟動
 jobinfo_opt_start=啟動
 jobinfo_opt_log=查詢日誌
 jobinfo_opt_log=查詢日誌
 jobinfo_opt_run=執行一次
 jobinfo_opt_run=執行一次
+jobinfo_opt_run_tips=請輸入本次執行的機器地址,為空則從執行器獲取
 jobinfo_opt_registryinfo=注冊節點
 jobinfo_opt_registryinfo=注冊節點
 jobinfo_opt_next_time=下次執行時間
 jobinfo_opt_next_time=下次執行時間
 jobinfo_glue_remark=源碼備註
 jobinfo_glue_remark=源碼備註

+ 2 - 1
xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js

@@ -262,7 +262,8 @@ $(function() {
             url : base_url + "/jobinfo/trigger",
             url : base_url + "/jobinfo/trigger",
             data : {
             data : {
                 "id" : $("#jobTriggerModal .form input[name='id']").val(),
                 "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",
             dataType : "json",
             success : function(data){
             success : function(data){

+ 6 - 0
xxl-job-admin/src/main/resources/templates/jobinfo/jobinfo.index.ftl

@@ -407,6 +407,12 @@ exit 0
                             <textarea class="textarea form-control" name="executorParam" placeholder="${I18n.system_please_input}${I18n.jobinfo_field_executorparam}" maxlength="512" style="height: 63px; line-height: 1.2;"></textarea>
                             <textarea class="textarea form-control" name="executorParam" placeholder="${I18n.system_please_input}${I18n.jobinfo_field_executorparam}" maxlength="512" style="height: 63px; line-height: 1.2;"></textarea>
                         </div>
                         </div>
                     </div>
                     </div>
+                    <div class="form-group">
+                        <label for="firstname" class="col-sm-2 control-label">${I18n.jobgroup_field_registryList}<font color="black">*</font></label>
+                        <div class="col-sm-10">
+                            <textarea class="textarea form-control" name="addressList" placeholder="${I18n.jobinfo_opt_run_tips}" maxlength="512" style="height: 63px; line-height: 1.2;"></textarea>
+                        </div>
+                    </div>
                     <hr>
                     <hr>
                     <div class="form-group">
                     <div class="form-group">
                         <div class="col-sm-offset-3 col-sm-6">
                         <div class="col-sm-offset-3 col-sm-6">