Merge branch 'develop' into develop

pull/450/head
小马哥 2 years ago committed by GitHub
commit 71c8e8a44c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,9 +28,9 @@ import java.util.function.Supplier;
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class Singleton {
private static final ConcurrentHashMap<String, Object> SINGLE_OBJECT_POOL = new ConcurrentHashMap();
/**
* Get a singleton object by key.
*
@ -42,7 +42,8 @@ public final class Singleton {
Object result = SINGLE_OBJECT_POOL.get(key);
return result == null ? null : (T) result;
}
/**
* Get a singleton object by key.
*
@ -60,7 +61,7 @@ public final class Singleton {
}
return result != null ? (T) result : null;
}
/**
* Object into container.
*
@ -69,7 +70,7 @@ public final class Singleton {
public static void put(Object value) {
put(value.getClass().getName(), value);
}
/**
* Object into container.
*

@ -24,7 +24,7 @@ import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
import cn.hippo4j.core.toolkit.IdentifyUtil;
import cn.hippo4j.core.toolkit.TraceContextUtil;
import cn.hippo4j.message.service.HippoSendMessageService;
import cn.hippo4j.message.service.Hippo4jSendMessageService;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import cn.hippo4j.message.request.AlarmNotifyRequest;
@ -51,7 +51,7 @@ import java.util.concurrent.*;
public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner {
@NonNull
private final HippoSendMessageService hippoSendMessageService;
private final Hippo4jSendMessageService hippoSendMessageService;
@Value("${spring.profiles.active:UNKNOWN}")
private String active;

@ -22,8 +22,8 @@ import cn.hippo4j.message.platform.DingSendMessageHandler;
import cn.hippo4j.message.platform.LarkSendMessageHandler;
import cn.hippo4j.message.platform.WeChatSendMessageHandler;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.HippoBaseSendMessageService;
import cn.hippo4j.message.service.HippoSendMessageService;
import cn.hippo4j.message.service.Hippo4jBaseSendMessageService;
import cn.hippo4j.message.service.Hippo4jSendMessageService;
import cn.hippo4j.message.service.SendMessageHandler;
import org.springframework.context.annotation.Bean;
@ -33,9 +33,9 @@ import org.springframework.context.annotation.Bean;
public class MessageConfiguration {
@Bean
public HippoSendMessageService hippoSendMessageService(NotifyConfigBuilder serverNotifyConfigBuilder,
AlarmControlHandler alarmControlHandler) {
return new HippoBaseSendMessageService(serverNotifyConfigBuilder, alarmControlHandler);
public Hippo4jSendMessageService hippo4jSendMessageService(NotifyConfigBuilder serverNotifyConfigBuilder,
AlarmControlHandler alarmControlHandler) {
return new Hippo4jBaseSendMessageService(serverNotifyConfigBuilder, alarmControlHandler);
}
@Bean

@ -22,29 +22,29 @@ import lombok.Builder;
import lombok.Data;
/**
* Alarm control dto.
* Alarm control DTO.
*/
@Data
@Builder
public class AlarmControlDTO {
/**
* 线 Id
* Thread pool id
*/
private String threadPool;
/**
*
* Push alarm platform
*/
private String platform;
/**
*
* Push Alert Type
*/
private NotifyTypeEnum typeEnum;
/**
* 线
* Build thread pool alarm id
*
* @return
*/

@ -23,7 +23,7 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* Notify config dto.
* Notify config DTO.
*/
@Data
@EqualsAndHashCode

@ -28,12 +28,12 @@ import java.util.List;
public class ThreadPoolNotifyDTO {
/**
* notifyKey
* Notify key
*/
private String notifyKey;
/**
* notifyList
* Notify list
*/
private List<NotifyConfigDTO> notifyList;
}

@ -23,27 +23,27 @@ package cn.hippo4j.message.platform.constant;
public class DingAlarmConstants {
/**
* Url
* DingTalk Robot Url
*/
public static final String DING_ROBOT_SERVER_URL = "https://oapi.dingtalk.com/robot/send?access_token=";
/**
* 线
* Thread Pool Alert Notification Title
*/
public static final String DING_ALARM_TITLE = "动态线程池告警";
/**
* 线
* Thread pool parameter change notification title
*/
public static final String DING_NOTICE_TITLE = "动态线程池通知";
/**
* Trace
* Trace info
*/
public static final String DING_ALARM_TIMOUT_TRACE_REPLACE_TXT = "<font color=#708090 size=2>链路信息:%s</font> \n\n ";
/**
*
* Replace task timeout template
*/
public static final String DING_ALARM_TIMOUT_REPLACE_TXT =
"<font color=#708090 size=2>任务执行时间:%d / ms </font> \n\n " +

@ -23,51 +23,24 @@ package cn.hippo4j.message.platform.constant;
public class LarkAlarmConstants {
/**
* lark bot url
* Lark bot url
*/
public static final String LARK_BOT_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/";
/**
* lark at format. openid
* openid,@
* Lark at format. openid
* When openid is configured, the bot can @person
*/
public static final String LARK_AT_FORMAT_OPENID = "<at id='%s'></at>";
/**
* lark at format. username
* username,@username,@@
* Lark at format. username
* When configuring username, only @username can be displayed in blue font, and it is reminded by @people without @
*/
public static final String LARK_AT_FORMAT_USERNAME = "<at id=''>%s</at>";
/**
* lark openid prefix
* Lark openid prefix
*/
public static final String LARK_OPENID_PREFIX = "ou_";
/**
* Trace
*/
public static final String LARK_ALARM_TIMOUT_TRACE_REPLACE_TXT = ",{\"is_short\":true,\"text\":{\"content\":\"** 链路信息:** %s\",\"tag\":\"lark_md\"}}";
/**
*
*/
public static final String LARK_ALARM_TIMOUT_REPLACE_TXT =
"{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 任务执行时间:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 超时时间:** %s\",\"tag\":\"lark_md\"}}" +
LARK_ALARM_TIMOUT_TRACE_REPLACE_TXT +
"],\"tag\":\"div\"},{\"tag\":\"hr\"},";
/**
* lark alarm json str
*/
public static final String LARK_ALARM_JSON_STR =
"{\"msg_type\":\"interactive\",\"card\":{\"config\":{\"wide_screen_mode\":true},\"header\":{\"template\":\"red\",\"title\":{\"content\":\"[\uD83D\uDD25警报] %s 动态线程池运行告警(%s\",\"tag\":\"plain_text\"}},\"elements\":[{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 线程池ID** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 应用名称:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 应用实例:** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 核心线程数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 最大线程数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 当前线程数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 活跃线程数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 同存最大线程数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 线程池任务总量:** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 队列类型:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 队列容量:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 队列元素个数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 队列剩余个数:** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},"
+ LARK_ALARM_TIMOUT_REPLACE_TXT
+ "{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 拒绝策略:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 拒绝策略执行次数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** OWNER** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 播报时间: ** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},{\"tag\":\"note\",\"elements\":[{\"tag\":\"plain_text\",\"content\":\"提示: %s 分钟内此线程池不会重复告警(可配置)\"}]}]}}";
/**
* lark notice json str
*/
public static final String LARK_NOTICE_JSON_STR =
"{\"msg_type\":\"interactive\",\"card\":{\"config\":{\"wide_screen_mode\":true},\"header\":{\"template\":\"greed\",\"title\":{\"content\":\"[通知] %s 动态线程池参数变更\",\"tag\":\"plain_text\"}},\"elements\":[{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 线程池ID** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 应用名称:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 应用实例:** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 核心线程数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 最大线程数:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 核心线程超时:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 线程存活时间:** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** 队列类型:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 队列容量:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 执行超时时间:** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},{\"fields\":[{\"is_short\":true,\"text\":{\"content\":\"** AGO 拒绝策略:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** NOW 拒绝策略:** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** OWNER** %s\",\"tag\":\"lark_md\"}},{\"is_short\":true,\"text\":{\"content\":\"** 播报时间: ** %s\",\"tag\":\"lark_md\"}}],\"tag\":\"div\"},{\"tag\":\"hr\"},{\"tag\":\"note\",\"elements\":[{\"tag\":\"plain_text\",\"content\":\"提示:动态线程池配置变更实时通知(无限制)\"}]}]}}";
}

@ -23,17 +23,17 @@ package cn.hippo4j.message.platform.constant;
public class WeChatAlarmConstants {
/**
* Url
* Enterprise Micro Robot Url
*/
public static final String WE_CHAT_SERVER_URL = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=";
/**
* Trace
* Trace info
*/
public static final String WE_CHAT_ALARM_TIMOUT_TRACE_REPLACE_TXT = "\n> 链路信息:%s ";
/**
*
* Replace task timeout template
*/
public static final String WE_CHAT_ALARM_TIMOUT_REPLACE_TXT =
"\n> 任务执行时间:%s / ms \n" +

@ -30,102 +30,102 @@ import lombok.experimental.Accessors;
public class AlarmNotifyRequest extends BaseNotifyRequest {
/**
* interval
* Interval
*/
private Integer interval;
/**
* notifyTypeEnum
* Notify type enum
*/
private NotifyTypeEnum notifyTypeEnum;
/**
* active
* Active
*/
private String active;
/**
* appName
* App name
*/
private String appName;
/**
* identify
* Identify
*/
private String identify;
/**
* corePoolSize
* Core pool size
*/
private Integer corePoolSize;
/**
* maximumPoolSize
* Maximum pool size
*/
private Integer maximumPoolSize;
/**
* poolSize
* Pool size
*/
private Integer poolSize;
/**
* activeCount
* Active count
*/
private Integer activeCount;
/**
* largestPoolSize
* Largest pool size
*/
private Integer largestPoolSize;
/**
* completedTaskCount
* Completed task count
*/
private Long completedTaskCount;
/**
* queueName
* Queue name
*/
private String queueName;
/**
* capacity
* Capacity
*/
private Integer capacity;
/**
* queueSize
* Queue size
*/
private Integer queueSize;
/**
* remainingCapacity
* Remaining capacity
*/
private Integer remainingCapacity;
/**
* rejectedExecutionHandlerName
* Rejected execution handler name
*/
private String rejectedExecutionHandlerName;
/**
* rejectCountNum
* Reject count num
*/
private Long rejectCountNum;
/**
* executeTime
* Execute time
*/
private Long executeTime;
/**
* executeTimeOut
* Execute timeout
*/
private Long executeTimeOut;
/**
* executeTimeoutTrace
* Execute timeout trace
*/
private String executeTimeoutTrace;
}

@ -26,7 +26,7 @@ import lombok.Data;
public class RobotAlarmNotifyRequest extends AlarmNotifyRequest {
/**
* secretKey
* Secret key
*/
private String secretKey;
}

@ -26,7 +26,7 @@ import lombok.Data;
public class RobotChangeParameterNotifyRequest extends ChangeParameterNotifyRequest {
/**
* secretKey
* Secret key
*/
private String secretKey;
}

@ -30,7 +30,7 @@ import java.util.List;
public class ThreadPoolNotifyRequest {
/**
* groupKeys
* Group keys
*/
private List<String> groupKeys;
}

@ -26,32 +26,32 @@ import lombok.Data;
public class BaseNotifyRequest implements NotifyRequest {
/**
* tenantId
* Tenant id
*/
private String tenantId;
/**
* itemId
* Item id
*/
private String itemId;
/**
* threadPoolId
* Thread pool id
*/
private String threadPoolId;
/**
* platform
* Platform
*/
private String platform;
/**
* type
* Type
*/
private String type;
/**
* receives
* Receives
*/
private String receives;
}

@ -36,11 +36,11 @@ import java.util.List;
import java.util.Map;
/**
* Hippo base send message service.
* Hippo-4j base send message service.
*/
@Slf4j
@RequiredArgsConstructor
public class HippoBaseSendMessageService implements HippoSendMessageService, CommandLineRunner {
public class Hippo4jBaseSendMessageService implements Hippo4jSendMessageService, CommandLineRunner {
private final NotifyConfigBuilder notifyConfigBuilder;

@ -22,12 +22,12 @@ import cn.hippo4j.message.request.AlarmNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
/**
* Hippo4j send message service.
* Hippo-4j send message service.
*/
public interface HippoSendMessageService {
public interface Hippo4jSendMessageService {
/**
* Send alarm message.
* Send dynamic thread pool alert notifications.
*
* @param typeEnum
* @param alarmNotifyRequest
@ -35,7 +35,7 @@ public interface HippoSendMessageService {
void sendAlarmMessage(NotifyTypeEnum typeEnum, AlarmNotifyRequest alarmNotifyRequest);
/**
* Send change message.
* Send dynamic thread pool parameter change notification.
*
* @param changeParameterNotifyRequest
*/

@ -63,9 +63,7 @@ public class ThreadPoolNotifyAlarm {
/**
* Receives
*
* <p>
* Do not enable this configuration for the time being, it may be useful if you develop mailboxes in the future.
* </p>
* <p> Do not enable this configuration for the time being, it may be useful if you develop mailboxes in the future.
*/
@Deprecated
private Map<String, String> receives;

@ -33,8 +33,8 @@ import cn.hippo4j.core.springboot.starter.support.ThreadPoolAdapterRegister;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.config.MessageConfiguration;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.HippoBaseSendMessageService;
import cn.hippo4j.message.service.HippoSendMessageService;
import cn.hippo4j.message.service.Hippo4jBaseSendMessageService;
import cn.hippo4j.message.service.Hippo4jSendMessageService;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -78,7 +78,7 @@ public class DynamicThreadPoolCoreAutoConfiguration {
}
@Bean
public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(HippoSendMessageService hippoSendMessageService) {
public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(Hippo4jSendMessageService hippoSendMessageService) {
return new ThreadPoolNotifyAlarmHandler(hippoSendMessageService);
}
@ -96,7 +96,7 @@ public class DynamicThreadPoolCoreAutoConfiguration {
@SuppressWarnings("all")
public ExecutorsListener hippo4jExecutorsListener(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler,
CoreNotifyConfigBuilder coreNotifyConfigBuilder,
HippoBaseSendMessageService hippoBaseSendMessageService) {
Hippo4jBaseSendMessageService hippoBaseSendMessageService) {
return new ExecutorsListener(threadPoolNotifyAlarmHandler, coreNotifyConfigBuilder, hippoBaseSendMessageService);
}

@ -33,7 +33,7 @@ import cn.hippo4j.core.springboot.starter.notify.CoreNotifyConfigBuilder;
import cn.hippo4j.core.springboot.starter.support.GlobalCoreThreadPoolManage;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hippo4j.message.service.HippoBaseSendMessageService;
import cn.hippo4j.message.service.Hippo4jBaseSendMessageService;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
@ -65,7 +65,7 @@ public class ExecutorsListener implements ApplicationListener<Hippo4jCoreDynamic
private final CoreNotifyConfigBuilder coreNotifyConfigBuilder;
private final HippoBaseSendMessageService hippoBaseSendMessageService;
private final Hippo4jBaseSendMessageService hippo4jBaseSendMessageService;
@Override
public void onApplicationEvent(Hippo4jCoreDynamicRefreshEvent threadPoolDynamicRefreshEvent) {
@ -141,7 +141,7 @@ public class ExecutorsListener implements ApplicationListener<Hippo4jCoreDynamic
boolean checkNotifyAlarm = false;
List<String> changeKeys = Lists.newArrayList();
Map<String, List<NotifyConfigDTO>> newDynamicThreadPoolNotifyMap = coreNotifyConfigBuilder.buildSingleNotifyConfig(properties);
Map<String, List<NotifyConfigDTO>> notifyConfigs = hippoBaseSendMessageService.getNotifyConfigs();
Map<String, List<NotifyConfigDTO>> notifyConfigs = hippo4jBaseSendMessageService.getNotifyConfigs();
if (CollectionUtil.isNotEmpty(notifyConfigs)) {
for (Map.Entry<String, List<NotifyConfigDTO>> each : newDynamicThreadPoolNotifyMap.entrySet()) {
if (checkNotifyConfig) {
@ -159,7 +159,7 @@ public class ExecutorsListener implements ApplicationListener<Hippo4jCoreDynamic
}
if (checkNotifyConfig) {
coreNotifyConfigBuilder.initCacheAndLock(newDynamicThreadPoolNotifyMap);
hippoBaseSendMessageService.putPlatform(newDynamicThreadPoolNotifyMap);
hippo4jBaseSendMessageService.putPlatform(newDynamicThreadPoolNotifyMap);
}
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(properties.getThreadPoolId());
if (threadPoolNotifyAlarm != null && properties.getNotify() != null) {

@ -24,7 +24,7 @@ import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.notify.CoreNotifyConfigBuilder;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.service.HippoBaseSendMessageService;
import cn.hippo4j.message.service.Hippo4jBaseSendMessageService;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
@ -47,7 +47,7 @@ public class PlatformsListener implements ApplicationListener<Hippo4jCoreDynamic
String threadPoolId = executor.getThreadPoolId();
DynamicThreadPoolWrapper wrapper = GlobalThreadPoolManage.getExecutorService(threadPoolId);
if (wrapper != null && !wrapper.isInitFlag()) {
HippoBaseSendMessageService sendMessageService = ApplicationContextHolder.getBean(HippoBaseSendMessageService.class);
Hippo4jBaseSendMessageService sendMessageService = ApplicationContextHolder.getBean(Hippo4jBaseSendMessageService.class);
CoreNotifyConfigBuilder configBuilder = ApplicationContextHolder.getBean(CoreNotifyConfigBuilder.class);
Map<String, List<NotifyConfigDTO>> notifyConfig = configBuilder.buildSingleNotifyConfig(executor);
sendMessageService.putPlatform(notifyConfig);

@ -31,7 +31,7 @@ import cn.hippo4j.core.toolkit.inet.InetUtils;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.config.MessageConfiguration;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.HippoSendMessageService;
import cn.hippo4j.message.service.Hippo4jSendMessageService;
import cn.hippo4j.springboot.starter.controller.ThreadPoolAdapterController;
import cn.hippo4j.springboot.starter.controller.WebThreadPoolController;
import cn.hippo4j.springboot.starter.controller.WebThreadPoolRunStateController;
@ -187,7 +187,7 @@ public class DynamicThreadPoolAutoConfiguration {
}
@Bean
public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(HippoSendMessageService hippoSendMessageService) {
public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(Hippo4jSendMessageService hippoSendMessageService) {
return new ThreadPoolNotifyAlarmHandler(hippoSendMessageService);
}
}

Loading…
Cancel
Save