fix(3.2.0)
优化重试上下文,支持SPI扩展
This commit is contained in:
parent
9cd2d0f62e
commit
6568273d60
@ -0,0 +1,16 @@
|
||||
package com.aizuda.easy.retry.client.common;
|
||||
|
||||
/**
|
||||
* @author: xiaowoniu
|
||||
* @date : 2024-03-22
|
||||
* @since :3.2.0
|
||||
*/
|
||||
public interface EasyRetryLogContext<T> {
|
||||
|
||||
void set(T value);
|
||||
|
||||
void remove();
|
||||
|
||||
T get();
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
package com.aizuda.easy.retry.client.common;
|
||||
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.aizuda.easy.retry.client.common.appender;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.report.AsyncReportLog;
|
||||
import com.aizuda.easy.retry.client.common.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.constant.LogFieldConstants;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
import org.apache.log4j.MDC;
|
||||
import org.apache.logging.log4j.core.Filter;
|
||||
import org.apache.logging.log4j.core.Layout;
|
||||
@ -34,7 +32,7 @@ public class EasyRetryLog4j2Appender extends AbstractAppender {
|
||||
public void append(LogEvent event) {
|
||||
|
||||
// Not job context
|
||||
if (Objects.isNull(ThreadLocalLogUtil.getContext()) || Objects.isNull(MDC.get(LogFieldConstants.MDC_REMOTE))) {
|
||||
if (Objects.isNull(EasyRetryLogManager.getLogMeta()) || Objects.isNull(MDC.get(LogFieldConstants.MDC_REMOTE))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.aizuda.easy.retry.client.common.appender;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.report.AsyncReportLog;
|
||||
import com.aizuda.easy.retry.client.common.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.constant.LogFieldConstants;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
import org.apache.log4j.MDC;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
@ -30,7 +28,7 @@ public class EasyRetryLog4jAppender extends AppenderSkeleton {
|
||||
protected void append(LoggingEvent event) {
|
||||
|
||||
// Not job context
|
||||
if (Objects.isNull(ThreadLocalLogUtil.getContext()) || Objects.isNull(MDC.get(LogFieldConstants.MDC_REMOTE))) {
|
||||
if (Objects.isNull(EasyRetryLogManager.getLogMeta()) || Objects.isNull(MDC.get(LogFieldConstants.MDC_REMOTE))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,10 @@ import ch.qos.logback.classic.spi.StackTraceElementProxy;
|
||||
import ch.qos.logback.classic.spi.ThrowableProxyUtil;
|
||||
import ch.qos.logback.core.CoreConstants;
|
||||
import ch.qos.logback.core.UnsynchronizedAppenderBase;
|
||||
import com.aizuda.easy.retry.client.common.report.AsyncReportLog;
|
||||
import com.aizuda.easy.retry.client.common.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.constant.LogFieldConstants;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -34,7 +32,7 @@ public class EasyRetryLogbackAppender<E> extends UnsynchronizedAppenderBase<E> {
|
||||
|
||||
// Not job context
|
||||
if (!(eventObject instanceof LoggingEvent)
|
||||
|| Objects.isNull(ThreadLocalLogUtil.getContext())
|
||||
|| Objects.isNull(EasyRetryLogManager.getLogMeta())
|
||||
|| Objects.isNull(MDC.get(LogFieldConstants.MDC_REMOTE))) {
|
||||
return;
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.aizuda.easy.retry.client.common.log.context;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.aizuda.easy.retry.client.common.EasyRetryLogContext;
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientException;
|
||||
|
||||
/**
|
||||
* ThreadLocal实现类
|
||||
*
|
||||
* @author: xiaowoniu
|
||||
* @date : 2023-08-09 16:34
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public class ThreadLocalLogContext<T> implements EasyRetryLogContext<T> {
|
||||
|
||||
private final ThreadLocal<T> threadLocal;
|
||||
|
||||
public ThreadLocalLogContext(ThreadLocal<T> threadLocal) {
|
||||
Assert.notNull(threadLocal, ()-> new EasyRetryClientException("thread local can not be null"));
|
||||
this.threadLocal = threadLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(T value) {
|
||||
threadLocal.set(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
threadLocal.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get() {
|
||||
return threadLocal.get();
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
package com.aizuda.easy.retry.client.common.log.report;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.client.common.LogReport;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.common.window.SlidingWindow;
|
||||
import com.aizuda.easy.retry.common.core.window.Listener;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
package com.aizuda.easy.retry.client.common.log.report;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
package com.aizuda.easy.retry.client.common.log.report;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.LogReport;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
@ -11,15 +12,17 @@ import java.util.List;
|
||||
*/
|
||||
public final class LogReportFactory {
|
||||
|
||||
private static final List<LogReport> reports = Lists.newArrayList();
|
||||
private static final List<LogReport> REPORTS = Lists.newArrayList();
|
||||
private LogReportFactory() {
|
||||
}
|
||||
|
||||
static void add(LogReport logReport) {
|
||||
reports.add(logReport);
|
||||
static void add(LogReport logReport) {
|
||||
REPORTS.add(logReport);
|
||||
}
|
||||
|
||||
public static LogReport get() {
|
||||
|
||||
for (final LogReport report : reports) {
|
||||
for (final LogReport report : REPORTS) {
|
||||
if (report.supports()) {
|
||||
return report;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
package com.aizuda.easy.retry.client.common.log.report;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.client.NettyClient;
|
||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
@ -0,0 +1,62 @@
|
||||
package com.aizuda.easy.retry.client.common.log.support;
|
||||
|
||||
import cn.hutool.core.util.ServiceLoaderUtil;
|
||||
import com.aizuda.easy.retry.client.common.EasyRetryLogContext;
|
||||
import com.aizuda.easy.retry.client.common.log.context.ThreadLocalLogContext;
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogMeta;
|
||||
import com.aizuda.easy.retry.common.log.enums.LogTypeEnum;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author wodeyangzipingpingwuqi·
|
||||
* @date 2023-12-29
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public final class EasyRetryLogManager {
|
||||
|
||||
private static final EasyRetryLogContext<LogTypeEnum> LOG_TYPE = easyRetryLogContextLoader();
|
||||
private static final EasyRetryLogContext<LogMeta> LOG_META = easyRetryLogContextLoader();
|
||||
|
||||
private static <T> EasyRetryLogContext<T> easyRetryLogContextLoader() {
|
||||
return Optional.ofNullable(ServiceLoaderUtil.loadFirst(EasyRetryLogContext.class)).orElse(new ThreadLocalLogContext<T>(new ThreadLocal<>()));
|
||||
}
|
||||
|
||||
private EasyRetryLogManager() {
|
||||
}
|
||||
|
||||
public static void initLogInfo(LogMeta logMeta, LogTypeEnum logType) {
|
||||
setLogMeta(logMeta);
|
||||
setLogType(logType);
|
||||
}
|
||||
|
||||
public static void setLogMeta(LogMeta logMeta) {
|
||||
LOG_META.set(logMeta);
|
||||
}
|
||||
|
||||
public static LogMeta getLogMeta() {
|
||||
return LOG_META.get();
|
||||
}
|
||||
|
||||
public static void removeLogMeta() {
|
||||
LOG_META.remove();
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
removeLogMeta();
|
||||
removeLogType();
|
||||
}
|
||||
|
||||
public static void setLogType (LogTypeEnum logType) {
|
||||
LOG_TYPE.set(logType);
|
||||
}
|
||||
|
||||
public static LogTypeEnum getLogType () {
|
||||
return LOG_TYPE.get();
|
||||
}
|
||||
|
||||
public static void removeLogType () {
|
||||
LOG_TYPE.remove();
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.window.SlidingWindow;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.server.model.dto.LogTaskDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 异步上报日志数据
|
||||
*
|
||||
* @author wodeyangzipingpingwuqi
|
||||
* @date 2023-12-27
|
||||
* @since 2.6.0
|
||||
*/
|
||||
//@Component
|
||||
@Slf4j
|
||||
@Deprecated
|
||||
public class AsyncReportLog implements Lifecycle {
|
||||
|
||||
@Autowired
|
||||
private EasyRetryProperties easyRetryProperties;
|
||||
|
||||
private SlidingWindow<LogTaskDTO> slidingWindow;
|
||||
|
||||
/**
|
||||
* 异步上报到服务端, 若当前处于远程重试阶段不会进行执行上报
|
||||
*/
|
||||
public Boolean syncReportLog(LogContentDTO logContent) {
|
||||
|
||||
// LogTaskDTO logTaskDTO = buildLogTaskDTO(logContent);
|
||||
// slidingWindow.add(logTaskDTO);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
EasyRetryProperties.LogSlidingWindowConfig logSlidingWindow = easyRetryProperties.getLogSlidingWindow();
|
||||
|
||||
slidingWindow = SlidingWindow
|
||||
.Builder
|
||||
.<LogTaskDTO>newBuilder()
|
||||
.withTotalThreshold(logSlidingWindow.getTotalThreshold())
|
||||
.withWindowTotalThreshold(logSlidingWindow.getWindowTotalThreshold())
|
||||
.withDuration(logSlidingWindow.getDuration(), logSlidingWindow.getChronoUnit())
|
||||
.withListener(new ReportLogListener())
|
||||
.build();
|
||||
|
||||
slidingWindow.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
EasyRetryLog.LOCAL.info("AsyncReport Log about to shutdown");
|
||||
if (Objects.nonNull(slidingWindow)) {
|
||||
slidingWindow.end();
|
||||
}
|
||||
EasyRetryLog.LOCAL.info("AsyncReport Log has been shutdown");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 构建上报任务对象
|
||||
// *
|
||||
// * @return logContent 上报服务端对象
|
||||
// */
|
||||
// protected LogTaskDTO buildLogTaskDTO(LogContentDTO logContentDTO) {
|
||||
// LogMeta context = ThreadLocalLogUtil.getContext();
|
||||
//
|
||||
// LogTaskDTO logTaskDTO = new LogTaskDTO();
|
||||
// logTaskDTO.setJobId(context.getJobId());
|
||||
// logTaskDTO.setTaskId(context.getTaskId());
|
||||
// logTaskDTO.setTaskBatchId(context.getTaskBatchId());
|
||||
// logTaskDTO.setRealTime(logContentDTO.getTimeStamp());
|
||||
// logTaskDTO.setNamespaceId(context.getNamespaceId());
|
||||
// logTaskDTO.setGroupName(context.getGroupName());
|
||||
// logTaskDTO.setFieldList(logContentDTO.getFieldList());
|
||||
// return logTaskDTO;
|
||||
// }
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.aizuda.easy.retry.client.common.util;
|
||||
|
||||
|
||||
import com.aizuda.easy.retry.client.common.report.LogMeta;
|
||||
import com.aizuda.easy.retry.common.log.enums.LogTypeEnum;
|
||||
|
||||
/**
|
||||
* @author wodeyangzipingpingwuqi·
|
||||
* @date 2023-12-29
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ThreadLocalLogUtil {
|
||||
private static final ThreadLocal<LogTypeEnum> LOG_TYPE = new ThreadLocal<>();
|
||||
private static final ThreadLocal<LogMeta> JOB_CONTEXT_LOCAL = new ThreadLocal<>();
|
||||
|
||||
public static void initLogInfo(LogMeta logMeta, LogTypeEnum logType) {
|
||||
setContext(logMeta);
|
||||
setLogType(logType);
|
||||
}
|
||||
|
||||
public static void setContext(LogMeta logMeta) {
|
||||
JOB_CONTEXT_LOCAL.set(logMeta);
|
||||
}
|
||||
|
||||
public static LogMeta getContext() {
|
||||
return JOB_CONTEXT_LOCAL.get();
|
||||
}
|
||||
|
||||
public static void removeContext() {
|
||||
JOB_CONTEXT_LOCAL.remove();
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
JOB_CONTEXT_LOCAL.remove();
|
||||
LOG_TYPE.remove();
|
||||
}
|
||||
|
||||
public static void setLogType (LogTypeEnum logType) {
|
||||
LOG_TYPE.set(logType);
|
||||
}
|
||||
|
||||
public static LogTypeEnum getLogType () {
|
||||
return LOG_TYPE.get();
|
||||
}
|
||||
|
||||
public static void removeLogType () {
|
||||
LOG_TYPE.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common;
|
||||
package com.aizuda.easy.retry.client.core;
|
||||
|
||||
/**
|
||||
* @author www.byteblogs.com
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.client;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.core.IdempotentIdGenerate;
|
||||
import com.aizuda.easy.retry.client.core.RetryArgSerializer;
|
||||
import com.aizuda.easy.retry.client.common.cache.GroupVersionCache;
|
||||
@ -92,7 +92,7 @@ public class RetryEndPoint {
|
||||
retryLogMeta.setGroupName(executeReqDto.getGroupName());
|
||||
retryLogMeta.setNamespaceId(executeReqDto.getNamespaceId());
|
||||
retryLogMeta.setUniqueId(executeReqDto.getUniqueId());
|
||||
ThreadLocalLogUtil.initLogInfo(retryLogMeta, LogTypeEnum.RETRY);
|
||||
EasyRetryLogManager.initLogInfo(retryLogMeta, LogTypeEnum.RETRY);
|
||||
|
||||
RetryerResultContext retryerResultContext = retryStrategy.openRetry(executeReqDto.getScene(),
|
||||
executeReqDto.getExecutorName(), deSerialize);
|
||||
@ -125,7 +125,7 @@ public class RetryEndPoint {
|
||||
|
||||
} finally {
|
||||
RetrySiteSnapshot.removeAll();
|
||||
ThreadLocalLogUtil.removeAll();
|
||||
EasyRetryLogManager.removeAll();
|
||||
}
|
||||
|
||||
return new Result<>(executeRespDto);
|
||||
@ -152,7 +152,7 @@ public class RetryEndPoint {
|
||||
retryLogMeta.setGroupName(callbackDTO.getGroup());
|
||||
retryLogMeta.setNamespaceId(callbackDTO.getNamespaceId());
|
||||
retryLogMeta.setUniqueId(callbackDTO.getUniqueId());
|
||||
ThreadLocalLogUtil.initLogInfo(retryLogMeta, LogTypeEnum.RETRY);
|
||||
EasyRetryLogManager.initLogInfo(retryLogMeta, LogTypeEnum.RETRY);
|
||||
|
||||
retryerInfo = RetryerInfoCache.get(callbackDTO.getScene(), callbackDTO.getExecutorName());
|
||||
if (Objects.isNull(retryerInfo)) {
|
||||
@ -174,7 +174,7 @@ public class RetryEndPoint {
|
||||
// 若不是SpringBean 则直接反射以普通类调用
|
||||
return doCallbackForOrdinaryClass(callbackDTO, retryerInfo, deSerialize);
|
||||
} finally {
|
||||
ThreadLocalLogUtil.removeAll();
|
||||
EasyRetryLogManager.removeAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.core.log;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.report.LogMeta;
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogMeta;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.log;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.report.AbstractLogReport;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.report.AbstractLogReport;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.enums.LogTypeEnum;
|
||||
import com.aizuda.easy.retry.server.model.dto.RetryLogTaskDTO;
|
||||
@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
|
||||
public class RetryLogReport extends AbstractLogReport<RetryLogTaskDTO> {
|
||||
@Override
|
||||
protected RetryLogTaskDTO buildLogTaskDTO(LogContentDTO logContentDTO) {
|
||||
RetryLogMeta context = (RetryLogMeta) ThreadLocalLogUtil.getContext();
|
||||
RetryLogMeta context = (RetryLogMeta) EasyRetryLogManager.getLogMeta();
|
||||
RetryLogTaskDTO logTaskDTO = new RetryLogTaskDTO();
|
||||
logTaskDTO.setLogType(LogTypeEnum.RETRY.name());
|
||||
logTaskDTO.setUniqueId(context.getUniqueId());
|
||||
@ -29,6 +29,6 @@ public class RetryLogReport extends AbstractLogReport<RetryLogTaskDTO> {
|
||||
|
||||
@Override
|
||||
public boolean supports() {
|
||||
return LogTypeEnum.RETRY == ThreadLocalLogUtil.getLogType();
|
||||
return LogTypeEnum.RETRY == EasyRetryLogManager.getLogType();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.report;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.aizuda.easy.retry.client.common.Report;
|
||||
import com.aizuda.easy.retry.client.core.Report;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.common.core.expression.ExpressionEngine;
|
||||
import com.aizuda.easy.retry.client.core.IdempotentIdGenerate;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.core.strategy;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.Report;
|
||||
import com.aizuda.easy.retry.client.core.Report;
|
||||
import com.aizuda.easy.retry.client.common.cache.GroupVersionCache;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.core.RetryExecutor;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.job.core.client;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.job.core.IJobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.cache.JobExecutorInfoCache;
|
||||
import com.aizuda.easy.retry.client.job.core.cache.ThreadPoolCache;
|
||||
@ -71,7 +71,7 @@ public class JobEndPoint {
|
||||
EasyRetryLog.REMOTE.error("客户端发生非预期异常. taskBatchId:[{}]", dispatchJob.getTaskBatchId());
|
||||
throw e;
|
||||
} finally {
|
||||
ThreadLocalLogUtil.removeContext();
|
||||
EasyRetryLogManager.removeLogMeta();
|
||||
}
|
||||
|
||||
return new Result<>(Boolean.TRUE);
|
||||
@ -84,7 +84,7 @@ public class JobEndPoint {
|
||||
logMeta.setGroupName(jobContext.getGroupName());
|
||||
logMeta.setJobId(jobContext.getJobId());
|
||||
logMeta.setTaskBatchId(jobContext.getTaskBatchId());
|
||||
ThreadLocalLogUtil.initLogInfo(logMeta, LogTypeEnum.JOB);
|
||||
EasyRetryLogManager.initLogInfo(logMeta, LogTypeEnum.JOB);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.job.core.executor;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.job.core.IJobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.cache.FutureCache;
|
||||
import com.aizuda.easy.retry.client.job.core.cache.ThreadPoolCache;
|
||||
@ -56,7 +56,7 @@ public abstract class AbstractJobExecutor implements IJobExecutor {
|
||||
initLogContext(jobContext);
|
||||
return doJobExecute(jobArgs);
|
||||
} finally {
|
||||
ThreadLocalLogUtil.removeContext();
|
||||
EasyRetryLogManager.removeLogMeta();
|
||||
}
|
||||
|
||||
});
|
||||
@ -72,7 +72,7 @@ public abstract class AbstractJobExecutor implements IJobExecutor {
|
||||
logMeta.setGroupName(jobContext.getGroupName());
|
||||
logMeta.setJobId(jobContext.getJobId());
|
||||
logMeta.setTaskBatchId(jobContext.getTaskBatchId());
|
||||
ThreadLocalLogUtil.initLogInfo(logMeta, LogTypeEnum.JOB);
|
||||
EasyRetryLogManager.initLogInfo(logMeta, LogTypeEnum.JOB);
|
||||
}
|
||||
|
||||
private static JobArgs buildJobArgs(JobContext jobContext) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.job.core.executor;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.job.core.cache.ThreadPoolCache;
|
||||
import com.aizuda.easy.retry.client.job.core.client.JobNettyClient;
|
||||
import com.aizuda.easy.retry.client.job.core.log.JobLogMeta;
|
||||
@ -65,7 +65,7 @@ public class JobExecutorFutureCallback implements FutureCallback<ExecuteResult>
|
||||
} catch (Exception e) {
|
||||
EasyRetryLog.REMOTE.error("执行结果上报异常.[{}]", jobContext.getTaskId(), e);
|
||||
} finally {
|
||||
ThreadLocalLogUtil.removeContext();
|
||||
EasyRetryLogManager.removeLogMeta();
|
||||
stopThreadPool();
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class JobExecutorFutureCallback implements FutureCallback<ExecuteResult>
|
||||
} catch (Exception e) {
|
||||
EasyRetryLog.REMOTE.error("执行结果上报异常.[{}]", jobContext.getTaskId(), e);
|
||||
} finally {
|
||||
ThreadLocalLogUtil.removeContext();
|
||||
EasyRetryLogManager.removeLogMeta();
|
||||
stopThreadPool();
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class JobExecutorFutureCallback implements FutureCallback<ExecuteResult>
|
||||
logMeta.setGroupName(jobContext.getGroupName());
|
||||
logMeta.setJobId(jobContext.getJobId());
|
||||
logMeta.setTaskBatchId(jobContext.getTaskBatchId());
|
||||
ThreadLocalLogUtil.initLogInfo(logMeta, LogTypeEnum.JOB);
|
||||
EasyRetryLogManager.initLogInfo(logMeta, LogTypeEnum.JOB);
|
||||
}
|
||||
|
||||
private void stopThreadPool() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.job.core.log;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.report.LogMeta;
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogMeta;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.job.core.log;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.report.AbstractLogReport;
|
||||
import com.aizuda.easy.retry.client.common.util.ThreadLocalLogUtil;
|
||||
import com.aizuda.easy.retry.client.common.log.report.AbstractLogReport;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.enums.LogTypeEnum;
|
||||
import com.aizuda.easy.retry.server.model.dto.JobLogTaskDTO;
|
||||
@ -17,12 +17,12 @@ public class JobLogReport extends AbstractLogReport<JobLogTaskDTO> {
|
||||
|
||||
@Override
|
||||
public boolean supports () {
|
||||
return LogTypeEnum.JOB == ThreadLocalLogUtil.getLogType();
|
||||
return LogTypeEnum.JOB == EasyRetryLogManager.getLogType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JobLogTaskDTO buildLogTaskDTO(LogContentDTO logContentDTO) {
|
||||
JobLogMeta context = (JobLogMeta) ThreadLocalLogUtil.getContext();
|
||||
JobLogMeta context = (JobLogMeta) EasyRetryLogManager.getLogMeta();
|
||||
JobLogTaskDTO logTaskDTO = new JobLogTaskDTO();
|
||||
logTaskDTO.setJobId(context.getJobId());
|
||||
logTaskDTO.setLogType(LogTypeEnum.JOB.name());
|
||||
|
Loading…
Reference in New Issue
Block a user