From f6db2a7d5090279104e461489a8f7c1a3847609f Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Wed, 15 Dec 2021 00:16:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=BA=BF=E7=A8=8B=E6=B1=A0?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E4=BF=A1=E6=81=AF=E6=89=93=E5=8D=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starter/alarm/BaseSendMessageService.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/BaseSendMessageService.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/BaseSendMessageService.java index 39be88cc..1765c890 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/BaseSendMessageService.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/BaseSendMessageService.java @@ -1,6 +1,7 @@ package cn.hippo4j.starter.alarm; import cn.hippo4j.common.config.ApplicationContextHolder; +import cn.hippo4j.common.constant.Constants; import cn.hippo4j.common.model.PoolParameterInfo; import cn.hippo4j.common.toolkit.GroupKey; import cn.hippo4j.common.toolkit.JSONUtil; @@ -51,10 +52,11 @@ public class BaseSendMessageService implements InitializingBean, SendMessageServ @Override public void sendAlarmMessage(MessageTypeEnum typeEnum, DynamicThreadPoolExecutor executor) { + String threadPoolId = executor.getThreadPoolId(); String buildKey = StrUtil.builder(executor.getThreadPoolId(), "+", "ALARM").toString(); List notifyList = ALARM_NOTIFY_CONFIG.get(buildKey); if (CollUtil.isEmpty(notifyList)) { - log.warn("Please configure alarm notification on the server."); + log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); return; } @@ -62,7 +64,7 @@ public class BaseSendMessageService implements InitializingBean, SendMessageServ try { SendMessageHandler messageHandler = sendMessageHandlers.get(each.getPlatform()); if (messageHandler == null) { - log.warn("Please configure alarm notification on the server."); + log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); return; } @@ -70,17 +72,18 @@ public class BaseSendMessageService implements InitializingBean, SendMessageServ messageHandler.sendAlarmMessage(each, executor); } } catch (Exception ex) { - log.warn("Failed to send thread pool alarm notification.", ex); + log.warn("Failed to send thread pool alarm notification. key :: [{}]", threadPoolId, ex); } }); } @Override public void sendChangeMessage(PoolParameterInfo parameter) { + String threadPoolId = parameter.getTpId(); String buildKey = StrUtil.builder(parameter.getTpId(), "+", "CONFIG").toString(); List notifyList = ALARM_NOTIFY_CONFIG.get(buildKey); if (CollUtil.isEmpty(notifyList)) { - log.warn("Please configure alarm notification on the server."); + log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); return; } @@ -88,13 +91,13 @@ public class BaseSendMessageService implements InitializingBean, SendMessageServ try { SendMessageHandler messageHandler = sendMessageHandlers.get(each.getPlatform()); if (messageHandler == null) { - log.warn("Please configure alarm notification on the server."); + log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); return; } messageHandler.sendChangeMessage(each, parameter); } catch (Exception ex) { - log.warn("Failed to send thread pool change notification.", ex); + log.warn("Failed to send thread pool change notification. key :: [{}]", threadPoolId, ex); } }); } @@ -135,7 +138,7 @@ public class BaseSendMessageService implements InitializingBean, SendMessageServ Cache cache = CacheBuilder.newBuilder() .expireAfterWrite(each.getInterval(), TimeUnit.MINUTES) .build(); - AlarmControlHandler.THREAD_POOL_ALARM_CACHE.put(StrUtil.builder(each.getTpId(), "+", each.getPlatform()).toString(), cache); + AlarmControlHandler.THREAD_POOL_ALARM_CACHE.put(StrUtil.builder(each.getTpId(), Constants.GROUP_KEY_DELIMITER, each.getPlatform()).toString(), cache); }) ); }