feat(1.5.0-beta1): 优化重试客户端日志
This commit is contained in:
parent
df80d2eab9
commit
0ad2cbd162
@ -44,7 +44,7 @@ public class RemoteRetryExecutor {
|
||||
executeRespDto.setSceneName(context.getScene());
|
||||
|
||||
try {
|
||||
RetrySiteSnapshot.setAttemptNumber(context.getRetryCount());
|
||||
// RetrySiteSnapshot.setAttemptNumber(context.getRetryCount() + 1);
|
||||
|
||||
// 初始化实时日志上下文
|
||||
initLogContext(context);
|
||||
@ -70,18 +70,20 @@ public class RemoteRetryExecutor {
|
||||
executeRespDto.setResultJson(JsonUtil.toJsonString(retryerResultContext.getResult()));
|
||||
}
|
||||
|
||||
Integer retryCount = context.getRetryCount() + 1;
|
||||
if (Objects.equals(RetryResultStatusEnum.SUCCESS.getStatus(), executeRespDto.getStatusCode())) {
|
||||
SnailJobLog.REMOTE.info("remote retry【SUCCESS】. count:[{}] result:[{}]", context.getRetryCount(),
|
||||
executeRespDto.getResultJson());
|
||||
SnailJobLog.REMOTE.info("remote retry【SUCCESS】. retryTaskId:[{}] count:[{}] result:[{}]",
|
||||
context.getRetryTaskId(), retryCount, executeRespDto.getResultJson());
|
||||
} else if (Objects.equals(RetryResultStatusEnum.STOP.getStatus(), executeRespDto.getStatusCode())) {
|
||||
SnailJobLog.REMOTE.warn("remote retry 【STOP】. count:[{}] exceptionMsg:[{}]",
|
||||
context.getRetryCount(), executeRespDto.getExceptionMsg());
|
||||
SnailJobLog.REMOTE.warn("remote retry 【STOP】.retryTaskId:[{}] count:[{}] exceptionMsg:[{}]",
|
||||
context.getRetryTaskId(), retryCount, executeRespDto.getExceptionMsg());
|
||||
} else if (Objects.equals(RetryResultStatusEnum.FAILURE.getStatus(), executeRespDto.getStatusCode())) {
|
||||
SnailJobLog.REMOTE.error("remote retry 【FAILURE】. count:[{}] ", context.getRetryCount(),
|
||||
retryerResultContext.getThrowable());
|
||||
SnailJobLog.REMOTE.error("remote retry 【FAILURE】. retryTaskId:[{}] count:[{}] ",
|
||||
context.getRetryTaskId(), retryCount, retryerResultContext.getThrowable());
|
||||
} else {
|
||||
SnailJobLog.REMOTE.error("remote retry 【UNKNOWN】. count:[{}] result:[{}]", context.getRetryCount(),
|
||||
executeRespDto.getResultJson(), retryerResultContext.getThrowable());
|
||||
SnailJobLog.REMOTE.error("remote retry 【UNKNOWN】. retryTaskId:[{}] count:[{}] result:[{}]",
|
||||
context.getRetryTaskId(), retryCount, executeRespDto.getResultJson(),
|
||||
retryerResultContext.getThrowable());
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
@ -50,19 +50,6 @@ public class RetrySiteSnapshot {
|
||||
* 进入方法入口时间标记
|
||||
*/
|
||||
private static final RetrySiteSnapshotContext<Long> ENTRY_METHOD_TIME = SnailRetrySpiLoader.loadRetrySiteSnapshotContext();
|
||||
private static final RetrySiteSnapshotContext<Integer> ATTEMPT_NUMBER = SnailRetrySpiLoader.loadRetrySiteSnapshotContext();
|
||||
|
||||
public static Integer getAttemptNumber() {
|
||||
return ATTEMPT_NUMBER.get();
|
||||
}
|
||||
|
||||
public static void setAttemptNumber(Integer attemptNumber) {
|
||||
ATTEMPT_NUMBER.set(attemptNumber);
|
||||
}
|
||||
|
||||
public static void removeAttemptNumber() {
|
||||
ATTEMPT_NUMBER.remove();
|
||||
}
|
||||
|
||||
public static Integer getStage() {
|
||||
return RETRY_STAGE.get();
|
||||
@ -214,7 +201,6 @@ public class RetrySiteSnapshot {
|
||||
|
||||
removeStatus();
|
||||
removeStage();
|
||||
removeAttemptNumber();
|
||||
removeEntryMethodTime();
|
||||
removeRetryHeader();
|
||||
removeRetryStatusCode();
|
||||
|
@ -86,7 +86,7 @@ public class RemoteRetryStrategies extends AbstractRetryStrategies {
|
||||
|
||||
@Override
|
||||
protected RetryExecutorParameter<WaitStrategy, StopStrategy> getRetryExecutorParameter(RetryerInfo retryerInfo) {
|
||||
return new RetryExecutorParameter<WaitStrategy, StopStrategy>() {
|
||||
return new RetryExecutorParameter<>() {
|
||||
|
||||
@Override
|
||||
public WaitStrategy backOff() {
|
||||
@ -100,20 +100,7 @@ public class RemoteRetryStrategies extends AbstractRetryStrategies {
|
||||
|
||||
@Override
|
||||
public List<RetryListener> getRetryListeners() {
|
||||
return Collections.singletonList(new RetryListener() {
|
||||
@Override
|
||||
public <V> void onRetry(Attempt<V> attempt) {
|
||||
Integer attemptNumber = RetrySiteSnapshot.getAttemptNumber();
|
||||
if (attempt.hasResult()) {
|
||||
SnailJobLog.LOCAL.info("snail-job 远程重试成功,第[{}]次调度", attemptNumber);
|
||||
}
|
||||
|
||||
if (attempt.hasException()) {
|
||||
SnailJobLog.LOCAL.error("snail-job 远程重试失败,第[{}]次调度 ", attemptNumber, attempt.getExceptionCause());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class RetryTimerWheel {
|
||||
public static synchronized void register(String idempotentKey, TimerTask<String> task, Duration delay) {
|
||||
|
||||
register(idempotentKey, hashedWheelTimer -> {
|
||||
SnailJobLog.LOCAL.info("加入时间轮. delay:[{}ms] taskType:[{}]", delay, idempotentKey);
|
||||
SnailJobLog.LOCAL.debug("加入时间轮. delay:[{}ms] taskType:[{}]", delay, idempotentKey);
|
||||
timer.newTimeout(task, Math.max(delay.toMillis(), 0), TimeUnit.MILLISECONDS);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user