From ee60b65102a4ceb4b1ed4b6c3ccc06d6b25cb251 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Thu, 10 Mar 2022 20:38:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=A8=A1=E5=9D=97.=20(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ....java => HippoBaseSendMessageService.java} | 12 ++- .../notify/platform/DingAlarmConstants.java | 74 +++++++++---------- .../platform/DingSendMessageHandler.java | 2 + .../notify/platform/LarkAlarmConstants.java | 2 +- .../platform/LarkSendMessageHandler.java | 2 + .../notify/platform/WeChatAlarmConstants.java | 5 +- .../platform/WeChatSendMessageHandler.java | 2 + .../request/ChangeParameterNotifyRequest.java | 4 + .../ThreadPoolNotifyAlarmHandler.java | 10 +++ .../config/MessageNotifyConfiguration.java | 2 +- .../core/ServerThreadPoolDynamicRefresh.java | 9 ++- 11 files changed, 79 insertions(+), 45 deletions(-) rename hippo4j-common/src/main/java/cn/hippo4j/common/notify/{BaseSendMessageServiceImpl.java => HippoBaseSendMessageService.java} (93%) diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/BaseSendMessageServiceImpl.java b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/HippoBaseSendMessageService.java similarity index 93% rename from hippo4j-common/src/main/java/cn/hippo4j/common/notify/BaseSendMessageServiceImpl.java rename to hippo4j-common/src/main/java/cn/hippo4j/common/notify/HippoBaseSendMessageService.java index 7e26cff5..07904b96 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/BaseSendMessageServiceImpl.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/HippoBaseSendMessageService.java @@ -22,7 +22,7 @@ import java.util.Map; */ @Slf4j @RequiredArgsConstructor -public class BaseSendMessageServiceImpl implements HippoSendMessageService, CommandLineRunner { +public class HippoBaseSendMessageService implements HippoSendMessageService, CommandLineRunner { private final NotifyConfigBuilder notifyConfigBuilder; @@ -38,7 +38,6 @@ public class BaseSendMessageServiceImpl implements HippoSendMessageService, Comm String buildKey = StrUtil.builder(threadPoolId, "+", "ALARM").toString(); List notifyList = notifyConfigs.get(buildKey); if (CollUtil.isEmpty(notifyList)) { - log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); return; } @@ -113,4 +112,13 @@ public class BaseSendMessageServiceImpl implements HippoSendMessageService, Comm notifyConfigs.putAll(buildNotify); } + /** + * Put platform. + * + * @param notifyConfigs + */ + public synchronized void putPlatform(Map> notifyConfigs) { + this.notifyConfigs.putAll(notifyConfigs); + } + } diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingAlarmConstants.java b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingAlarmConstants.java index f8d14050..380d4b9a 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingAlarmConstants.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingAlarmConstants.java @@ -26,14 +26,14 @@ public class DingAlarmConstants { /** * Trace 信息 */ - public static final String DING_ALARM_TIMOUT_TRACE_REPLACE_TXT = "链路信息:%s \n\n"; + public static final String DING_ALARM_TIMOUT_TRACE_REPLACE_TXT = "链路信息:%s \n\n"; /** * 替换任务超时模板 */ public static final String DING_ALARM_TIMOUT_REPLACE_TXT = - "任务执行时间:%d / ms \n\n" + - "超时时间:%d / ms \n\n" + + "任务执行时间:%d / ms \n\n" + + "超时时间:%d / ms \n\n" + DING_ALARM_TIMOUT_TRACE_REPLACE_TXT + " --- \n\n "; @@ -41,30 +41,30 @@ public class DingAlarmConstants { * 线程池报警通知文本 */ public static final String DING_ALARM_TXT = - "[警报] %s - 动态线程池运行告警(%s) \n\n" + + "**[警报] %s - 动态线程池运行告警(%s)** \n\n" + " --- \n\n " + - "线程池ID:%s \n\n " + - "应用名称:%s \n\n " + - "应用实例:%s \n\n " + - "实例标识:%s \n\n " + + "线程池ID:%s \n\n " + + "应用名称:%s \n\n " + + "应用实例:%s \n\n " + + "实例标识:%s \n\n " + " --- \n\n " + - "核心线程数:%d \n\n " + - "最大线程数:%d \n\n " + - "当前线程数:%d \n\n " + - "活跃线程数:%d \n\n " + - "最大任务数:%d \n\n " + - "线程池任务总量:%d \n\n " + + "核心线程数:%d \n\n " + + "最大线程数:%d \n\n " + + "当前线程数:%d \n\n " + + "活跃线程数:%d \n\n " + + "最大任务数:%d \n\n " + + "线程池任务总量:%d \n\n " + " --- \n\n " + - "队列类型:%s \n\n " + - "队列容量:%d \n\n " + - "队列元素个数:%d \n\n " + - "队列剩余个数:%d \n\n " + + "队列类型:%s \n\n " + + "队列容量:%d \n\n " + + "队列元素个数:%d \n\n " + + "队列剩余个数:%d \n\n " + " --- \n\n " + DING_ALARM_TIMOUT_REPLACE_TXT + - "拒绝策略:%s \n\n" + - "拒绝策略执行次数:%d \n\n " + - "OWNER:@%s \n\n" + - "提示:%d 分钟内此线程池不会重复告警(可配置) \n\n" + + "拒绝策略:%s \n\n" + + "拒绝策略执行次数:%d \n\n " + + "OWNER:@%s \n\n" + + "提示:%d 分钟内此线程池不会重复告警(可配置) \n\n" + " --- \n\n " + "**播报时间:%s**"; @@ -72,25 +72,25 @@ public class DingAlarmConstants { * 线程池参数变更通知文本 */ public static final String DING_NOTICE_TXT = - "[通知] %s - 动态线程池参数变更 \n\n" + + "**[通知] %s - 动态线程池参数变更** \n\n" + " --- \n\n " + - "线程池ID:%s \n\n " + - "应用名称:%s \n\n " + - "应用实例:%s \n\n " + + "线程池ID:%s \n\n " + + "应用名称:%s \n\n " + + "应用实例:%s \n\n " + " --- \n\n " + - "核心线程数:%s \n\n " + - "最大线程数:%s \n\n " + - "核心线程超时:%s \n\n " + - "线程存活时间:%s / SECONDS \n\n" + + "核心线程数:%s \n\n " + + "最大线程数:%s \n\n " + + "核心线程超时:%s \n\n " + + "线程存活时间:%s \n\n" + + "执行超时时间:%s \n\n" + " --- \n\n " + - "队列类型:%s \n\n " + - "队列容量:%s \n\n " + + "队列类型:%s \n\n " + + "队列容量:%s \n\n " + + "AGO 拒绝策略:%s \n\n" + + "NOW 拒绝策略:%s \n\n" + " --- \n\n " + - "AGO 拒绝策略:%s \n\n" + - "NOW 拒绝策略:%s \n\n" + - " --- \n\n " + - "提示:动态线程池配置变更实时通知(无限制) \n\n" + - "OWNER:@%s \n\n" + + "提示:动态线程池配置变更实时通知(无限制) \n\n" + + "OWNER:@%s \n\n" + " --- \n\n " + "**播报时间:%s**"; diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingSendMessageHandler.java b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingSendMessageHandler.java index 059e782c..52f77d9a 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingSendMessageHandler.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/DingSendMessageHandler.java @@ -133,6 +133,8 @@ public class DingSendMessageHandler implements SendMessageHandler 队列元素个数:%s \n" + "> 队列剩余个数:%s \n" + "> 拒绝策略:%s \n" + - "> 拒绝策略执行次数:%s \n" + + "> 拒绝策略执行次数:%s \n" + WE_CHAT_ALARM_TIMOUT_REPLACE_TXT + "> OWNER:<@%s> \n" + "> 提示:%d 分钟内此线程池不会重复告警(可配置) \n\n" + @@ -62,7 +62,8 @@ public class WeChatAlarmConstants { "> 核心线程数:%s \n" + "> 最大线程数:%s \n" + "> 核心线程超时:%s \n" + - "> 线程存活时间:%s / SECONDS \n" + + "> 线程存活时间:%s \n" + + "> 执行超时时间:%s \n" + "> 队列类型:%s \n" + "> 队列容量:%s \n" + "> AGO 拒绝策略:%s \n" + diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/WeChatSendMessageHandler.java b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/WeChatSendMessageHandler.java index e912176a..3260a4f1 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/WeChatSendMessageHandler.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/notify/platform/WeChatSendMessageHandler.java @@ -124,6 +124,8 @@ public class WeChatSendMessageHandler implements SendMessageHandler %s", originalCapacity, (afterExecutor.getQueue().remainingCapacity() + afterExecutor.getQueue().size())), String.format("%s => %s", originalKeepAliveTime, afterExecutor.getKeepAliveTime(TimeUnit.SECONDS)), + String.format("%s => %s", originalExecuteTimeOut, originalExecuteTimeOut), String.format("%s => %s", originalRejected, RejectedTypeEnum.getRejectedNameByType(parameter.getRejectedType())), String.format("%s => %s", originalAllowCoreThreadTimeOut, EnableEnum.getBool(parameter.getAllowCoreThreadTimeOut())) );