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