feat: 3.2.0
1.优化定时任务重试
This commit is contained in:
parent
5c6a00d69b
commit
76d29f5f6a
@ -32,6 +32,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.reflect.UndeclaredThrowableException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,6 +57,7 @@ public class RequestClientActor extends AbstractActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doExecute(RealJobExecutorDTO realJobExecutorDTO) {
|
private void doExecute(RealJobExecutorDTO realJobExecutorDTO) {
|
||||||
|
long nowMilli = DateUtils.toNowMilli();
|
||||||
// 检查客户端是否存在
|
// 检查客户端是否存在
|
||||||
RegisterNodeInfo registerNodeInfo = CacheRegisterTable.getServerNode(
|
RegisterNodeInfo registerNodeInfo = CacheRegisterTable.getServerNode(
|
||||||
realJobExecutorDTO.getGroupName(),
|
realJobExecutorDTO.getGroupName(),
|
||||||
@ -64,8 +66,13 @@ public class RequestClientActor extends AbstractActor {
|
|||||||
if (Objects.isNull(registerNodeInfo)) {
|
if (Objects.isNull(registerNodeInfo)) {
|
||||||
taskExecuteFailure(realJobExecutorDTO, "客户端不存在");
|
taskExecuteFailure(realJobExecutorDTO, "客户端不存在");
|
||||||
LogMetaDTO logMetaDTO = JobTaskConverter.INSTANCE.toJobLogDTO(realJobExecutorDTO);
|
LogMetaDTO logMetaDTO = JobTaskConverter.INSTANCE.toJobLogDTO(realJobExecutorDTO);
|
||||||
logMetaDTO.setTimestamp( DateUtils.toNowMilli());
|
logMetaDTO.setTimestamp(nowMilli);
|
||||||
EasyRetryLog.REMOTE.error("taskId:[{}] 任务调度失败. 失败原因: 无可执行的客户端 <|>{}<|>", realJobExecutorDTO.getTaskId(), logMetaDTO);
|
if (realJobExecutorDTO.isRetry()) {
|
||||||
|
EasyRetryLog.REMOTE.error("taskId:[{}] 任务调度失败执行重试. 失败原因: 无可执行的客户端. 重试次数:[{}]. <|>{}<|>",
|
||||||
|
realJobExecutorDTO.getTaskId(), realJobExecutorDTO.getRetryCount(), logMetaDTO);
|
||||||
|
} else {
|
||||||
|
EasyRetryLog.REMOTE.error("taskId:[{}] 任务调度失败. 失败原因: 无可执行的客户端 <|>{}<|>", realJobExecutorDTO.getTaskId(), logMetaDTO);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,9 +100,19 @@ public class RequestClientActor extends AbstractActor {
|
|||||||
throwable = re.getLastFailedAttempt().getExceptionCause();
|
throwable = re.getLastFailedAttempt().getExceptionCause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.getClass().isAssignableFrom(UndeclaredThrowableException.class)) {
|
||||||
|
UndeclaredThrowableException re = (UndeclaredThrowableException) e;
|
||||||
|
throwable = re.getUndeclaredThrowable();
|
||||||
|
}
|
||||||
|
|
||||||
LogMetaDTO logMetaDTO = JobTaskConverter.INSTANCE.toJobLogDTO(realJobExecutorDTO);
|
LogMetaDTO logMetaDTO = JobTaskConverter.INSTANCE.toJobLogDTO(realJobExecutorDTO);
|
||||||
logMetaDTO.setTimestamp( DateUtils.toNowMilli());
|
logMetaDTO.setTimestamp(nowMilli);
|
||||||
EasyRetryLog.REMOTE.error("taskId:[{}] 任务调度失败. <|>{}<|>", logMetaDTO.getTaskId(), logMetaDTO, throwable);
|
if (realJobExecutorDTO.isRetry()) {
|
||||||
|
EasyRetryLog.REMOTE.error("taskId:[{}] 任务调度失败执行重试 重试次数:[{}]. <|>{}<|>", logMetaDTO.getTaskId(),
|
||||||
|
realJobExecutorDTO.getRetryCount(), logMetaDTO, throwable);
|
||||||
|
} else {
|
||||||
|
EasyRetryLog.REMOTE.error("taskId:[{}] 任务调度失败. <|>{}<|>", logMetaDTO.getTaskId(), logMetaDTO, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
taskExecuteFailure(realJobExecutorDTO, throwable.getMessage());
|
taskExecuteFailure(realJobExecutorDTO, throwable.getMessage());
|
||||||
|
|
||||||
@ -129,11 +146,12 @@ public class RequestClientActor extends AbstractActor {
|
|||||||
private JobRpcClient buildRpcClient(RegisterNodeInfo registerNodeInfo, RealJobExecutorDTO realJobExecutorDTO) {
|
private JobRpcClient buildRpcClient(RegisterNodeInfo registerNodeInfo, RealJobExecutorDTO realJobExecutorDTO) {
|
||||||
|
|
||||||
int maxRetryTimes = realJobExecutorDTO.getMaxRetryTimes();
|
int maxRetryTimes = realJobExecutorDTO.getMaxRetryTimes();
|
||||||
|
boolean retry = realJobExecutorDTO.isRetry();
|
||||||
return RequestBuilder.<JobRpcClient, Result>newBuilder()
|
return RequestBuilder.<JobRpcClient, Result>newBuilder()
|
||||||
.nodeInfo(registerNodeInfo)
|
.nodeInfo(registerNodeInfo)
|
||||||
.namespaceId(registerNodeInfo.getNamespaceId())
|
.namespaceId(registerNodeInfo.getNamespaceId())
|
||||||
.failRetry(maxRetryTimes > 0)
|
.failRetry(maxRetryTimes > 0 && !retry)
|
||||||
.retryTimes(realJobExecutorDTO.getMaxRetryTimes())
|
.retryTimes(maxRetryTimes)
|
||||||
.retryInterval(realJobExecutorDTO.getRetryInterval())
|
.retryInterval(realJobExecutorDTO.getRetryInterval())
|
||||||
.retryListener(new JobExecutorRetryListener(realJobExecutorDTO))
|
.retryListener(new JobExecutorRetryListener(realJobExecutorDTO))
|
||||||
.client(JobRpcClient.class)
|
.client(JobRpcClient.class)
|
||||||
|
Loading…
Reference in New Issue
Block a user