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

This commit is contained in:
xuxueli 2020-04-09 21:54:12 +08:00
parent 1199cec9ff
commit 2349098034
12 changed files with 44 additions and 13 deletions

View File

@ -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

View File

@ -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;
} }

View File

@ -52,7 +52,7 @@ public class JobFailMonitorHelper {
// 1fail retry monitor // 1fail 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);

View File

@ -93,7 +93,7 @@ public class JobScheduleHelper {
// 2.2trigger-expire < 5sdirect-trigger && make next-trigger-time // 2.2trigger-expire < 5sdirect-trigger && make next-trigger-time
// 1trigger // 1trigger
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() );
// 2fresh next // 2fresh 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();

View File

@ -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) { public static void trigger(int jobId, TriggerTypeEnum triggerType, int failRetryCount, String executorShardingParam, String executorParam, String addressList) {
helper.addTrigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam); helper.addTrigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam, addressList);
} }
} }

View File

@ -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){

View File

@ -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

View File

@ -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

View File

@ -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=源码备注

View File

@ -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=源碼備註

View File

@ -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){

View File

@ -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">