style:hippo4j-message CheckStyle (#926)

pull/933/head
WuLang 2 years ago committed by GitHub
parent 8e2c30d8b3
commit 518e9fb45e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,4 +27,5 @@
<suppress checks="MagicNumber" files="ByteConvertUtil.java"/>
<suppress checks="MagicNumber" files="DubboThreadPoolAdapter.java"/>
<suppress checks="MagicNumber" files="UndertowWebThreadPoolHandler.java"/>
<suppress checks="MagicNumber" files="DefaultThreadPoolCheckAlarmHandler.java"/>
</suppressions>

@ -18,7 +18,9 @@
package cn.hippo4j.message.dto;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
/**
* Alarm control DTO.

@ -70,6 +70,9 @@ public class WeChatSendMessageHandler extends AbstractRobotSendMessageHandler {
}
}
/**
* WeChat
*/
@Data
@Accessors(chain = true)
public static class WeChatReqDTO {
@ -79,6 +82,9 @@ public class WeChatSendMessageHandler extends AbstractRobotSendMessageHandler {
private Markdown markdown;
}
/**
* Markdown
*/
@Data
public static class Markdown {

@ -46,8 +46,8 @@ public class DingAlarmConstants {
* Replace task timeout template
*/
public static final String DING_ALARM_TIMEOUT_REPLACE_TXT =
"<font color=#708090 size=2>任务执行时间:%d / ms </font> \n\n " +
"<font color=#708090 size=2>超时时间:%d / ms</font> \n\n " +
DING_ALARM_TIMEOUT_TRACE_REPLACE_TXT +
" --- \n\n ";
"<font color=#708090 size=2>任务执行时间:%d / ms </font> \n\n "
+ "<font color=#708090 size=2>超时时间:%d / ms</font> \n\n "
+ DING_ALARM_TIMEOUT_TRACE_REPLACE_TXT
+ " --- \n\n ";
}

@ -36,7 +36,7 @@ public class WeChatAlarmConstants {
* Replace task timeout template
*/
public static final String WE_CHAT_ALARM_TIMOUT_REPLACE_TXT =
"\n> 任务执行时间:%s / ms \n" +
"> 超时时间:%s / ms " +
WE_CHAT_ALARM_TIMOUT_TRACE_REPLACE_TXT;
"\n> 任务执行时间:%s / ms \n"
+ "> 超时时间:%s / ms "
+ WE_CHAT_ALARM_TIMOUT_TRACE_REPLACE_TXT;
}

@ -64,11 +64,11 @@ public class DefaultThreadPoolCheckAlarmHandler implements Runnable, ThreadPoolC
@Value("${spring.dynamic.thread-pool.check-state-interval:5}")
private Integer checkStateInterval;
private final ScheduledExecutorService ALARM_NOTIFY_EXECUTOR = new ScheduledThreadPoolExecutor(
private final ScheduledExecutorService alarmNotifyExecutor = new ScheduledThreadPoolExecutor(
1,
r -> new Thread(r, "client.alarm.notify"));
private final ExecutorService ASYNC_ALARM_NOTIFY_EXECUTOR = ThreadPoolBuilder.builder()
private final ExecutorService asyncAlarmNotifyExecutor = ThreadPoolBuilder.builder()
.poolThreadSize(2, 4)
.threadFactory("client.execute.timeout.alarm")
.allowCoreThreadTimeOut(true)
@ -79,7 +79,7 @@ public class DefaultThreadPoolCheckAlarmHandler implements Runnable, ThreadPoolC
@Override
public void run(String... args) throws Exception {
ALARM_NOTIFY_EXECUTOR.scheduleWithFixedDelay(this, 0, checkStateInterval, TimeUnit.SECONDS);
alarmNotifyExecutor.scheduleWithFixedDelay(this, 0, checkStateInterval, TimeUnit.SECONDS);
}
@Override
@ -162,7 +162,7 @@ public class DefaultThreadPoolCheckAlarmHandler implements Runnable, ThreadPoolC
hippo4jSendMessageService.sendAlarmMessage(NotifyTypeEnum.REJECT, alarmNotifyRequest);
}
};
ASYNC_ALARM_NOTIFY_EXECUTOR.execute(checkPoolRejectedAlarmTask);
asyncAlarmNotifyExecutor.execute(checkPoolRejectedAlarmTask);
}
/**
@ -190,7 +190,7 @@ public class DefaultThreadPoolCheckAlarmHandler implements Runnable, ThreadPoolC
alarmNotifyRequest.setExecuteTimeoutTrace(executeTimeoutTrace);
}
Runnable task = () -> hippo4jSendMessageService.sendAlarmMessage(NotifyTypeEnum.TIMEOUT, alarmNotifyRequest);
ASYNC_ALARM_NOTIFY_EXECUTOR.execute(task);
asyncAlarmNotifyExecutor.execute(task);
} catch (Throwable ex) {
log.error("Send thread pool execution timeout alarm error.", ex);
}

@ -46,7 +46,7 @@ public class Hippo4jBaseSendMessageService implements Hippo4jSendMessageService,
private final AlarmControlHandler alarmControlHandler;
@Getter
public final Map<String, List<NotifyConfigDTO>> notifyConfigs = new HashMap<>();
private final Map<String, List<NotifyConfigDTO>> notifyConfigs = new HashMap<>();
private final Map<String, SendMessageHandler> sendMessageHandlers = new HashMap<>();

Loading…
Cancel
Save