任务参数LogDateTime生成逻辑调整,分片广播场景下保障时间一致;

3.3.2-release
xuxueli 4 months ago
parent 0f0a05523a
commit 80a99cfb9d

@ -2756,7 +2756,8 @@ public void execute() {
- 5、【优化】调度日志列表排序逻辑优化提升易读性
- 6、【优化】调度中心OpenAPI通讯token调整为非必填合并PR-3892
- 7、【优化】执行器详情接口权限调整支持普通用户查看注册节点合并PR-3882
- 8、【TODO】任务调度触发后分批批量更新提升调度性能
- 8、【优化】任务参数LogDateTime生成逻辑调整分片广播场景下保障时间一致
- 9、【TODO】任务调度触发后分批批量更新提升调度性能

@ -51,6 +51,8 @@ public class JobTrigger {
* >=0: use this param
* <0: use param from job info config
* @param executorShardingParam
* null: new sharding, all nodes
* not null: for retry, only one node
* @param executorParam
* null: use job param
* not null: cover job param
@ -85,6 +87,7 @@ public class JobTrigger {
// sharding param
int[] shardingParam = null;
Date triggerTime = new Date();
if (executorShardingParam!=null){
String[] shardingArr = executorShardingParam.split("/");
if (shardingArr.length==2 && StringTool.isNumeric(shardingArr[0]) && StringTool.isNumeric(shardingArr[1])) {
@ -97,13 +100,13 @@ public class JobTrigger {
&& group.getRegistryList()!=null && !group.getRegistryList().isEmpty()
&& shardingParam==null) {
for (int i = 0; i < group.getRegistryList().size(); i++) {
processTrigger(group, jobInfo, finalFailRetryCount, triggerType, i, group.getRegistryList().size());
processTrigger(group, jobInfo, finalFailRetryCount, triggerType, triggerTime, i, group.getRegistryList().size());
}
} else {
if (shardingParam == null) {
shardingParam = new int[]{0, 1};
}
processTrigger(group, jobInfo, finalFailRetryCount, triggerType, shardingParam[0], shardingParam[1]);
processTrigger(group, jobInfo, finalFailRetryCount, triggerType, triggerTime, shardingParam[0], shardingParam[1]);
}
}
@ -124,6 +127,7 @@ public class JobTrigger {
* @param jobInfo job info
* @param finalFailRetryCount the fail-retry count
* @param triggerType trigger type
* @param triggerTime trigger time
* @param index sharding index
* @param total sharding index
*/
@ -131,6 +135,7 @@ public class JobTrigger {
XxlJobInfo jobInfo,
int finalFailRetryCount,
TriggerTypeEnum triggerType,
Date triggerTime,
int index,
int total){
@ -143,7 +148,7 @@ public class JobTrigger {
XxlJobLog jobLog = new XxlJobLog();
jobLog.setJobGroup(jobInfo.getJobGroup());
jobLog.setJobId(jobInfo.getId());
jobLog.setTriggerTime(new Date());
jobLog.setTriggerTime(triggerTime);
xxlJobLogMapper.save(jobLog);
logger.debug(">>>>>>>>>>> xxl-job trigger start, jobId:{}", jobLog.getId());
@ -251,22 +256,26 @@ public class JobTrigger {
* @return return
*/
private Response<String> doTrigger(TriggerRequest triggerParam, String address){
Response<String> runResult = null;
try {
// build client
ExecutorBiz executorBiz = XxlJobAdminBootstrap.getExecutorBiz(address);
runResult = executorBiz.run(triggerParam);
// invoke
Response<String> runResult = executorBiz.run(triggerParam);
// build result
StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + "");
runResultSB.append("<br>address").append(address);
runResultSB.append("<br>code").append(runResult.getCode());
runResultSB.append("<br>msg").append(runResult.getMsg());
// return
runResult.setMsg(runResultSB.toString());
return runResult;
} catch (Exception e) {
logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
runResult = Response.of(XxlJobContext.HANDLE_CODE_FAIL, ThrowableTool.toString(e));
return Response.of(XxlJobContext.HANDLE_CODE_FAIL, ThrowableTool.toString(e));
}
StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + "");
runResultSB.append("<br>address").append(address);
runResultSB.append("<br>code").append(runResult.getCode());
runResultSB.append("<br>msg").append(runResult.getMsg());
runResult.setMsg(runResultSB.toString());
return runResult;
}
}

@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
* @author xuxueli 2019-12-11 21:52:51
*/
public class SampleXxlJob {
private static Logger logger = LoggerFactory.getLogger(SampleXxlJob.class);
private static final Logger logger = LoggerFactory.getLogger(SampleXxlJob.class);
/**

@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
*/
@Component
public class SampleXxlJob {
private static Logger logger = LoggerFactory.getLogger(SampleXxlJob.class);
private static final Logger logger = LoggerFactory.getLogger(SampleXxlJob.class);
/**

Loading…
Cancel
Save