mirror of https://github.com/longtai-cn/hippo4j
parent
0f3287403d
commit
227f8893e0
@ -0,0 +1,24 @@
|
|||||||
|
package cn.hippo4j.common.notify;
|
||||||
|
|
||||||
|
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
|
||||||
|
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base send message service impl.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 21:32
|
||||||
|
*/
|
||||||
|
public class BaseSendMessageServiceImpl implements SendMessageService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendAlarmMessage(NotifyTypeEnum typeEnum, AlarmNotifyRequest alarmNotifyRequest) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendChangeMessage(ChangeParameterNotifyRequest changeParameterNotifyRequest) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.hippo4j.common.notify;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify type enum.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 19:44
|
||||||
|
*/
|
||||||
|
public enum NotifyTypeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CHANGE
|
||||||
|
*/
|
||||||
|
CHANGE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CAPACITY
|
||||||
|
*/
|
||||||
|
CAPACITY,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ACTIVITY
|
||||||
|
*/
|
||||||
|
ACTIVITY,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* REJECT
|
||||||
|
*/
|
||||||
|
REJECT
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.hippo4j.common.notify;
|
||||||
|
|
||||||
|
import cn.hippo4j.common.notify.request.NotifyRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send message handler.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/8/15 15:44
|
||||||
|
*/
|
||||||
|
public interface SendMessageHandler<T extends NotifyRequest, R extends NotifyRequest> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get type.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send alarm message.
|
||||||
|
*
|
||||||
|
* @param alarmNotifyRequest
|
||||||
|
*/
|
||||||
|
void sendAlarmMessage(T alarmNotifyRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send change message.
|
||||||
|
*
|
||||||
|
* @param changeParameterNotifyRequest
|
||||||
|
*/
|
||||||
|
void sendChangeMessage(R changeParameterNotifyRequest);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package cn.hippo4j.common.notify;
|
||||||
|
|
||||||
|
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
|
||||||
|
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send message service.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 19:56
|
||||||
|
*/
|
||||||
|
public interface SendMessageService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send alarm message.
|
||||||
|
*
|
||||||
|
* @param typeEnum
|
||||||
|
* @param alarmNotifyRequest
|
||||||
|
*/
|
||||||
|
void sendAlarmMessage(NotifyTypeEnum typeEnum, AlarmNotifyRequest alarmNotifyRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send change message.
|
||||||
|
*
|
||||||
|
* @param changeParameterNotifyRequest
|
||||||
|
*/
|
||||||
|
void sendChangeMessage(ChangeParameterNotifyRequest changeParameterNotifyRequest);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,154 @@
|
|||||||
|
package cn.hippo4j.common.notify.platform;
|
||||||
|
|
||||||
|
import cn.hippo4j.common.notify.NotifyPlatformEnum;
|
||||||
|
import cn.hippo4j.common.notify.request.RobotAlarmNotifyRequest;
|
||||||
|
import cn.hippo4j.common.notify.request.RobotChangeParameterNotifyRequest;
|
||||||
|
import cn.hippo4j.common.notify.SendMessageHandler;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.dingtalk.api.DefaultDingTalkClient;
|
||||||
|
import com.dingtalk.api.DingTalkClient;
|
||||||
|
import com.dingtalk.api.request.OapiRobotSendRequest;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.taobao.api.ApiException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.hippo4j.common.notify.platform.DingAlarmConstants.DING_ALARM_TXT;
|
||||||
|
import static cn.hippo4j.common.notify.platform.DingAlarmConstants.DING_NOTICE_TXT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send ding notification message.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/8/15 15:49
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class DingSendMessageHandler implements SendMessageHandler<RobotAlarmNotifyRequest, RobotChangeParameterNotifyRequest> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return NotifyPlatformEnum.DING.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendAlarmMessage(RobotAlarmNotifyRequest alarmNotifyRequest) {
|
||||||
|
String[] receives = alarmNotifyRequest.getReceives().split(",");
|
||||||
|
String afterReceives = Joiner.on(", @").join(receives);
|
||||||
|
|
||||||
|
String text = String.format(
|
||||||
|
DING_ALARM_TXT,
|
||||||
|
// 环境
|
||||||
|
alarmNotifyRequest.getActive(),
|
||||||
|
// 线程池ID
|
||||||
|
alarmNotifyRequest.getThreadPoolId(),
|
||||||
|
// 应用名称
|
||||||
|
alarmNotifyRequest.getAppName(),
|
||||||
|
// 实例信息
|
||||||
|
alarmNotifyRequest.getIdentify(),
|
||||||
|
// 报警类型
|
||||||
|
alarmNotifyRequest.getNotifyTypeEnum(),
|
||||||
|
// 核心线程数
|
||||||
|
alarmNotifyRequest.getCorePoolSize(),
|
||||||
|
// 最大线程数
|
||||||
|
alarmNotifyRequest.getMaximumPoolSize(),
|
||||||
|
// 当前线程数
|
||||||
|
alarmNotifyRequest.getPoolSize(),
|
||||||
|
// 活跃线程数
|
||||||
|
alarmNotifyRequest.getActiveCount(),
|
||||||
|
// 最大任务数
|
||||||
|
alarmNotifyRequest.getLargestPoolSize(),
|
||||||
|
// 线程池任务总量
|
||||||
|
alarmNotifyRequest.getCompletedTaskCount(),
|
||||||
|
// 队列类型名称
|
||||||
|
alarmNotifyRequest.getClass().getSimpleName(),
|
||||||
|
// 队列容量
|
||||||
|
alarmNotifyRequest.getCapacity(),
|
||||||
|
// 队列元素个数
|
||||||
|
alarmNotifyRequest.getQueueSize(),
|
||||||
|
// 队列剩余个数
|
||||||
|
alarmNotifyRequest.getRemainingCapacity(),
|
||||||
|
// 拒绝策略名称
|
||||||
|
alarmNotifyRequest.getRejectedExecutionHandlerName(),
|
||||||
|
// 拒绝策略次数
|
||||||
|
alarmNotifyRequest.getRejectCountNum(),
|
||||||
|
// 告警手机号
|
||||||
|
afterReceives,
|
||||||
|
// 报警频率
|
||||||
|
alarmNotifyRequest.getInterval(),
|
||||||
|
// 当前时间
|
||||||
|
DateUtil.now()
|
||||||
|
);
|
||||||
|
|
||||||
|
execute(alarmNotifyRequest.getSecretKey(), DingAlarmConstants.DING_ALARM_TITLE, text, Lists.newArrayList(receives));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendChangeMessage(RobotChangeParameterNotifyRequest changeParameterNotifyRequest) {
|
||||||
|
String threadPoolId = changeParameterNotifyRequest.getThreadPoolId();
|
||||||
|
|
||||||
|
String[] receives = changeParameterNotifyRequest.getReceives().split(",");
|
||||||
|
String afterReceives = Joiner.on(", @").join(receives);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hesitant e.g. ➲ ➜ ⇨ ➪
|
||||||
|
*/
|
||||||
|
String text = String.format(
|
||||||
|
DING_NOTICE_TXT,
|
||||||
|
// 环境
|
||||||
|
changeParameterNotifyRequest.getActive(),
|
||||||
|
// 线程池名称
|
||||||
|
threadPoolId,
|
||||||
|
// 应用名称
|
||||||
|
changeParameterNotifyRequest.getAppName(),
|
||||||
|
// 实例信息
|
||||||
|
changeParameterNotifyRequest.getIdentify(),
|
||||||
|
// 核心线程数
|
||||||
|
changeParameterNotifyRequest.getBeforeCorePoolSize() + " ➲ " + changeParameterNotifyRequest.getNowCorePoolSize(),
|
||||||
|
// 最大线程数
|
||||||
|
changeParameterNotifyRequest.getBeforeMaximumPoolSize() + " ➲ " + changeParameterNotifyRequest.getNowMaximumPoolSize(),
|
||||||
|
// 核心线程超时
|
||||||
|
changeParameterNotifyRequest.getBeforeAllowsCoreThreadTimeOut() + " ➲ " + changeParameterNotifyRequest.getNowAllowsCoreThreadTimeOut(),
|
||||||
|
// 线程存活时间
|
||||||
|
changeParameterNotifyRequest.getBeforeKeepAliveTime() + " ➲ " + changeParameterNotifyRequest.getNowAllowsCoreThreadTimeOut(),
|
||||||
|
// 阻塞队列
|
||||||
|
changeParameterNotifyRequest.getBlockingQueueName(),
|
||||||
|
// 阻塞队列容量
|
||||||
|
changeParameterNotifyRequest.getBeforeQueueCapacity() + " ➲ " + changeParameterNotifyRequest.getNowQueueCapacity(),
|
||||||
|
// 拒绝策略
|
||||||
|
changeParameterNotifyRequest.getBeforeRejectedName(),
|
||||||
|
changeParameterNotifyRequest.getNowRejectedName(),
|
||||||
|
// 告警手机号
|
||||||
|
afterReceives,
|
||||||
|
// 当前时间
|
||||||
|
DateUtil.now()
|
||||||
|
);
|
||||||
|
|
||||||
|
execute(changeParameterNotifyRequest.getSecretKey(), DingAlarmConstants.DING_NOTICE_TITLE, text, Lists.newArrayList(receives));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void execute(String secretKey, String title, String text, List<String> mobiles) {
|
||||||
|
String serverUrl = DingAlarmConstants.DING_ROBOT_SERVER_URL + secretKey;
|
||||||
|
DingTalkClient dingTalkClient = new DefaultDingTalkClient(serverUrl);
|
||||||
|
OapiRobotSendRequest request = new OapiRobotSendRequest();
|
||||||
|
request.setMsgtype("markdown");
|
||||||
|
|
||||||
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
|
||||||
|
markdown.setTitle(title);
|
||||||
|
markdown.setText(text);
|
||||||
|
|
||||||
|
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
||||||
|
at.setAtMobiles(mobiles);
|
||||||
|
|
||||||
|
request.setAt(at);
|
||||||
|
request.setMarkdown(markdown);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dingTalkClient.execute(request);
|
||||||
|
} catch (ApiException ex) {
|
||||||
|
log.error("Ding failed to send message", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cn.hippo4j.common.notify.platform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lark alarm constants.
|
||||||
|
*
|
||||||
|
* @author imyzt
|
||||||
|
* @date 2021-11-23 19:29
|
||||||
|
*/
|
||||||
|
public class LarkAlarmConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lark bot url
|
||||||
|
*/
|
||||||
|
public static final String LARK_BOT_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lark 报警 json文件路径
|
||||||
|
*/
|
||||||
|
public static final String ALARM_JSON_PATH = "classpath:properties/lark/alarm.json";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lark 配置变更通知 json文件路径
|
||||||
|
*/
|
||||||
|
public static final String NOTICE_JSON_PATH = "classpath:properties/lark/notice.json";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lark at format. openid
|
||||||
|
* 当配置openid时,机器人可以@人
|
||||||
|
*/
|
||||||
|
public static final String LARK_AT_FORMAT_OPENID = "<at id='%s'></at>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lark at format. username
|
||||||
|
* 当配置username时,只能蓝色字体展示@username,被@人无@提醒
|
||||||
|
*/
|
||||||
|
public static final String LARK_AT_FORMAT_USERNAME = "<at id=''>%s</at>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lark openid prefix
|
||||||
|
*/
|
||||||
|
public static final String LARK_OPENID_PREFIX = "ou_";
|
||||||
|
}
|
@ -0,0 +1,172 @@
|
|||||||
|
package cn.hippo4j.common.notify.platform;
|
||||||
|
|
||||||
|
import cn.hippo4j.common.notify.NotifyPlatformEnum;
|
||||||
|
import cn.hippo4j.common.notify.SendMessageHandler;
|
||||||
|
import cn.hippo4j.common.notify.request.RobotAlarmNotifyRequest;
|
||||||
|
import cn.hippo4j.common.notify.request.RobotChangeParameterNotifyRequest;
|
||||||
|
import cn.hippo4j.common.toolkit.JSONUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import static cn.hippo4j.common.notify.platform.WeChatAlarmConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WeChat send message handler.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/11/26 20:06
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class WeChatSendMessageHandler implements SendMessageHandler<RobotAlarmNotifyRequest, RobotChangeParameterNotifyRequest> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return NotifyPlatformEnum.WECHAT.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendAlarmMessage(RobotAlarmNotifyRequest alarmNotifyRequest) {
|
||||||
|
String[] receives = alarmNotifyRequest.getReceives().split(",");
|
||||||
|
String afterReceives = Joiner.on(", @").join(receives);
|
||||||
|
|
||||||
|
String text = String.format(
|
||||||
|
WE_CHAT_ALARM_TXT,
|
||||||
|
// 环境
|
||||||
|
alarmNotifyRequest.getActive(),
|
||||||
|
// 线程池ID
|
||||||
|
alarmNotifyRequest.getThreadPoolId(),
|
||||||
|
// 应用名称
|
||||||
|
alarmNotifyRequest.getAppName(),
|
||||||
|
// 实例信息
|
||||||
|
alarmNotifyRequest.getIdentify(),
|
||||||
|
// 报警类型
|
||||||
|
alarmNotifyRequest.getNotifyTypeEnum(),
|
||||||
|
// 核心线程数
|
||||||
|
alarmNotifyRequest.getCorePoolSize(),
|
||||||
|
// 最大线程数
|
||||||
|
alarmNotifyRequest.getMaximumPoolSize(),
|
||||||
|
// 当前线程数
|
||||||
|
alarmNotifyRequest.getPoolSize(),
|
||||||
|
// 活跃线程数
|
||||||
|
alarmNotifyRequest.getActiveCount(),
|
||||||
|
// 最大任务数
|
||||||
|
alarmNotifyRequest.getLargestPoolSize(),
|
||||||
|
// 线程池任务总量
|
||||||
|
alarmNotifyRequest.getCompletedTaskCount(),
|
||||||
|
// 队列类型名称
|
||||||
|
alarmNotifyRequest.getClass().getSimpleName(),
|
||||||
|
// 队列容量
|
||||||
|
alarmNotifyRequest.getCapacity(),
|
||||||
|
// 队列元素个数
|
||||||
|
alarmNotifyRequest.getQueueSize(),
|
||||||
|
// 队列剩余个数
|
||||||
|
alarmNotifyRequest.getRemainingCapacity(),
|
||||||
|
// 拒绝策略名称
|
||||||
|
alarmNotifyRequest.getRejectedExecutionHandlerName(),
|
||||||
|
// 拒绝策略次数
|
||||||
|
alarmNotifyRequest.getRejectCountNum(),
|
||||||
|
// 告警手机号
|
||||||
|
afterReceives,
|
||||||
|
// 报警频率
|
||||||
|
alarmNotifyRequest.getInterval(),
|
||||||
|
// 当前时间
|
||||||
|
DateUtil.now()
|
||||||
|
);
|
||||||
|
execute(alarmNotifyRequest.getSecretKey(), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendChangeMessage(RobotChangeParameterNotifyRequest changeParameterNotifyRequest) {
|
||||||
|
String threadPoolId = changeParameterNotifyRequest.getThreadPoolId();
|
||||||
|
|
||||||
|
String[] receives = changeParameterNotifyRequest.getReceives().split(",");
|
||||||
|
String afterReceives = Joiner.on("><@").join(receives);
|
||||||
|
|
||||||
|
String text = String.format(
|
||||||
|
WE_CHAT_NOTICE_TXT,
|
||||||
|
// 环境
|
||||||
|
changeParameterNotifyRequest.getActive(),
|
||||||
|
// 线程池名称
|
||||||
|
threadPoolId,
|
||||||
|
// 应用名称
|
||||||
|
changeParameterNotifyRequest.getAppName(),
|
||||||
|
// 实例信息
|
||||||
|
changeParameterNotifyRequest.getIdentify(),
|
||||||
|
// 核心线程数
|
||||||
|
changeParameterNotifyRequest.getBeforeCorePoolSize() + " ➲ " + changeParameterNotifyRequest.getNowCorePoolSize(),
|
||||||
|
// 最大线程数
|
||||||
|
changeParameterNotifyRequest.getBeforeMaximumPoolSize() + " ➲ " + changeParameterNotifyRequest.getNowMaximumPoolSize(),
|
||||||
|
// 核心线程超时
|
||||||
|
changeParameterNotifyRequest.getBeforeAllowsCoreThreadTimeOut() + " ➲ " + changeParameterNotifyRequest.getNowAllowsCoreThreadTimeOut(),
|
||||||
|
// 线程存活时间
|
||||||
|
changeParameterNotifyRequest.getBeforeKeepAliveTime() + " ➲ " + changeParameterNotifyRequest.getNowAllowsCoreThreadTimeOut(),
|
||||||
|
// 阻塞队列
|
||||||
|
changeParameterNotifyRequest.getBlockingQueueName(),
|
||||||
|
// 阻塞队列容量
|
||||||
|
changeParameterNotifyRequest.getBeforeQueueCapacity() + " ➲ " + changeParameterNotifyRequest.getNowQueueCapacity(),
|
||||||
|
// 拒绝策略
|
||||||
|
changeParameterNotifyRequest.getBeforeRejectedName(),
|
||||||
|
changeParameterNotifyRequest.getNowRejectedName(),
|
||||||
|
// 告警手机号
|
||||||
|
afterReceives,
|
||||||
|
// 当前时间
|
||||||
|
DateUtil.now()
|
||||||
|
);
|
||||||
|
|
||||||
|
execute(changeParameterNotifyRequest.getSecretKey(), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute.
|
||||||
|
*
|
||||||
|
* @param secretKey
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
|
private void execute(String secretKey, String text) {
|
||||||
|
String serverUrl = WE_CHAT_SERVER_URL + secretKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
WeChatReqDTO weChatReq = new WeChatReqDTO();
|
||||||
|
weChatReq.setMsgtype("markdown");
|
||||||
|
|
||||||
|
Markdown markdown = new Markdown();
|
||||||
|
markdown.setContent(text);
|
||||||
|
weChatReq.setMarkdown(markdown);
|
||||||
|
|
||||||
|
HttpRequest.post(serverUrl).body(JSONUtil.toJSONString(weChatReq)).execute();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("WeChat failed to send message", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public static class WeChatReqDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* msgType
|
||||||
|
*/
|
||||||
|
private String msgtype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* markdown
|
||||||
|
*/
|
||||||
|
private Markdown markdown;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Markdown {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* content
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.hippo4j.common.notify.request;
|
||||||
|
|
||||||
|
import cn.hippo4j.common.notify.NotifyTypeEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alarm notify request.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 19:41
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AlarmNotifyRequest extends BaseNotifyRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* interval
|
||||||
|
*/
|
||||||
|
private Integer interval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* notifyTypeEnum
|
||||||
|
*/
|
||||||
|
private NotifyTypeEnum notifyTypeEnum;
|
||||||
|
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
private String identify;
|
||||||
|
|
||||||
|
private Integer corePoolSize;
|
||||||
|
|
||||||
|
private Integer maximumPoolSize;
|
||||||
|
|
||||||
|
private Integer poolSize;
|
||||||
|
|
||||||
|
private Integer activeCount;
|
||||||
|
|
||||||
|
private Integer largestPoolSize;
|
||||||
|
|
||||||
|
private Long completedTaskCount;
|
||||||
|
|
||||||
|
private String queueName;
|
||||||
|
|
||||||
|
private Integer capacity;
|
||||||
|
|
||||||
|
private Integer queueSize;
|
||||||
|
|
||||||
|
private Integer remainingCapacity;
|
||||||
|
|
||||||
|
private String rejectedExecutionHandlerName;
|
||||||
|
|
||||||
|
private Long rejectCountNum;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package cn.hippo4j.common.notify.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base notify request.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 19:35
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BaseNotifyRequest implements NotifyRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tenantId
|
||||||
|
*/
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* itemId
|
||||||
|
*/
|
||||||
|
private String itemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* threadPoolId
|
||||||
|
*/
|
||||||
|
private String threadPoolId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* platform
|
||||||
|
*/
|
||||||
|
private String platform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* type
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* receives
|
||||||
|
*/
|
||||||
|
private String receives;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package cn.hippo4j.common.notify.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change parameter notify request.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 20:22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ChangeParameterNotifyRequest extends BaseNotifyRequest {
|
||||||
|
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
private String identify;
|
||||||
|
|
||||||
|
private Integer beforeCorePoolSize;
|
||||||
|
|
||||||
|
private Integer nowCorePoolSize;
|
||||||
|
|
||||||
|
private Integer beforeMaximumPoolSize;
|
||||||
|
|
||||||
|
private Integer nowMaximumPoolSize;
|
||||||
|
|
||||||
|
private Boolean beforeAllowsCoreThreadTimeOut;
|
||||||
|
|
||||||
|
private Boolean nowAllowsCoreThreadTimeOut;
|
||||||
|
|
||||||
|
private Long beforeKeepAliveTime;
|
||||||
|
|
||||||
|
private Long nowKeepAliveTime;
|
||||||
|
|
||||||
|
private String blockingQueueName;
|
||||||
|
|
||||||
|
private Integer beforeQueueCapacity;
|
||||||
|
|
||||||
|
private Integer nowQueueCapacity;
|
||||||
|
|
||||||
|
private String beforeRejectedName;
|
||||||
|
|
||||||
|
private String nowRejectedName;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package cn.hippo4j.common.notify.request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify request.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 19:38
|
||||||
|
*/
|
||||||
|
public interface NotifyRequest {
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package cn.hippo4j.common.notify.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Robot alarm notify request.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 21:50
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RobotAlarmNotifyRequest extends AlarmNotifyRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* secretKey
|
||||||
|
*/
|
||||||
|
private String secretKey;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package cn.hippo4j.common.notify.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Robot change parameter notify request.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2022/2/22 21:03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RobotChangeParameterNotifyRequest extends ChangeParameterNotifyRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* secretKey
|
||||||
|
*/
|
||||||
|
private String secretKey;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package cn.hippo4j.common.toolkit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread util.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/12/6 23:34
|
||||||
|
*/
|
||||||
|
public class ThreadUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建新线程.
|
||||||
|
*
|
||||||
|
* @param runnable {@link Runnable}
|
||||||
|
* @param name 线程名
|
||||||
|
* @param isDaemon 是否守护线程
|
||||||
|
* @return {@link Thread}
|
||||||
|
*/
|
||||||
|
public static Thread newThread(Runnable runnable, String name, boolean isDaemon) {
|
||||||
|
Thread t = new Thread(null, runnable, name);
|
||||||
|
t.setDaemon(isDaemon);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂起当前线程.
|
||||||
|
*
|
||||||
|
* @param millis 毫秒
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean sleep(long millis) {
|
||||||
|
if (millis > 0) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(millis);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue