feat(3.2.0): 优化日志归档和新增日志
1. 手动完成重试任务添加接入实时日志 2. 修复重试日志的写入
This commit is contained in:
parent
7b80936474
commit
35a86e133b
@ -161,8 +161,7 @@ CREATE TABLE `retry_task_log_message`
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`message` longtext NOT NULL COMMENT '异常信息',
|
||||
`log_num` int(11) NOT NULL DEFAULT 1 COMMENT '日志数量',
|
||||
`real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间',
|
||||
`client_info` varchar(128) DEFAULT NULL COMMENT '客户端地址 clientId#ip:port',
|
||||
`real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间'
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `unique_id`),
|
||||
KEY `idx_create_dt` (`create_dt`)
|
||||
|
@ -231,8 +231,7 @@ CREATE TABLE retry_task_log_message
|
||||
group_name VARCHAR2(64) NOT NULL,
|
||||
unique_id VARCHAR2(64) NOT NULL,
|
||||
create_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
message CLOB DEFAULT '',
|
||||
client_info VARCHAR2(128) DEFAULT NULL
|
||||
message CLOB DEFAULT ''
|
||||
);
|
||||
|
||||
CREATE INDEX idx_retry_task_log_message_1 ON retry_task_log_message (namespace_id, group_name, unique_id);
|
||||
@ -245,7 +244,6 @@ COMMENT ON COLUMN retry_task_log_message.group_name IS '组名称';
|
||||
COMMENT ON COLUMN retry_task_log_message.unique_id IS '同组下id唯一';
|
||||
COMMENT ON COLUMN retry_task_log_message.create_dt IS '创建时间';
|
||||
COMMENT ON COLUMN retry_task_log_message.message IS '异常信息';
|
||||
COMMENT ON COLUMN retry_task_log_message.client_info IS '客户端地址 clientId#ip:port';
|
||||
|
||||
-- scene_config
|
||||
CREATE TABLE scene_config
|
||||
|
@ -227,7 +227,8 @@ CREATE TABLE retry_task_log_message
|
||||
unique_id VARCHAR(64) NOT NULL,
|
||||
create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
message TEXT NOT NULL,
|
||||
client_info VARCHAR(128) DEFAULT NULL
|
||||
log_num INT NOT NULL DEFAULT 1,
|
||||
real_time BIGINT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE INDEX idx_namespace_id_group_name_unique_id ON retry_task_log_message (namespace_id, group_name, unique_id);
|
||||
@ -238,7 +239,8 @@ COMMENT ON COLUMN retry_task_log_message.group_name IS '组名称';
|
||||
COMMENT ON COLUMN retry_task_log_message.unique_id IS '同组下id唯一';
|
||||
COMMENT ON COLUMN retry_task_log_message.create_dt IS '创建时间';
|
||||
COMMENT ON COLUMN retry_task_log_message.message IS '异常信息';
|
||||
COMMENT ON COLUMN retry_task_log_message.client_info IS '客户端地址 clientId#ip:port';
|
||||
COMMENT ON COLUMN retry_task_log_message.log_num IS '日志条数';
|
||||
COMMENT ON COLUMN retry_task_log_message.real_time IS '实际时间';
|
||||
COMMENT ON TABLE retry_task_log_message IS '任务调度日志信息记录表';
|
||||
|
||||
CREATE TABLE scene_config
|
||||
|
@ -1807,8 +1807,7 @@ CREATE TABLE retry_task_log_message
|
||||
group_name nvarchar(64) NOT NULL,
|
||||
unique_id nvarchar(64) NOT NULL,
|
||||
create_dt datetime2 NOT NULL DEFAULT GETDATE(),
|
||||
message nvarchar(max) NOT NULL,
|
||||
client_info nvarchar(128) NULL
|
||||
message nvarchar(max) NOT NULL
|
||||
)
|
||||
GO
|
||||
|
||||
@ -1859,13 +1858,6 @@ EXEC sp_addextendedproperty
|
||||
'COLUMN', N'message'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'客户端地址 clientId#ip:port',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'retry_task_log_message',
|
||||
'COLUMN', N'client_info'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'任务调度日志信息记录表',
|
||||
'SCHEMA', N'dbo',
|
||||
|
@ -114,15 +114,17 @@ public class RetryEndPoint {
|
||||
}
|
||||
|
||||
if (Objects.equals(RetryResultStatusEnum.SUCCESS.getStatus(), executeRespDto.getStatusCode())) {
|
||||
EasyRetryLog.REMOTE.info("remote retry complete. count:[{}] result:[{}]", executeReqDto.getRetryCount(),
|
||||
EasyRetryLog.REMOTE.info("remote retry【SUCCESS】. count:[{}] result:[{}]", executeReqDto.getRetryCount(),
|
||||
executeRespDto.getResultJson());
|
||||
}
|
||||
if (Objects.equals(RetryResultStatusEnum.STOP.getStatus(), executeRespDto.getStatusCode())) {
|
||||
EasyRetryLog.REMOTE.warn("remote retry complete. count:[{}] exceptionMsg:[{}]",
|
||||
} else if (Objects.equals(RetryResultStatusEnum.STOP.getStatus(), executeRespDto.getStatusCode())) {
|
||||
EasyRetryLog.REMOTE.warn("remote retry 【STOP】. count:[{}] exceptionMsg:[{}]",
|
||||
executeReqDto.getRetryCount(), executeRespDto.getExceptionMsg());
|
||||
} else {
|
||||
EasyRetryLog.REMOTE.error("remote retry complete. count:[{}] ", executeReqDto.getRetryCount(),
|
||||
} else if (Objects.equals(RetryResultStatusEnum.FAILURE.getStatus(), executeRespDto.getStatusCode())) {
|
||||
EasyRetryLog.REMOTE.error("remote retry 【FAILURE】. count:[{}] ", executeReqDto.getRetryCount(),
|
||||
retryerResultContext.getThrowable());
|
||||
} else {
|
||||
EasyRetryLog.REMOTE.error("remote retry 【UNKNOWN】. count:[{}] result:[{}]", executeReqDto.getRetryCount(),
|
||||
executeRespDto.getResultJson(), retryerResultContext.getThrowable());
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
@ -138,4 +138,9 @@ public interface SystemConstants {
|
||||
* Easy Retry 认证Token
|
||||
*/
|
||||
String EASY_RETRY_AUTH_TOKEN= "ER-TOKEN";
|
||||
|
||||
/**
|
||||
* 日志类型字段
|
||||
*/
|
||||
String JSON_FILED_LOG_TYPE = "logType" ;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.aizuda.easy.retry.template.datasource.persistence.mapper;
|
||||
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.JobLogMessage;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTaskLogMessage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
@ -45,11 +45,6 @@ public class RetryTaskLogMessage implements Serializable {
|
||||
*/
|
||||
private String uniqueId;
|
||||
|
||||
/**
|
||||
* 客户端信息
|
||||
*/
|
||||
private String clientInfo;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
@ -11,12 +11,11 @@
|
||||
<result column="log_num" property="logNum"/>
|
||||
<result column="message" property="message"/>
|
||||
<result column="real_time" property="realTime"/>
|
||||
<result column="client_info" property="clientInfo"/>
|
||||
</resultMap>
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
|
||||
create_dt, real_time, client_info)
|
||||
create_dt, real_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
@ -26,8 +25,7 @@
|
||||
#{item.logNum},
|
||||
#{item.message},
|
||||
#{item.createDt},
|
||||
#{item.realTime},
|
||||
#{item.clientInfo}
|
||||
#{item.realTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@ -11,12 +11,11 @@
|
||||
<result column="log_num" property="logNum"/>
|
||||
<result column="message" property="message"/>
|
||||
<result column="real_time" property="realTime"/>
|
||||
<result column="client_info" property="clientInfo"/>
|
||||
</resultMap>
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
|
||||
create_dt, real_time, client_info)
|
||||
create_dt, real_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
@ -26,8 +25,7 @@
|
||||
#{item.logNum},
|
||||
#{item.message},
|
||||
#{item.createDt},
|
||||
#{item.realTime},
|
||||
#{item.clientInfo}
|
||||
#{item.realTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@ -11,4 +11,35 @@
|
||||
<result column="message" property="message" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
|
||||
create_dt, real_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.uniqueId},
|
||||
#{item.logNum},
|
||||
#{item.message},
|
||||
#{item.createDt},
|
||||
#{item.realTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="batchUpdate" parameterType="java.util.List">
|
||||
UPDATE retry_task_log_message jlm,
|
||||
(
|
||||
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
|
||||
SELECT
|
||||
#{item.message} AS message,
|
||||
#{item.logNum} AS log_num,
|
||||
#{item.id} AS id
|
||||
</foreach>
|
||||
) tt
|
||||
SET jlm.message = tt.message, jlm.log_num = tt.log_num
|
||||
WHERE jlm.id = tt.id
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
@ -7,16 +7,21 @@ import ch.qos.logback.classic.spi.ThrowableProxyUtil;
|
||||
import ch.qos.logback.core.CoreConstants;
|
||||
import ch.qos.logback.core.UnsynchronizedAppenderBase;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.core.util.NetUtil;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.common.log.constant.LogFieldConstants;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.enums.LogTypeEnum;
|
||||
import com.aizuda.easy.retry.server.common.LogStorage;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.LogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.log.LogStorageFactory;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -64,23 +69,37 @@ public class EasyRetryServerLogbackAppender<E> extends UnsynchronizedAppenderBas
|
||||
continue;
|
||||
}
|
||||
|
||||
logMetaDTO = JsonUtil.parseObject(extractedData, LogMetaDTO.class);
|
||||
JsonNode jsonNode = JsonUtil.toJson(extractedData);
|
||||
if (!jsonNode.has(SystemConstants.JSON_FILED_LOG_TYPE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = jsonNode.get(SystemConstants.JSON_FILED_LOG_TYPE).asText();
|
||||
if (LogTypeEnum.RETRY.equals(LogTypeEnum.valueOf(name))) {
|
||||
logMetaDTO = JsonUtil.parseObject(extractedData, RetryLogMetaDTO.class);
|
||||
} else if (LogTypeEnum.JOB.equals(LogTypeEnum.valueOf(name))) {
|
||||
logMetaDTO = JsonUtil.parseObject(extractedData, JobLogMetaDTO.class);
|
||||
} else {
|
||||
throw new IllegalArgumentException("logType is not support");
|
||||
}
|
||||
|
||||
String message = event.getFormattedMessage().replaceFirst(patternString, StrUtil.EMPTY);
|
||||
logContentDTO.addMessageField(message);
|
||||
logContentDTO.addTimeStamp(Optional.ofNullable(logMetaDTO.getTimestamp()).orElse(event.getTimeStamp()));
|
||||
break;
|
||||
}
|
||||
|
||||
if (Objects.isNull(logMetaDTO)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存执行的日志
|
||||
saveLog(logContentDTO, logMetaDTO);
|
||||
|
||||
} catch (Exception e) {
|
||||
EasyRetryLog.LOCAL.error("日志解析失败. msg:[{}]", event.getFormattedMessage(), e);
|
||||
}
|
||||
|
||||
if (Objects.isNull(logMetaDTO)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存执行的日志
|
||||
saveLog(logContentDTO, logMetaDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.job.task.dto;
|
||||
package com.aizuda.easy.retry.server.common.dto;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.log.enums.LogTypeEnum;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.dto;
|
||||
package com.aizuda.easy.retry.server.common.dto;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.log.enums.LogTypeEnum;
|
@ -5,6 +5,7 @@ import com.aizuda.easy.retry.server.common.LogStorage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author: xiaowoniu
|
||||
@ -13,7 +14,8 @@ import java.util.Map;
|
||||
*/
|
||||
public final class LogStorageFactory {
|
||||
|
||||
private static final Map<LogTypeEnum, LogStorage> LOG_STORAGE = new HashMap<>();
|
||||
private LogStorageFactory() {}
|
||||
private static final Map<LogTypeEnum, LogStorage> LOG_STORAGE = new ConcurrentHashMap<>();
|
||||
|
||||
public static void register(LogTypeEnum logType, LogStorage logStorage) {
|
||||
LOG_STORAGE.put(logType, logStorage);
|
||||
|
@ -117,7 +117,7 @@ public class ServerRegister extends AbstractRegister {
|
||||
List<ServerNode> serverNodes = serverNodeMapper.selectList(
|
||||
new LambdaQueryWrapper<ServerNode>()
|
||||
.eq(ServerNode::getNodeType, NodeTypeEnum.CLIENT.getType())
|
||||
.in(ServerNode::getNamespaceId, new HashSet<>(allConsumerGroupName.values()))
|
||||
.in(ServerNode::getNamespaceId, namespaceIdSets)
|
||||
.in(ServerNode::getGroupName, allConsumerGroupName.keySet()));
|
||||
for (final ServerNode node : serverNodes) {
|
||||
// 刷新全量本地缓存
|
||||
|
@ -2,7 +2,7 @@ package com.aizuda.easy.retry.server.job.task.support;
|
||||
|
||||
import com.aizuda.easy.retry.client.model.request.DispatchJobRequest;
|
||||
import com.aizuda.easy.retry.client.model.request.DispatchJobResultRequest;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.*;
|
||||
import com.aizuda.easy.retry.server.job.task.support.block.job.BlockStrategyContext;
|
||||
import com.aizuda.easy.retry.server.job.task.support.executor.workflow.WorkflowExecutorContext;
|
||||
|
@ -11,6 +11,7 @@ import com.aizuda.easy.retry.server.model.dto.JobLogTaskDTO;
|
||||
import com.aizuda.easy.retry.server.model.dto.LogTaskDTO;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobLogMessageMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.JobLogMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
@ -34,10 +35,9 @@ import java.util.stream.Collectors;
|
||||
@Component(ActorGenerator.JOB_LOG_ACTOR)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class JobLogActor extends AbstractActor {
|
||||
|
||||
@Autowired
|
||||
private JobLogMessageMapper jobLogMessageMapper;
|
||||
private final JobLogMessageMapper jobLogMessageMapper;
|
||||
|
||||
@Override
|
||||
public Receive createReceive() {
|
||||
@ -89,6 +89,7 @@ public class JobLogActor extends AbstractActor {
|
||||
private void saveLogMessage(JobLogDTO jobLogDTO) {
|
||||
JobLogMessage jobLogMessage = JobTaskConverter.INSTANCE.toJobLogMessage(jobLogDTO);
|
||||
jobLogMessage.setCreateDt(LocalDateTime.now());
|
||||
jobLogMessage.setLogNum(1);
|
||||
jobLogMessage.setMessage(Optional.ofNullable(jobLogDTO.getMessage()).orElse(StrUtil.EMPTY));
|
||||
jobLogMessage.setTaskId(Optional.ofNullable(jobLogMessage.getTaskId()).orElse(0L));
|
||||
jobLogMessageMapper.insert(jobLogMessage);
|
||||
|
@ -15,7 +15,7 @@ import com.aizuda.easy.retry.server.common.dto.RegisterNodeInfo;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.job.task.client.JobRpcClient;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobExecutorResultDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.RealJobExecutorDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.support.ClientCallbackHandler;
|
||||
import com.aizuda.easy.retry.server.job.task.support.JobTaskConverter;
|
||||
|
@ -12,7 +12,7 @@ import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.server.common.client.RequestInterceptor;
|
||||
import com.aizuda.easy.retry.server.common.dto.CallbackConfig;
|
||||
import com.aizuda.easy.retry.server.common.enums.ContentTypeEnum;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.support.WorkflowTaskConverter;
|
||||
import com.aizuda.easy.retry.server.model.dto.CallbackParamsDTO;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobTaskMapper;
|
||||
|
@ -12,7 +12,7 @@ import com.aizuda.easy.retry.server.common.dto.DecisionConfig;
|
||||
import com.aizuda.easy.retry.server.common.enums.ExpressionTypeEnum;
|
||||
import com.aizuda.easy.retry.server.common.enums.LogicalConditionEnum;
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.support.expression.ExpressionInvocationHandler;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobTaskMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.JobTask;
|
||||
|
@ -9,7 +9,7 @@ import com.aizuda.easy.retry.common.core.enums.WorkflowNodeTypeEnum;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobTaskPrepareDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.support.JobTaskConverter;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.JobTask;
|
||||
|
@ -10,7 +10,7 @@ import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
||||
import com.aizuda.easy.retry.server.common.dto.LogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.log.LogStorageFactory;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobLogDTO;
|
||||
import com.aizuda.easy.retry.server.job.task.dto.JobLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.JobLogMetaDTO;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -2,7 +2,7 @@ package com.aizuda.easy.retry.server.retry.task.support;
|
||||
|
||||
import com.aizuda.easy.retry.server.model.dto.RetryLogTaskDTO;
|
||||
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.NotifyConfigPartitionTask;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.RetryPartitionTask;
|
||||
import com.aizuda.easy.retry.server.retry.task.generator.task.TaskContext;
|
||||
|
@ -13,7 +13,7 @@ import com.aizuda.easy.retry.server.common.dto.RegisterNodeInfo;
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.retry.task.client.RetryRpcClient;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryTaskConverter;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.context.CallbackRetryContext;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.handler.CallbackRetryTaskHandler;
|
||||
|
@ -15,7 +15,7 @@ import com.aizuda.easy.retry.server.common.client.RequestBuilder;
|
||||
import com.aizuda.easy.retry.server.common.dto.RegisterNodeInfo;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.retry.task.client.RetryRpcClient;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryTaskConverter;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.context.MaxAttemptsPersistenceRetryContext;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.retry.RetryExecutor;
|
||||
|
@ -9,6 +9,7 @@ import com.aizuda.easy.retry.server.model.dto.RetryLogTaskDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryTaskConverter;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.RetryTaskLogMessageMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTaskLogMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
@ -33,11 +34,9 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Component(ActorGenerator.LOG_ACTOR)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class RetryLogActor extends AbstractActor {
|
||||
|
||||
@Autowired
|
||||
private RetryTaskLogMessageMapper retryTaskLogMessageMapper;
|
||||
private final RetryTaskLogMessageMapper retryTaskLogMessageMapper;
|
||||
|
||||
@Override
|
||||
public Receive createReceive() {
|
||||
@ -88,8 +87,10 @@ public class RetryLogActor extends AbstractActor {
|
||||
RetryTaskLogMessage retryTaskLogMessage = new RetryTaskLogMessage();
|
||||
retryTaskLogMessage.setUniqueId(retryTaskLogDTO.getUniqueId());
|
||||
retryTaskLogMessage.setGroupName(retryTaskLogDTO.getGroupName());
|
||||
retryTaskLogMessage.setClientInfo(retryTaskLogDTO.getClientInfo());
|
||||
// retryTaskLogMessage.setClientInfo(retryTaskLogDTO.getClientInfo());
|
||||
retryTaskLogMessage.setNamespaceId(retryTaskLogDTO.getNamespaceId());
|
||||
retryTaskLogMessage.setLogNum(1);
|
||||
retryTaskLogMessage.setRealTime(retryTaskLogDTO.getRealTime());
|
||||
String errorMessage = retryTaskLogDTO.getMessage();
|
||||
retryTaskLogMessage.setMessage(
|
||||
StrUtil.isBlank(errorMessage) ? StrUtil.EMPTY : errorMessage);
|
||||
|
@ -7,7 +7,7 @@ import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.handler.ClientNodeAllocateHandler;
|
||||
import com.aizuda.easy.retry.server.common.IdempotentStrategy;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryContext;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryTaskConverter;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.retry.RetryExecutor;
|
||||
@ -65,20 +65,10 @@ public abstract class AbstractTaskExecutor implements TaskExecutor, Initializing
|
||||
retryTask.getGroupName(),
|
||||
retryTask.getUniqueId(), pair.getValue().toString());
|
||||
|
||||
// 记录日志
|
||||
// RetryTaskLogDTO retryTaskLog = new RetryTaskLogDTO();
|
||||
// retryTaskLog.setGroupName(retryTask.getGroupName());
|
||||
// retryTaskLog.setUniqueId(retryTask.getUniqueId());
|
||||
// retryTaskLog.setRetryStatus(retryTask.getRetryStatus());
|
||||
// retryTaskLog.setMessage(pair.getValue().toString());
|
||||
// retryTaskLog.setTriggerTime(LocalDateTime.now());
|
||||
// ActorRef actorRef = ActorGenerator.logActor();
|
||||
|
||||
RetryLogMetaDTO retryLogMetaDTO = RetryTaskConverter.INSTANCE.toLogMetaDTO(retryTask);
|
||||
retryLogMetaDTO.setTimestamp(DateUtils.toNowMilli());
|
||||
EasyRetryLog.REMOTE.error("触发条件不满足 原因: [{}] <|>{}<|>", pair.getValue().toString(), retryLogMetaDTO);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,6 @@ public class RetryTaskExecutor extends AbstractTaskExecutor {
|
||||
.withStopStrategy(StopStrategies.stopException())
|
||||
.withStopStrategy(StopStrategies.stopResultStatusCode())
|
||||
.withWaitStrategy(getWaitWaitStrategy(sceneConfig))
|
||||
// .withFilterStrategy(FilterStrategies.triggerAtFilter())
|
||||
.withFilterStrategy(FilterStrategies.bitSetIdempotentFilter(idempotentStrategy))
|
||||
.withFilterStrategy(FilterStrategies.sceneBlackFilter())
|
||||
.withFilterStrategy(FilterStrategies.checkAliveClientPodFilter())
|
||||
|
@ -9,7 +9,7 @@ import com.aizuda.easy.retry.server.common.LogStorage;
|
||||
import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
||||
import com.aizuda.easy.retry.server.common.dto.LogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.log.LogStorageFactory;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.dispatch.actor.log.RetryTaskLogDTO;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@ -29,24 +29,24 @@ public class RetryLogStorage implements LogStorage, InitializingBean {
|
||||
|
||||
@Override
|
||||
public LogTypeEnum logType() {
|
||||
return LogTypeEnum.JOB;
|
||||
return LogTypeEnum.RETRY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storage(final LogContentDTO logContentDTO, final LogMetaDTO logMetaDTO) {
|
||||
RetryLogMetaDTO retryLogMetaDTO = (RetryLogMetaDTO) logMetaDTO;
|
||||
RetryTaskLogDTO jobLogDTO = new RetryTaskLogDTO();
|
||||
RetryTaskLogDTO retryTaskLogDTO = new RetryTaskLogDTO();
|
||||
Map<String, String> messageMap = logContentDTO.getFieldList()
|
||||
.stream()
|
||||
.filter(logTaskDTO_ -> !Objects.isNull(logTaskDTO_.getValue()))
|
||||
.collect(Collectors.toMap(TaskLogFieldDTO::getName, TaskLogFieldDTO::getValue));
|
||||
jobLogDTO.setMessage(JsonUtil.toJsonString(Lists.newArrayList(messageMap)));
|
||||
jobLogDTO.setGroupName(retryLogMetaDTO.getGroupName());
|
||||
jobLogDTO.setNamespaceId(retryLogMetaDTO.getNamespaceId());
|
||||
jobLogDTO.setUniqueId(retryLogMetaDTO.getUniqueId());
|
||||
jobLogDTO.setRealTime(retryLogMetaDTO.getTimestamp());
|
||||
ActorRef actorRef = ActorGenerator.jobLogActor();
|
||||
actorRef.tell(jobLogDTO, actorRef);
|
||||
retryTaskLogDTO.setMessage(JsonUtil.toJsonString(Lists.newArrayList(messageMap)));
|
||||
retryTaskLogDTO.setGroupName(retryLogMetaDTO.getGroupName());
|
||||
retryTaskLogDTO.setNamespaceId(retryLogMetaDTO.getNamespaceId());
|
||||
retryTaskLogDTO.setUniqueId(retryLogMetaDTO.getUniqueId());
|
||||
retryTaskLogDTO.setRealTime(retryLogMetaDTO.getTimestamp());
|
||||
ActorRef actorRef = ActorGenerator.logActor();
|
||||
actorRef.tell(retryTaskLogDTO, actorRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,7 @@ import cn.hutool.core.lang.Pair;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.retry.task.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.FilterStrategy;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryContext;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryTaskConverter;
|
||||
|
@ -3,6 +3,7 @@ package com.aizuda.easy.retry.server.starter.server.handler;
|
||||
import akka.actor.ActorRef;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||
import com.aizuda.easy.retry.common.core.enums.HeadersEnum;
|
||||
import com.aizuda.easy.retry.common.core.enums.StatusEnum;
|
||||
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
|
||||
@ -25,6 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.aizuda.easy.retry.common.core.constant.SystemConstants.HTTP_PATH.BATCH_LOG_REPORT;
|
||||
|
||||
@ -52,7 +54,7 @@ public class ReportLogHttpRequestHandler extends PostHttpRequestHandler {
|
||||
@Override
|
||||
public String doHandler(String content, UrlQuery urlQuery, HttpHeaders headers) {
|
||||
|
||||
EasyRetryLog.LOCAL.info("Begin Handler Log Report Data. [{}]", content);
|
||||
EasyRetryLog.LOCAL.debug("Begin Handler Log Report Data. [{}]", content);
|
||||
EasyRetryRequest retryRequest = JsonUtil.parseObject(content, EasyRetryRequest.class);
|
||||
Object[] args = retryRequest.getArgs();
|
||||
|
||||
@ -62,11 +64,13 @@ public class ReportLogHttpRequestHandler extends PostHttpRequestHandler {
|
||||
List<RetryLogTaskDTO> retryTasks = Lists.newArrayList();
|
||||
List<JobLogTaskDTO> jobTasks = Lists.newArrayList();
|
||||
for (final JsonNode node : jsonNode) {
|
||||
if (node.findValue(JSON_FILED).asText().equals(LogTypeEnum.JOB.name())) {
|
||||
JsonNode value = node.findValue(SystemConstants.JSON_FILED_LOG_TYPE);
|
||||
if (Objects.isNull(value) || value.asText().equals(LogTypeEnum.JOB.name())) {
|
||||
jobTasks.add(JsonUtil.parseObject(node.toPrettyString(), JobLogTaskDTO.class));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.findValue(JSON_FILED).asText().equals(LogTypeEnum.RETRY.name())) {
|
||||
if (value.asText().equals(LogTypeEnum.RETRY.name())) {
|
||||
retryTasks.add(JsonUtil.parseObject(node.toPrettyString(), RetryLogTaskDTO.class));
|
||||
}
|
||||
}
|
||||
@ -78,10 +82,6 @@ public class ReportLogHttpRequestHandler extends PostHttpRequestHandler {
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(retryTasks)) {
|
||||
String clintInfo = getClientInfo(headers);
|
||||
for (final RetryLogTaskDTO retryTask : retryTasks) {
|
||||
retryTask.setClientInfo(clintInfo);
|
||||
}
|
||||
ActorRef actorRef = ActorGenerator.logActor();
|
||||
actorRef.tell(retryTasks, actorRef);
|
||||
}
|
||||
|
@ -146,11 +146,6 @@ public class RetryTaskLogServiceImpl implements RetryTaskLogService {
|
||||
int size = originalList.size() - fromIndex;
|
||||
List<Map<String, String>> pageList = originalList.stream().skip(fromIndex).limit(queryVO.getSize())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
map.put("clientInfo", retryTaskLogMessage.getClientInfo());
|
||||
originalList.add(map);
|
||||
|
||||
if (messages.size() + size >= queryVO.getSize()) {
|
||||
messages.addAll(pageList);
|
||||
nextStartId = retryTaskLogMessage.getId();
|
||||
@ -161,8 +156,6 @@ public class RetryTaskLogServiceImpl implements RetryTaskLogService {
|
||||
messages.addAll(pageList);
|
||||
nextStartId = retryTaskLogMessage.getId() + 1;
|
||||
fromIndex = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
messages = messages.stream().sorted((o1, o2) -> {
|
||||
|
@ -7,6 +7,7 @@ import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
||||
import com.aizuda.easy.retry.common.core.enums.StatusEnum;
|
||||
import com.aizuda.easy.retry.common.core.model.Result;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.server.common.WaitStrategy;
|
||||
import com.aizuda.easy.retry.server.common.cache.CacheRegisterTable;
|
||||
import com.aizuda.easy.retry.server.common.client.RequestBuilder;
|
||||
@ -19,9 +20,11 @@ import com.aizuda.easy.retry.server.common.strategy.WaitStrategies.WaitStrategyE
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.client.RetryRpcClient;
|
||||
import com.aizuda.easy.retry.server.common.dto.RetryLogMetaDTO;
|
||||
import com.aizuda.easy.retry.server.retry.task.generator.task.TaskContext;
|
||||
import com.aizuda.easy.retry.server.retry.task.generator.task.TaskGenerator;
|
||||
import com.aizuda.easy.retry.server.common.handler.ClientNodeAllocateHandler;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.RetryTaskConverter;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.dispatch.task.TaskExecutor;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.dispatch.task.TaskExecutorSceneEnum;
|
||||
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
||||
@ -45,7 +48,6 @@ import com.aizuda.easy.retry.template.datasource.persistence.mapper.RetryTaskLog
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTaskLog;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTaskLogMessage;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@ -78,8 +80,6 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
||||
@Autowired
|
||||
private ClientNodeAllocateHandler clientNodeAllocateHandler;
|
||||
@Autowired
|
||||
private RetryTaskLogMessageMapper retryTaskLogMessageMapper;
|
||||
@Autowired
|
||||
private RetryTaskLogMapper retryTaskLogMapper;
|
||||
@Autowired
|
||||
private AccessTemplate accessTemplate;
|
||||
@ -178,12 +178,9 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
||||
}
|
||||
|
||||
if (RetryStatusEnum.FINISH.getStatus().equals(retryStatusEnum.getStatus())) {
|
||||
RetryTaskLogMessage retryTaskLogMessage = new RetryTaskLogMessage();
|
||||
retryTaskLogMessage.setUniqueId(retryTask.getUniqueId());
|
||||
retryTaskLogMessage.setGroupName(retryTask.getGroupName());
|
||||
retryTaskLogMessage.setMessage("手动操作完成");
|
||||
retryTaskLogMessage.setCreateDt(LocalDateTime.now());
|
||||
retryTaskLogMessageMapper.insert(retryTaskLogMessage);
|
||||
RetryLogMetaDTO retryLogMetaDTO = RetryTaskConverter.INSTANCE.toLogMetaDTO(retryTask);
|
||||
retryLogMetaDTO.setTimestamp(DateUtils.toNowMilli());
|
||||
EasyRetryLog.REMOTE.info("=============手动操作完成============. <|>{}<|>", retryLogMetaDTO);
|
||||
}
|
||||
|
||||
RetryTaskLog retryTaskLog = new RetryTaskLog();
|
||||
|
Loading…
Reference in New Issue
Block a user