feat(syslog): 完成高吞吐可靠链路与统计存储优化
- 新增接入 WAL、检查点、背压恢复及可靠分发机制,完善 Kafka 幂等发布、分区、重试、DLT 和补偿流程 - 引入规则预编译、批内快照及 JetCache/Caffeine 两级缓存,支持缓存失效广播、影子对账和执行指标 - 升级 InfluxDB V2 原始日志模型,统一接收时间与 Point 时间,支持按日 measurement、UUID 分桶及 V1/V2 双读 - 重构达梦标准化批量写入与统计链路,支持事务内直写、增量投影、幂等控制、窗口水位和日期切换 - 完善告警处理、配置校验、运行监控及测试覆盖
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
package com.common.util;
|
||||
|
||||
import java.time.DateTimeException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 解析接入端固定的 yyyyMMddHHmmssSSS 接收时间,兼容生产使用的 Java 8。 */
|
||||
public final class IngressReceiveTimeUtil {
|
||||
|
||||
private static final int RECEIVE_TIME_LENGTH = 17;
|
||||
|
||||
private IngressReceiveTimeUtil() {
|
||||
}
|
||||
|
||||
public static LocalDateTime parse(String value) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("receive_time 不能为空");
|
||||
}
|
||||
String text = value.trim();
|
||||
if (text.length() != RECEIVE_TIME_LENGTH) {
|
||||
throw new IllegalArgumentException("receive_time 必须为17位数字");
|
||||
}
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (!Character.isDigit(text.charAt(i))) {
|
||||
throw new IllegalArgumentException("receive_time 包含非数字字符");
|
||||
}
|
||||
}
|
||||
try {
|
||||
return LocalDateTime.of(
|
||||
integer(text, 0, 4),
|
||||
integer(text, 4, 6),
|
||||
integer(text, 6, 8),
|
||||
integer(text, 8, 10),
|
||||
integer(text, 10, 12),
|
||||
integer(text, 12, 14),
|
||||
integer(text, 14, 17) * 1_000_000);
|
||||
} catch (DateTimeException invalidDate) {
|
||||
throw new IllegalArgumentException("receive_time 日期时间无效", invalidDate);
|
||||
}
|
||||
}
|
||||
|
||||
private static int integer(String value, int start, int end) {
|
||||
return Integer.parseInt(value.substring(start, end));
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -144,8 +144,7 @@ public class JsonParser {
|
||||
LinkedHashMap<String, Object> resultMap = new LinkedHashMap<>();
|
||||
if(!isValidJson(jsonStr))
|
||||
{
|
||||
System.out.println("parseJsonToFlatMap() json str:"+jsonStr);
|
||||
System.out.println("isValidJson(string) is false");
|
||||
logger.warn("parseJsonToFlatMap 收到无效JSON,长度={}", jsonStr == null ? 0 : jsonStr.length());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -188,8 +187,7 @@ public class JsonParser {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception ex.message:"+ e.getMessage());
|
||||
|
||||
logger.error("flattenJson 处理异常: path={}, reason={}", currentPath, e.getMessage());
|
||||
throw new RuntimeException("flattenJson 处理异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -53,9 +53,8 @@ public class NestedJsonParserUtil {
|
||||
try {
|
||||
// 1. 预处理JSON字符串
|
||||
// String processedJson = preprocessJsonString(jsonStr, allowUnquoted, allowSingleQuotes);
|
||||
String processedJson =jsonStr;
|
||||
|
||||
System.out.println("processedJson:"+processedJson);
|
||||
String processedJson = jsonStr;
|
||||
logger.trace("准备解析JSON,长度={}", processedJson.length());
|
||||
// 2. 深度验证嵌套结构
|
||||
//validateNestedStructure(processedJson, maxDepth);
|
||||
//ObjectMapper mapper = new ObjectMapper(); // 这里使用Jackson
|
||||
@@ -73,7 +72,7 @@ public class NestedJsonParserUtil {
|
||||
return postProcessParsedData(result, maxDepth);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.error("JSON解析失败json:{} 错误消息: {}",jsonStr, e.getMessage());
|
||||
logger.warn("JSON解析失败,长度={}, 原因={}", jsonStr.length(), e.getMessage());
|
||||
|
||||
// 5. 尝试修复并重新解析
|
||||
try {
|
||||
@@ -84,13 +83,13 @@ public class NestedJsonParserUtil {
|
||||
return postProcessParsedData(result, maxDepth);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.error("JSON修复后解析仍然失败", ex);
|
||||
logger.debug("JSON修复后解析仍然失败: {}", ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
//return Collections.emptyMap();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("JSON解析发生未知异常", e);
|
||||
logger.warn("JSON解析发生未知异常,长度={}, 原因={}", jsonStr.length(), e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -507,4 +506,4 @@ public class NestedJsonParserUtil {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -106,4 +106,13 @@ public class SafeCacheUtil {
|
||||
return loader.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 缓存失效失败只记录为 false,不覆盖已经成功提交的数据库事实。 */
|
||||
public boolean evictSafely(String key) {
|
||||
try {
|
||||
return Boolean.TRUE.equals(redisTemplate.delete(key));
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user