feat: custom job retry interval #285 #290

This commit is contained in:
tjq 2021-11-03 21:33:38 +08:00
parent 4c0e5f348b
commit c3eefeb626
5 changed files with 17 additions and 2 deletions

View File

@ -133,6 +133,8 @@ public class SaveJobInfoRequest {
private String lifecycle;
private Long retryInterval;
/**
* Check non-null properties.

View File

@ -81,4 +81,6 @@ public class JobInfoDTO {
private Integer dispatchStrategy;
private String lifecycle;
private Long retryInterval;
}

View File

@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@ -44,6 +45,8 @@ public class InstanceManager {
@Resource
private WorkflowInstanceManager workflowInstanceManager;
private static final long DEFAULT_RETRY_INTERVAL = 10000;
/**
* 更新任务状态
@ -114,8 +117,9 @@ public class InstanceManager {
log.info("[InstanceManager-{}] instance execute failed but will take the {}th retry.", instanceId, instanceInfo.getRunningTimes());
// 延迟10S重试由于重试不改变 instanceId如果派发到同一台机器上一个 TaskTracker 还处于资源释放阶段无法创建新的TaskTracker任务失败
instanceInfo.setExpectedTriggerTime(System.currentTimeMillis() + 10000);
// 默认延迟10S重试由于重试不改变 instanceId如果派发到同一台机器上一个 TaskTracker 还处于资源释放阶段无法创建新的TaskTracker任务失败
Long retryInterval = Optional.ofNullable(jobInfo.getRetryInterval()).orElse(DEFAULT_RETRY_INTERVAL);
instanceInfo.setExpectedTriggerTime(System.currentTimeMillis() + retryInterval);
// 修改状态为 等待派发正式开始重试
// 问题会丢失以往的调度记录actualTriggerTime什么的都会被覆盖

View File

@ -141,4 +141,9 @@ public class JobInfoDO {
private String lifecycle;
/**
* 重试时间间隔
*/
private Long retryInterval;
}

View File

@ -96,6 +96,8 @@ public class JobInfoVO {
private String lifecycle;
private Long retryInterval;
public static JobInfoVO from(JobInfoDO jobInfoDO) {
JobInfoVO jobInfoVO = new JobInfoVO();
BeanUtils.copyProperties(jobInfoDO, jobInfoVO);