diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/ThreadPoolAlarmManage.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/ThreadPoolAlarmManage.java index 54956e81..7bd1a6a1 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/ThreadPoolAlarmManage.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/ThreadPoolAlarmManage.java @@ -39,7 +39,12 @@ public class ThreadPoolAlarmManage { if (SEND_MESSAGE_SERVICE == null) { return; } - ThreadPoolAlarm threadPoolAlarm = threadPoolExecutor.getThreadPoolAlarm(); + + /** + * TODO 通知改造 + * https://github.com/acmenlt/dynamic-threadpool/issues/100 + */ + ThreadPoolAlarm threadPoolAlarm = new ThreadPoolAlarm(null, 80, 80); BlockingQueue blockIngQueue = threadPoolExecutor.getQueue(); int queueSize = blockIngQueue.size(); @@ -67,8 +72,11 @@ public class ThreadPoolAlarmManage { int maximumPoolSize = threadPoolExecutor.getMaximumPoolSize(); int divide = CalculateUtil.divide(activeCount, maximumPoolSize); - ThreadPoolAlarm threadPoolAlarm = threadPoolExecutor.getThreadPoolAlarm(); - + /** + * TODO 通知改造 + * https://github.com/acmenlt/dynamic-threadpool/issues/100 + */ + ThreadPoolAlarm threadPoolAlarm = new ThreadPoolAlarm(null, 80, 80); boolean isSend = threadPoolAlarm.getIsAlarm() && divide > threadPoolAlarm.getLivenessAlarm() && isSendMessage(threadPoolExecutor, MessageTypeEnum.LIVENESS); @@ -87,7 +95,11 @@ public class ThreadPoolAlarmManage { return; } - ThreadPoolAlarm threadPoolAlarm = threadPoolExecutor.getThreadPoolAlarm(); + /** + * TODO 通知改造 + * https://github.com/acmenlt/dynamic-threadpool/issues/100 + */ + ThreadPoolAlarm threadPoolAlarm = new ThreadPoolAlarm(null, 80, 80); if (threadPoolAlarm.getIsAlarm() && isSendMessage(threadPoolExecutor, MessageTypeEnum.REJECT)) { SEND_MESSAGE_SERVICE.sendAlarmMessage(MessageTypeEnum.REJECT, threadPoolExecutor); } diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java index 713f4924..fe8d3602 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java @@ -138,7 +138,6 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { .poolThreadSize(ppi.getCoreSize(), ppi.getMaxSize()) .keepAliveTime(ppi.getKeepAliveTime(), TimeUnit.SECONDS) .rejected(RejectedTypeEnum.createPolicy(ppi.getRejectedType())) - .alarmConfig(ppi.getIsAlarm(), ppi.getCapacityAlarm(), ppi.getLivenessAlarm()) .allowCoreThreadTimeOut(EnableEnum.getBool(ppi.getAllowCoreThreadTimeOut())) .build(); diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java index 7a1dc20a..5751e47d 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java @@ -1,7 +1,6 @@ package cn.hippo4j.starter.toolkit.thread; import cn.hippo4j.common.toolkit.Assert; -import cn.hippo4j.starter.alarm.ThreadPoolAlarm; import cn.hippo4j.starter.core.DynamicThreadPoolExecutor; import lombok.Data; import lombok.experimental.Accessors; @@ -121,7 +120,6 @@ public class AbstractBuildThreadPoolTemplate { initParam.getWorkQueue(), initParam.getThreadPoolId(), initParam.getThreadFactory(), - initParam.getThreadPoolAlarm(), initParam.getRejectedExecutionHandler() ); } catch (IllegalArgumentException ex) { @@ -182,11 +180,6 @@ public class AbstractBuildThreadPoolTemplate { */ private String threadPoolId; - /** - * 报警策略 - */ - private ThreadPoolAlarm threadPoolAlarm; - /** * 线程任务装饰器 */ diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java index f06cecb2..039caca4 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ThreadPoolBuilder.java @@ -1,9 +1,7 @@ package cn.hippo4j.starter.toolkit.thread; import cn.hippo4j.common.design.builder.Builder; -import cn.hippo4j.common.enums.EnableEnum; import cn.hippo4j.common.toolkit.Assert; -import cn.hippo4j.starter.alarm.ThreadPoolAlarm; import org.springframework.core.task.TaskDecorator; import java.math.BigDecimal; @@ -88,16 +86,6 @@ public class ThreadPoolBuilder implements Builder { */ private boolean isAlarm = false; - /** - * 容量告警 - */ - private Integer capacityAlarm; - - /** - * 活跃度告警 - */ - private Integer livenessAlarm; - /** * 线程任务装饰器 */ @@ -212,13 +200,6 @@ public class ThreadPoolBuilder implements Builder { return this; } - public ThreadPoolBuilder alarmConfig(int isAlarm, int capacityAlarm, int livenessAlarm) { - this.isAlarm = isAlarm == EnableEnum.YES.getIntCode() ? true : false; - this.capacityAlarm = capacityAlarm; - this.livenessAlarm = livenessAlarm; - return this; - } - public ThreadPoolBuilder taskDecorator(TaskDecorator taskDecorator) { this.taskDecorator = taskDecorator; return this; @@ -320,8 +301,6 @@ public class ThreadPoolBuilder implements Builder { if (builder.isDynamicPool) { String threadPoolId = Optional.ofNullable(builder.threadPoolId).orElse(builder.threadNamePrefix); initParam.setThreadPoolId(threadPoolId); - ThreadPoolAlarm threadPoolAlarm = new ThreadPoolAlarm(builder.isAlarm, builder.livenessAlarm, builder.capacityAlarm); - initParam.setThreadPoolAlarm(threadPoolAlarm); initParam.setWaitForTasksToCompleteOnShutdown(builder.waitForTasksToCompleteOnShutdown); initParam.setAwaitTerminationMillis(builder.awaitTerminationMillis); }