diff --git a/alerter/src/main/java/com/usthe/alert/calculate/CalculateAlarm.java b/alerter/src/main/java/com/usthe/alert/calculate/CalculateAlarm.java index 4ae34b1..d694878 100644 --- a/alerter/src/main/java/com/usthe/alert/calculate/CalculateAlarm.java +++ b/alerter/src/main/java/com/usthe/alert/calculate/CalculateAlarm.java @@ -78,7 +78,13 @@ public class CalculateAlarm { .priority(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY) .status(CommonConstants.ALERT_STATUS_CODE_PENDING) .times(1); - if (metricsData.getCode() == CollectRep.Code.UN_REACHABLE) { + if (metricsData.getCode() == CollectRep.Code.UN_AVAILABLE) { + // 采集器不可用 + alertBuilder.target(CommonConstants.AVAILABLE) + .content("监控紧急可用性告警: " + metricsData.getCode().name()); + triggeredMonitorStateAlertMap.put(monitorId, CollectRep.Code.UN_AVAILABLE); + dataQueue.addAlertData(alertBuilder.build()); + } else if (metricsData.getCode() == CollectRep.Code.UN_REACHABLE) { // UN_REACHABLE 对端不可达(网络层icmp) alertBuilder.target(CommonConstants.REACHABLE) .content("监控紧急可达性告警: " + metricsData.getCode().name()); @@ -91,8 +97,11 @@ public class CalculateAlarm { triggeredMonitorStateAlertMap.put(monitorId, CollectRep.Code.UN_CONNECTABLE); dataQueue.addAlertData(alertBuilder.build()); } else { - // todo 其它规范异常 TIMEOUT ... - return; + // 其他异常 + alertBuilder.target(CommonConstants.AVAILABLE) + .content("监控紧急可用性告警: " + metricsData.getCode().name()); + triggeredMonitorStateAlertMap.put(monitorId, metricsData.getCode()); + dataQueue.addAlertData(alertBuilder.build()); } return; } else { diff --git a/common/src/main/java/com/usthe/common/entity/job/Job.java b/common/src/main/java/com/usthe/common/entity/job/Job.java index 77ae04a..fd15b2e 100644 --- a/common/src/main/java/com/usthe/common/entity/job/Job.java +++ b/common/src/main/java/com/usthe/common/entity/job/Job.java @@ -2,6 +2,7 @@ package com.usthe.common.entity.job; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.gson.Gson; import com.usthe.common.entity.message.CollectRep; import lombok.AllArgsConstructor; import lombok.Builder; @@ -180,4 +181,11 @@ public class Job { } responseDataTemp.add(metricsData); } + + private static final Gson GSON = new Gson(); + + public Job clone(){ + // 深度克隆 + return GSON.fromJson(GSON.toJsonTree(this), Job.class); + } } diff --git a/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java b/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java index 91045a5..35528a8 100644 --- a/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java +++ b/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java @@ -59,7 +59,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner { if (appDefine == null) { throw new IllegalArgumentException("The app " + app + " not support."); } - return appDefine; + return appDefine.clone(); } @Override @@ -123,7 +123,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner { public void run(String... args) throws Exception { // 读取app定义配置加载到内存中 define/app/*.yml Yaml yaml = new Yaml(); - String classpath = this.getClass().getResource(File.separator).getPath(); + String classpath = this.getClass().getClassLoader().getResource("").getPath(); String defineAppPath = classpath + File.separator + "define" + File.separator + "app"; File directory = new File(defineAppPath); if (!directory.exists() || directory.listFiles() == null) { diff --git a/warehouse/src/main/java/com/usthe/warehouse/store/TdEngineDataStorage.java b/warehouse/src/main/java/com/usthe/warehouse/store/TdEngineDataStorage.java index eca8932..4fd0859 100644 --- a/warehouse/src/main/java/com/usthe/warehouse/store/TdEngineDataStorage.java +++ b/warehouse/src/main/java/com/usthe/warehouse/store/TdEngineDataStorage.java @@ -138,7 +138,7 @@ public class TdEngineDataStorage implements DisposableBean { if (CommonConstants.NULL_VALUE.equals(value)) { sqlRowBuffer.append("NULL"); } else { - sqlRowBuffer.append("'").append(value).append("'"); + sqlRowBuffer.append("'").append(formatStringValue(value)).append("'"); } } if (index != fields.size() - 1) { @@ -197,7 +197,9 @@ public class TdEngineDataStorage implements DisposableBean { } } - + private String formatStringValue(String value){ + return value.replaceAll("(\\\\)|(')","\\\\$0"); + } @Override public void destroy() throws Exception { if (hikariDataSource != null) {