diff --git a/hippo4j-adapter/hippo4j-adapter-alibaba-dubbo/pom.xml b/hippo4j-adapter/hippo4j-adapter-alibaba-dubbo/pom.xml index e2413208..5ffcc442 100644 --- a/hippo4j-adapter/hippo4j-adapter-alibaba-dubbo/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-alibaba-dubbo/pom.xml @@ -9,19 +9,17 @@ hippo4j-adapter-alibaba-dubbo - - 2.6.12 - - cn.hippo4j hippo4j-adapter-base + ${revision} com.alibaba dubbo ${alibaba-dubbo.version} + true diff --git a/hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml b/hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml index 1b975be4..62bd25f2 100644 --- a/hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml @@ -9,14 +9,11 @@ hippo4j-adapter-dubbo - - 3.0.5 - - cn.hippo4j hippo4j-adapter-base + ${revision} org.apache.dubbo diff --git a/hippo4j-adapter/hippo4j-adapter-hystrix/pom.xml b/hippo4j-adapter/hippo4j-adapter-hystrix/pom.xml index 8da68229..128e1ccb 100644 --- a/hippo4j-adapter/hippo4j-adapter-hystrix/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-hystrix/pom.xml @@ -13,11 +13,13 @@ cn.hippo4j hippo4j-adapter-base + ${revision} org.springframework.cloud spring-cloud-starter-netflix-hystrix ${spring-cloud-starter-netflix-hystrix.version} + true diff --git a/hippo4j-adapter/hippo4j-adapter-rabbitmq/pom.xml b/hippo4j-adapter/hippo4j-adapter-rabbitmq/pom.xml index d477e026..2d54fe82 100644 --- a/hippo4j-adapter/hippo4j-adapter-rabbitmq/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-rabbitmq/pom.xml @@ -13,10 +13,12 @@ cn.hippo4j hippo4j-adapter-base + ${revision} org.springframework.boot spring-boot-starter-amqp + true diff --git a/hippo4j-adapter/hippo4j-adapter-rocketmq/pom.xml b/hippo4j-adapter/hippo4j-adapter-rocketmq/pom.xml index 5b9451b3..bf046e13 100644 --- a/hippo4j-adapter/hippo4j-adapter-rocketmq/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-rocketmq/pom.xml @@ -13,11 +13,13 @@ cn.hippo4j hippo4j-adapter-base + ${revision} org.apache.rocketmq rocketmq-spring-boot-starter ${rocketmq.version} + true diff --git a/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rabbitmq/pom.xml b/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rabbitmq/pom.xml index ffce64e8..c0a96526 100644 --- a/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rabbitmq/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rabbitmq/pom.xml @@ -13,11 +13,13 @@ cn.hippo4j hippo4j-adapter-base + ${revision} org.springframework.cloud spring-cloud-starter-stream-rabbit ${spring-cloud-starter-stream-rabbitmq.version} + true diff --git a/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rocketmq/pom.xml b/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rocketmq/pom.xml index 1227e7bf..b8c524fa 100644 --- a/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rocketmq/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-spring-cloud-stream-rocketmq/pom.xml @@ -13,11 +13,13 @@ cn.hippo4j hippo4j-adapter-base + ${revision} com.alibaba.cloud spring-cloud-starter-stream-rocketmq ${spring-cloud-starter-stream-rocketmq.version} + true diff --git a/hippo4j-adapter/hippo4j-adapter-web/pom.xml b/hippo4j-adapter/hippo4j-adapter-web/pom.xml index 8563db72..62ab8998 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/pom.xml +++ b/hippo4j-adapter/hippo4j-adapter-web/pom.xml @@ -31,10 +31,6 @@ spring-boot-starter-undertow true - - org.projectlombok - lombok - org.springframework.boot spring-boot-starter @@ -42,6 +38,7 @@ cn.hippo4j hippo4j-core + ${revision} diff --git a/hippo4j-common/pom.xml b/hippo4j-common/pom.xml index 5f036d55..5f56c500 100644 --- a/hippo4j-common/pom.xml +++ b/hippo4j-common/pom.xml @@ -57,6 +57,7 @@ com.github.ben-manes.caffeine caffeine + ${caffeine.version} com.github.dozermapper diff --git a/hippo4j-message/src/main/java/cn/hippo4j/message/request/base/NotifyRequest.java b/hippo4j-common/src/main/java/cn/hippo4j/common/api/NotifyRequest.java similarity index 95% rename from hippo4j-message/src/main/java/cn/hippo4j/message/request/base/NotifyRequest.java rename to hippo4j-common/src/main/java/cn/hippo4j/common/api/NotifyRequest.java index 13e0da92..9b2b71ee 100644 --- a/hippo4j-message/src/main/java/cn/hippo4j/message/request/base/NotifyRequest.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/api/NotifyRequest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package cn.hippo4j.message.request.base; +package cn.hippo4j.common.api; /** * Notify request. diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/api/ThreadPoolCheckAlarm.java b/hippo4j-common/src/main/java/cn/hippo4j/common/api/ThreadPoolCheckAlarm.java new file mode 100644 index 00000000..6d4b0768 --- /dev/null +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/api/ThreadPoolCheckAlarm.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.hippo4j.common.api; + +import org.springframework.boot.CommandLineRunner; + +import java.util.concurrent.ThreadPoolExecutor; + +/** + * Thread-pol check alarm. + * + *

Dynamic thread pool check and send logic wait for refactoring, + * Try not to rely on this component for custom extensions, because it is undefined. + */ +public interface ThreadPoolCheckAlarm extends CommandLineRunner { + + /** + * Check pool capacity alarm. + * + * @param threadPoolId thread-pool id + * @param threadPoolExecutor thread-pool executor + */ + void checkPoolCapacityAlarm(String threadPoolId, ThreadPoolExecutor threadPoolExecutor); + + /** + * Check pool activity alarm. + * + * @param threadPoolId thread-pool id + * @param threadPoolExecutor thread-pool executor + */ + void checkPoolActivityAlarm(String threadPoolId, ThreadPoolExecutor threadPoolExecutor); + + /** + * Async send rejected alarm. + * + * @param threadPoolId thread-pool id + */ + void asyncSendRejectedAlarm(String threadPoolId); + + /** + * Async send execute time-out alarm. + * + * @param threadPoolId thread-pool id + * @param executeTime execute time + * @param executeTimeOut execute time-out + * @param threadPoolExecutor thread-pool executor + */ + void asyncSendExecuteTimeOutAlarm(String threadPoolId, long executeTime, long executeTimeOut, ThreadPoolExecutor threadPoolExecutor); +} diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/api/ThreadPoolConfigChange.java b/hippo4j-common/src/main/java/cn/hippo4j/common/api/ThreadPoolConfigChange.java new file mode 100644 index 00000000..8086240e --- /dev/null +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/api/ThreadPoolConfigChange.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.hippo4j.common.api; + +/** + * Thread-pool config change. + */ +public interface ThreadPoolConfigChange { + + /** + * Send pool config change. + * + * @param requestParam request param + */ + void sendPoolConfigChange(T requestParam); +} diff --git a/hippo4j-core/pom.xml b/hippo4j-core/pom.xml index e9e05f10..ae43fb91 100644 --- a/hippo4j-core/pom.xml +++ b/hippo4j-core/pom.xml @@ -10,34 +10,15 @@ hippo4j-core - - org.springframework.boot - spring-boot-starter-test - test - - - org.projectlombok - lombok - cn.hippo4j hippo4j-common ${revision} - cn.hippo4j - hippo4j-message - - - com.aliyun - alibaba-dingtalk-service-sdk - - - - log4j - log4j - - + org.springframework.boot + spring-boot-starter-test + test diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskRejectNotifyAlarmPlugin.java b/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskRejectNotifyAlarmPlugin.java index 6b865642..85229374 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskRejectNotifyAlarmPlugin.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskRejectNotifyAlarmPlugin.java @@ -17,9 +17,9 @@ package cn.hippo4j.core.plugin.impl; +import cn.hippo4j.common.api.ThreadPoolCheckAlarm; import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.core.executor.ExtensibleThreadPoolExecutor; -import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; import cn.hippo4j.core.plugin.RejectedAwarePlugin; import java.util.Optional; @@ -55,7 +55,7 @@ public class TaskRejectNotifyAlarmPlugin implements RejectedAwarePlugin { } String threadPoolId = ((ExtensibleThreadPoolExecutor) executor).getThreadPoolId(); Optional.ofNullable(ApplicationContextHolder.getInstance()) - .map(context -> context.getBean(ThreadPoolNotifyAlarmHandler.class)) + .map(context -> context.getBean(ThreadPoolCheckAlarm.class)) .ifPresent(handler -> handler.asyncSendRejectedAlarm(threadPoolId)); } } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskTimeoutNotifyAlarmPlugin.java b/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskTimeoutNotifyAlarmPlugin.java index d828cc6d..bdc6787e 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskTimeoutNotifyAlarmPlugin.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/plugin/impl/TaskTimeoutNotifyAlarmPlugin.java @@ -17,8 +17,8 @@ package cn.hippo4j.core.plugin.impl; +import cn.hippo4j.common.api.ThreadPoolCheckAlarm; import cn.hippo4j.common.config.ApplicationContextHolder; -import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -73,7 +73,7 @@ public class TaskTimeoutNotifyAlarmPlugin extends AbstractTaskTimerPlugin { return; } Optional.ofNullable(ApplicationContextHolder.getInstance()) - .map(context -> context.getBean(ThreadPoolNotifyAlarmHandler.class)) + .map(context -> context.getBean(ThreadPoolCheckAlarm.class)) .ifPresent(handler -> handler.asyncSendExecuteTimeOutAlarm( threadPoolId, taskExecuteTime, executeTimeOut, threadPoolExecutor)); } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/proxy/RejectedProxyInvocationHandler.java b/hippo4j-core/src/main/java/cn/hippo4j/core/proxy/RejectedProxyInvocationHandler.java index 2b029e54..263cbcc3 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/proxy/RejectedProxyInvocationHandler.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/proxy/RejectedProxyInvocationHandler.java @@ -17,8 +17,8 @@ package cn.hippo4j.core.proxy; +import cn.hippo4j.common.api.ThreadPoolCheckAlarm; import cn.hippo4j.common.config.ApplicationContextHolder; -import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -54,7 +54,7 @@ public class RejectedProxyInvocationHandler implements InvocationHandler { rejectCount.incrementAndGet(); if (ApplicationContextHolder.getInstance() != null) { try { - ThreadPoolNotifyAlarmHandler alarmHandler = ApplicationContextHolder.getBean(ThreadPoolNotifyAlarmHandler.class); + ThreadPoolCheckAlarm alarmHandler = ApplicationContextHolder.getBean(ThreadPoolCheckAlarm.class); alarmHandler.asyncSendRejectedAlarm(threadPoolId); } catch (Throwable ex) { log.error("Failed to send rejection policy alert.", ex); diff --git a/hippo4j-example/hippo4j-example-core/pom.xml b/hippo4j-example/hippo4j-example-core/pom.xml index 2628dbd6..86d8c24b 100644 --- a/hippo4j-example/hippo4j-example-core/pom.xml +++ b/hippo4j-example/hippo4j-example-core/pom.xml @@ -11,6 +11,7 @@ true + 2.12.1 @@ -18,36 +19,32 @@ org.springframework.boot spring-boot-starter - org.springframework.boot spring-boot-starter-test test - cn.hippo4j - hippo4j-core + hippo4j-message + ${revision} - com.alibaba transmittable-thread-local + ${transmittable-thread-local.version} - org.openjdk.jmh jmh-core 1.23 test - org.openjdk.jmh jmh-generator-annprocess 1.23 test - diff --git a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java index d081f092..9bc5dc79 100644 --- a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java +++ b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java @@ -17,14 +17,14 @@ package cn.hippo4j.example.core.inittest; +import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum; +import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum; import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterParameter; import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterWrapper; import cn.hippo4j.common.model.register.notify.DynamicThreadPoolRegisterCoreNotifyParameter; import cn.hippo4j.common.model.register.notify.DynamicThreadPoolRegisterServerNotifyParameter; import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; -import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum; -import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum; import cn.hippo4j.message.enums.NotifyPlatformEnum; import lombok.extern.slf4j.Slf4j; diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-rabbitmq-example/pom.xml b/hippo4j-example/hippo4j-spring-boot-starter-adapter-rabbitmq-example/pom.xml index ab8e038d..d94e8b62 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-rabbitmq-example/pom.xml +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-rabbitmq-example/pom.xml @@ -18,40 +18,29 @@ org.springframework.boot spring-boot-starter - org.springframework.boot spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-json - - org.projectlombok lombok - cn.hippo4j hippo4j-spring-boot-starter-adapter-rabbitmq ${project.version} - cn.hippo4j hippo4j-spring-boot-starter ${project.version} - cn.hippo4j hippo4j-example-core ${revision} - org.springframework.boot spring-boot-starter-amqp diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-rocketmq-example/pom.xml b/hippo4j-example/hippo4j-spring-boot-starter-adapter-rocketmq-example/pom.xml index cbabedf9..ba28fe22 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-rocketmq-example/pom.xml +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-rocketmq-example/pom.xml @@ -18,38 +18,33 @@ org.springframework.boot spring-boot-starter - org.springframework.boot spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-json - - org.projectlombok lombok - cn.hippo4j hippo4j-spring-boot-starter-adapter-rocketmq ${project.version} - cn.hippo4j hippo4j-spring-boot-starter ${project.version} - cn.hippo4j hippo4j-example-core ${revision} + + org.apache.rocketmq + rocketmq-spring-boot-starter + ${rocketmq.version} + diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml index 389906cb..17c7ad72 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml @@ -18,39 +18,34 @@ org.springframework.boot spring-boot-starter - org.springframework.boot spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-json - - org.projectlombok lombok - cn.hippo4j hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq ${project.version} - cn.hippo4j hippo4j-spring-boot-starter ${project.version} - cn.hippo4j hippo4j-example-core ${revision} + + org.springframework.cloud + spring-cloud-starter-stream-rabbit + ${spring-cloud-starter-stream-rabbitmq.version} + diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/pom.xml b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/pom.xml index 37faf900..0dc3f119 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/pom.xml +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/pom.xml @@ -19,40 +19,29 @@ org.springframework.boot spring-boot-starter - org.springframework.boot spring-boot-starter-web - com.alibaba.cloud spring-cloud-starter-stream-rocketmq ${spring-cloud-starter-stream-rocketmq.version} - - - org.springframework.boot - spring-boot-starter-json - - org.projectlombok lombok - cn.hippo4j hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq ${project.version} - cn.hippo4j hippo4j-spring-boot-starter ${project.version} - cn.hippo4j hippo4j-example-core diff --git a/hippo4j-message/pom.xml b/hippo4j-message/pom.xml index b32e2992..09fed8e6 100644 --- a/hippo4j-message/pom.xml +++ b/hippo4j-message/pom.xml @@ -12,17 +12,13 @@ cn.hippo4j - hippo4j-common + hippo4j-core ${revision} - - org.projectlombok - lombok - com.aliyun alibaba-dingtalk-service-sdk - true + ${dingtalk-sdk.version} diff --git a/hippo4j-message/src/main/java/cn/hippo4j/message/request/base/BaseNotifyRequest.java b/hippo4j-message/src/main/java/cn/hippo4j/message/request/base/BaseNotifyRequest.java index 5c96e994..5db9a63c 100644 --- a/hippo4j-message/src/main/java/cn/hippo4j/message/request/base/BaseNotifyRequest.java +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/request/base/BaseNotifyRequest.java @@ -17,6 +17,7 @@ package cn.hippo4j.message.request.base; +import cn.hippo4j.common.api.NotifyRequest; import lombok.Data; /** diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java b/hippo4j-message/src/main/java/cn/hippo4j/message/service/DefaultThreadPoolCheckAlarmHandler.java similarity index 91% rename from hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java rename to hippo4j-message/src/main/java/cn/hippo4j/message/service/DefaultThreadPoolCheckAlarmHandler.java index 62c8bf53..bb155495 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/service/DefaultThreadPoolCheckAlarmHandler.java @@ -15,24 +15,22 @@ * limitations under the License. */ -package cn.hippo4j.core.executor; +package cn.hippo4j.message.service; +import cn.hippo4j.common.api.ThreadPoolCheckAlarm; import cn.hippo4j.common.toolkit.CalculateUtil; import cn.hippo4j.common.toolkit.StringUtil; -import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage; +import cn.hippo4j.core.executor.DynamicThreadPoolExecutor; +import cn.hippo4j.core.executor.DynamicThreadPoolWrapper; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.core.executor.support.ThreadPoolBuilder; import cn.hippo4j.core.toolkit.ExecutorTraceContextUtil; import cn.hippo4j.core.toolkit.IdentifyUtil; import cn.hippo4j.message.enums.NotifyTypeEnum; import cn.hippo4j.message.request.AlarmNotifyRequest; -import cn.hippo4j.message.request.ChangeParameterNotifyRequest; -import cn.hippo4j.message.service.Hippo4jSendMessageService; -import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.CommandLineRunner; import java.util.List; import java.util.Objects; @@ -46,11 +44,11 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** - * Thread-pool notify alarm handler. + * Default thread-pool check alarm handler. */ @Slf4j @RequiredArgsConstructor -public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner { +public class DefaultThreadPoolCheckAlarmHandler implements Runnable, ThreadPoolCheckAlarm { private final Hippo4jSendMessageService hippo4jSendMessageService; @@ -104,6 +102,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner * @param threadPoolId thread-pool id * @param threadPoolExecutor thread-pool executor */ + @Override public void checkPoolCapacityAlarm(String threadPoolId, ThreadPoolExecutor threadPoolExecutor) { ThreadPoolNotifyAlarm alarmConfig = GlobalNotifyAlarmManage.get(threadPoolId); if (Objects.isNull(alarmConfig) || !alarmConfig.getAlarm() || alarmConfig.getCapacityAlarm() <= 0) { @@ -127,6 +126,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner * @param threadPoolId thread-pool id * @param threadPoolExecutor thread-pool executor */ + @Override public void checkPoolActivityAlarm(String threadPoolId, ThreadPoolExecutor threadPoolExecutor) { ThreadPoolNotifyAlarm alarmConfig = GlobalNotifyAlarmManage.get(threadPoolId); if (Objects.isNull(alarmConfig) || !alarmConfig.getAlarm() || alarmConfig.getActiveAlarm() <= 0) { @@ -148,6 +148,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner * * @param threadPoolId thread-pool id */ + @Override public void asyncSendRejectedAlarm(String threadPoolId) { Runnable checkPoolRejectedAlarmTask = () -> { ThreadPoolNotifyAlarm alarmConfig = GlobalNotifyAlarmManage.get(threadPoolId); @@ -172,6 +173,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner * @param executeTimeOut execute time-out * @param threadPoolExecutor thread-pool executor */ + @Override public void asyncSendExecuteTimeOutAlarm(String threadPoolId, long executeTime, long executeTimeOut, ThreadPoolExecutor threadPoolExecutor) { ThreadPoolNotifyAlarm alarmConfig = GlobalNotifyAlarmManage.get(threadPoolId); if (Objects.isNull(alarmConfig) || !alarmConfig.getAlarm()) { @@ -195,19 +197,6 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner } } - /** - * Send pool config change. - * - * @param request change parameter notify request - */ - public void sendPoolConfigChange(ChangeParameterNotifyRequest request) { - request.setActive(active.toUpperCase()); - String appName = StringUtil.isBlank(itemId) ? applicationName : itemId; - request.setAppName(appName); - request.setIdentify(IdentifyUtil.getIdentify()); - hippo4jSendMessageService.sendChangeMessage(request); - } - /** * Build alarm notify request. * diff --git a/hippo4j-message/src/main/java/cn/hippo4j/message/service/DefaultThreadPoolConfigChangeHandler.java b/hippo4j-message/src/main/java/cn/hippo4j/message/service/DefaultThreadPoolConfigChangeHandler.java new file mode 100644 index 00000000..730edd81 --- /dev/null +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/service/DefaultThreadPoolConfigChangeHandler.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.hippo4j.message.service; + +import cn.hippo4j.common.api.ThreadPoolConfigChange; +import cn.hippo4j.common.toolkit.StringUtil; +import cn.hippo4j.core.toolkit.IdentifyUtil; +import cn.hippo4j.message.request.ChangeParameterNotifyRequest; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; + +/** + * Default thread-pool config change handler. + */ +@RequiredArgsConstructor +public class DefaultThreadPoolConfigChangeHandler implements ThreadPoolConfigChange { + + @Value("${spring.profiles.active:UNKNOWN}") + private String active; + + @Value("${spring.dynamic.thread-pool.item-id:}") + private String itemId; + + @Value("${spring.application.name:UNKNOWN}") + private String applicationName; + + private final Hippo4jSendMessageService hippo4jSendMessageService; + + /** + * Send pool config change. + * + * @param requestParam change parameter notify request + */ + @Override + public void sendPoolConfigChange(ChangeParameterNotifyRequest requestParam) { + requestParam.setActive(active.toUpperCase()); + String appName = StringUtil.isBlank(itemId) ? applicationName : itemId; + requestParam.setAppName(appName); + requestParam.setIdentify(IdentifyUtil.getIdentify()); + hippo4jSendMessageService.sendChangeMessage(requestParam); + } +} diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/manage/GlobalNotifyAlarmManage.java b/hippo4j-message/src/main/java/cn/hippo4j/message/service/GlobalNotifyAlarmManage.java similarity index 94% rename from hippo4j-core/src/main/java/cn/hippo4j/core/executor/manage/GlobalNotifyAlarmManage.java rename to hippo4j-message/src/main/java/cn/hippo4j/message/service/GlobalNotifyAlarmManage.java index fee2a1ee..c9f9fdc8 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/manage/GlobalNotifyAlarmManage.java +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/service/GlobalNotifyAlarmManage.java @@ -15,9 +15,7 @@ * limitations under the License. */ -package cn.hippo4j.core.executor.manage; - -import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; +package cn.hippo4j.message.service; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/hippo4j-message/src/main/java/cn/hippo4j/message/service/SendMessageHandler.java b/hippo4j-message/src/main/java/cn/hippo4j/message/service/SendMessageHandler.java index 9e61f362..37e939bf 100644 --- a/hippo4j-message/src/main/java/cn/hippo4j/message/service/SendMessageHandler.java +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/service/SendMessageHandler.java @@ -18,7 +18,7 @@ package cn.hippo4j.message.service; import cn.hippo4j.message.dto.NotifyConfigDTO; -import cn.hippo4j.message.request.base.NotifyRequest; +import cn.hippo4j.common.api.NotifyRequest; /** * Send message handler. diff --git a/hippo4j-monitor/hippo4j-monitor-elasticsearch/pom.xml b/hippo4j-monitor/hippo4j-monitor-elasticsearch/pom.xml index 3ced6cef..0fcd444c 100644 --- a/hippo4j-monitor/hippo4j-monitor-elasticsearch/pom.xml +++ b/hippo4j-monitor/hippo4j-monitor-elasticsearch/pom.xml @@ -9,10 +9,6 @@ hippo4j-monitor-elasticsearch - - 6.8.17 - - cn.hippo4j diff --git a/hippo4j-monitor/pom.xml b/hippo4j-monitor/pom.xml index 8550b18c..f7a28f85 100644 --- a/hippo4j-monitor/pom.xml +++ b/hippo4j-monitor/pom.xml @@ -16,35 +16,4 @@ hippo4j-monitor-local-log hippo4j-monitor-micrometer - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.artifactId} - ${project.version} - ${maven.build.timestamp} - chen.ma - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.3 - - - - jar - - - - - - diff --git a/hippo4j-server/hippo4j-config/pom.xml b/hippo4j-server/hippo4j-config/pom.xml index b4ec93d8..f548e2cc 100644 --- a/hippo4j-server/hippo4j-config/pom.xml +++ b/hippo4j-server/hippo4j-config/pom.xml @@ -11,7 +11,6 @@ true - 2.1.214 @@ -50,6 +49,7 @@ cn.hippo4j hippo4j-adapter-base + ${revision} cn.hippo4j @@ -63,6 +63,7 @@ org.hibernate.validator hibernate-validator + ${hibernate-validator.version} org.springframework.boot diff --git a/hippo4j-server/hippo4j-console/pom.xml b/hippo4j-server/hippo4j-console/pom.xml index 5f89640a..193658a6 100644 --- a/hippo4j-server/hippo4j-console/pom.xml +++ b/hippo4j-server/hippo4j-console/pom.xml @@ -29,9 +29,5 @@ hippo4j-auth ${revision} - - org.hibernate.validator - hibernate-validator - diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/pom.xml b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/pom.xml index abf69151..837a1f3b 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/pom.xml +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/pom.xml @@ -22,6 +22,12 @@ cn.hippo4j hippo4j-core + ${revision} + + + cn.hippo4j + hippo4j-message + ${revision} com.alibaba.nacos @@ -39,21 +45,18 @@ com.ctrip.framework.apollo apollo-client ${apollo.version} - compile true org.apache.curator curator-framework ${curator-framework.version} - compile true io.etcd jetcd-core ${jetcd.version} - compile true @@ -104,6 +107,7 @@ cn.hippo4j hippo4j-adapter-base + ${revision} cn.hippo4j diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java index b30b235c..6dcf8475 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -17,6 +17,8 @@ package cn.hippo4j.config.springboot.starter.config; +import cn.hippo4j.common.api.ThreadPoolCheckAlarm; +import cn.hippo4j.common.api.ThreadPoolConfigChange; import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.config.springboot.starter.monitor.ThreadPoolMonitorExecutor; import cn.hippo4j.config.springboot.starter.notify.CoreNotifyConfigBuilder; @@ -29,11 +31,12 @@ import cn.hippo4j.config.springboot.starter.support.DynamicThreadPoolConfigServi import cn.hippo4j.config.springboot.starter.support.DynamicThreadPoolPostProcessor; import cn.hippo4j.core.config.UtilAutoConfiguration; import cn.hippo4j.core.enable.MarkerConfiguration; -import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; import cn.hippo4j.core.handler.DynamicThreadPoolBannerHandler; import cn.hippo4j.message.api.NotifyConfigBuilder; import cn.hippo4j.message.config.MessageConfiguration; import cn.hippo4j.message.service.AlarmControlHandler; +import cn.hippo4j.message.service.DefaultThreadPoolCheckAlarmHandler; +import cn.hippo4j.message.service.DefaultThreadPoolConfigChangeHandler; import cn.hippo4j.message.service.Hippo4jBaseSendMessageService; import cn.hippo4j.message.service.Hippo4jSendMessageService; import cn.hippo4j.springboot.starter.adapter.web.WebAdapterConfiguration; @@ -76,8 +79,15 @@ public class DynamicThreadPoolAutoConfiguration { } @Bean - public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(Hippo4jSendMessageService hippo4jSendMessageService) { - return new ThreadPoolNotifyAlarmHandler(hippo4jSendMessageService); + @ConditionalOnMissingBean + public ThreadPoolCheckAlarm defaultThreadPoolCheckAlarmHandler(Hippo4jSendMessageService hippo4jSendMessageService) { + return new DefaultThreadPoolCheckAlarmHandler(hippo4jSendMessageService); + } + + @Bean + @ConditionalOnMissingBean + public ThreadPoolConfigChange defaultThreadPoolConfigChangeHandler(Hippo4jSendMessageService hippo4jSendMessageService) { + return new DefaultThreadPoolConfigChangeHandler(hippo4jSendMessageService); } @Bean @@ -92,10 +102,10 @@ public class DynamicThreadPoolAutoConfiguration { @Bean @SuppressWarnings("all") - public DynamicThreadPoolRefreshListener hippo4jExecutorsListener(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler, + public DynamicThreadPoolRefreshListener hippo4jExecutorsListener(ThreadPoolConfigChange threadPoolConfigChange, CoreNotifyConfigBuilder coreNotifyConfigBuilder, Hippo4jBaseSendMessageService hippoBaseSendMessageService) { - return new DynamicThreadPoolRefreshListener(threadPoolNotifyAlarmHandler, coreNotifyConfigBuilder, hippoBaseSendMessageService); + return new DynamicThreadPoolRefreshListener(threadPoolConfigChange, coreNotifyConfigBuilder, hippoBaseSendMessageService); } @Bean diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/ZookeeperRefresherHandler.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/ZookeeperRefresherHandler.java index 0f01b047..00f6e6e5 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/ZookeeperRefresherHandler.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/ZookeeperRefresherHandler.java @@ -17,11 +17,7 @@ package cn.hippo4j.config.springboot.starter.refresher; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; - -import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage; +import cn.hippo4j.message.service.GlobalNotifyAlarmManage; import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; import lombok.extern.slf4j.Slf4j; import org.apache.curator.framework.CuratorFramework; @@ -35,6 +31,10 @@ import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.curator.utils.ZKPaths; import org.apache.zookeeper.WatchedEvent; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; + /** * Zookeeper refresher handler. */ diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java index 8f1e4a3b..fe30533c 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java @@ -17,6 +17,7 @@ package cn.hippo4j.config.springboot.starter.refresher.event; +import cn.hippo4j.common.api.ThreadPoolConfigChange; import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum; import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum; import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue; @@ -26,18 +27,21 @@ import cn.hippo4j.config.springboot.starter.config.ExecutorProperties; import cn.hippo4j.config.springboot.starter.notify.CoreNotifyConfigBuilder; import cn.hippo4j.config.springboot.starter.support.GlobalCoreThreadPoolManage; import cn.hippo4j.core.executor.DynamicThreadPoolExecutor; -import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; -import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.message.dto.NotifyConfigDTO; import cn.hippo4j.message.request.ChangeParameterNotifyRequest; +import cn.hippo4j.message.service.GlobalNotifyAlarmManage; import cn.hippo4j.message.service.Hippo4jBaseSendMessageService; import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.core.annotation.Order; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -54,7 +58,7 @@ import static cn.hippo4j.config.springboot.starter.refresher.event.Hippo4jConfig @Order(EXECUTORS_LISTENER) public class DynamicThreadPoolRefreshListener extends AbstractRefreshListener { - private final ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler; + private final ThreadPoolConfigChange threadPoolConfigChange; private final CoreNotifyConfigBuilder coreNotifyConfigBuilder; @@ -95,7 +99,7 @@ public class DynamicThreadPoolRefreshListener extends AbstractRefreshListenerhippo4j-adapter-rabbitmq ${revision} + + org.springframework.boot + spring-boot-starter-amqp + true + diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq/pom.xml index c6a049fc..c2d58f96 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq/pom.xml +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq/pom.xml @@ -15,5 +15,11 @@ hippo4j-adapter-spring-cloud-stream-rabbitmq ${revision} + + org.springframework.cloud + spring-cloud-starter-stream-rabbit + ${spring-cloud-starter-stream-rabbitmq.version} + true + diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml index 70131d65..5de5c2ee 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml @@ -21,12 +21,18 @@ cn.hippo4j hippo4j-core + ${revision} cn.hippo4j hippo4j-common ${revision} + + cn.hippo4j + hippo4j-message + ${revision} + org.springframework.boot spring-boot-configuration-processor @@ -36,39 +42,25 @@ org.projectlombok lombok - - com.aliyun - alibaba-dingtalk-service-sdk - - - - log4j - log4j - - - org.springframework.boot spring-boot-starter-tomcat - compile true org.springframework.boot spring-boot-starter-jetty - compile true org.springframework.boot spring-boot-starter-undertow - compile true cn.hippo4j hippo4j-adapter-base + ${revision} io.netty diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java index b950b423..1f3a5b44 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -20,11 +20,12 @@ package cn.hippo4j.springboot.starter.config; import cn.hippo4j.adapter.base.ThreadPoolAdapterBeanContainer; import cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose; import cn.hippo4j.common.api.ThreadDetailState; +import cn.hippo4j.common.api.ThreadPoolCheckAlarm; +import cn.hippo4j.common.api.ThreadPoolConfigChange; import cn.hippo4j.common.api.ThreadPoolDynamicRefresh; import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.core.config.UtilAutoConfiguration; import cn.hippo4j.core.enable.MarkerConfiguration; -import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; import cn.hippo4j.core.executor.support.service.DynamicThreadPoolService; import cn.hippo4j.core.handler.DynamicThreadPoolBannerHandler; @@ -33,6 +34,8 @@ 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.DefaultThreadPoolCheckAlarmHandler; +import cn.hippo4j.message.service.DefaultThreadPoolConfigChangeHandler; import cn.hippo4j.message.service.Hippo4jBaseSendMessageService; import cn.hippo4j.message.service.Hippo4jSendMessageService; import cn.hippo4j.springboot.starter.adapter.web.WebAdapterConfiguration; @@ -195,19 +198,26 @@ public class DynamicThreadPoolAutoConfiguration { } @Bean - public ThreadPoolDynamicRefresh threadPoolDynamicRefresh(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler) { - return new ServerThreadPoolDynamicRefresh(threadPoolNotifyAlarmHandler); + @ConditionalOnMissingBean + public ThreadPoolCheckAlarm defaultThreadPoolCheckAlarmHandler(Hippo4jSendMessageService hippo4jSendMessageService) { + return new DefaultThreadPoolCheckAlarmHandler(hippo4jSendMessageService); } @Bean - public DynamicThreadPoolSubscribeConfig dynamicThreadPoolSubscribeConfig(ThreadPoolDynamicRefresh threadPoolDynamicRefresh, - ClientWorker clientWorker) { - return new DynamicThreadPoolSubscribeConfig(threadPoolDynamicRefresh, clientWorker, properties); + @ConditionalOnMissingBean + public ThreadPoolConfigChange defaultThreadPoolConfigChangeHandler(Hippo4jSendMessageService hippo4jSendMessageService) { + return new DefaultThreadPoolConfigChangeHandler(hippo4jSendMessageService); } @Bean - public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(Hippo4jSendMessageService hippo4jSendMessageService) { - return new ThreadPoolNotifyAlarmHandler(hippo4jSendMessageService); + public ThreadPoolDynamicRefresh threadPoolDynamicRefresh(ThreadPoolConfigChange threadPoolConfigChange) { + return new ServerThreadPoolDynamicRefresh(threadPoolConfigChange); + } + + @Bean + public DynamicThreadPoolSubscribeConfig dynamicThreadPoolSubscribeConfig(ThreadPoolDynamicRefresh threadPoolDynamicRefresh, + ClientWorker clientWorker) { + return new DynamicThreadPoolSubscribeConfig(threadPoolDynamicRefresh, clientWorker, properties); } @Bean diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ServerThreadPoolDynamicRefresh.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ServerThreadPoolDynamicRefresh.java index 55e93559..0b9ba60d 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ServerThreadPoolDynamicRefresh.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ServerThreadPoolDynamicRefresh.java @@ -17,6 +17,7 @@ package cn.hippo4j.springboot.starter.core; +import cn.hippo4j.common.api.ThreadPoolConfigChange; import cn.hippo4j.common.api.ThreadPoolDynamicRefresh; import cn.hippo4j.common.enums.EnableEnum; import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum; @@ -26,7 +27,6 @@ import cn.hippo4j.common.model.ThreadPoolParameter; import cn.hippo4j.common.model.ThreadPoolParameterInfo; import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.core.executor.DynamicThreadPoolExecutor; -import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.message.request.ChangeParameterNotifyRequest; import lombok.AllArgsConstructor; @@ -48,7 +48,7 @@ import static cn.hippo4j.common.constant.ChangeThreadPoolConstants.CHANGE_THREAD @AllArgsConstructor public class ServerThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh { - private final ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler; + private final ThreadPoolConfigChange threadPoolConfigChange; @Override public void dynamicRefresh(String content) { @@ -95,7 +95,7 @@ public class ServerThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh .nowExecuteTimeOut(executeTimeOut) .build(); changeNotifyRequest.setThreadPoolId(threadPoolId); - threadPoolNotifyAlarmHandler.sendPoolConfigChange(changeNotifyRequest); + threadPoolConfigChange.sendPoolConfigChange(changeNotifyRequest); log.info(CHANGE_THREAD_POOL_TEXT, threadPoolId, String.format(CHANGE_DELIMITER, originalCoreSize, afterExecutor.getCorePoolSize()), diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolConfigService.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolConfigService.java index 96e8d717..02c9eb02 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolConfigService.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolConfigService.java @@ -27,21 +27,18 @@ import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.common.web.base.Result; import cn.hippo4j.common.web.exception.ServiceException; import cn.hippo4j.core.executor.DynamicThreadPoolWrapper; -import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.core.executor.support.service.AbstractDynamicThreadPoolService; import cn.hippo4j.message.dto.NotifyConfigDTO; +import cn.hippo4j.message.service.GlobalNotifyAlarmManage; import cn.hippo4j.message.service.Hippo4jBaseSendMessageService; import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; import cn.hippo4j.springboot.starter.config.BootstrapProperties; -import cn.hippo4j.springboot.starter.core.ClientWorker; import cn.hippo4j.springboot.starter.core.DynamicThreadPoolSubscribeConfig; -import cn.hippo4j.springboot.starter.event.ApplicationRefreshedEvent; import cn.hippo4j.springboot.starter.notify.ServerNotifyConfigBuilder; import cn.hippo4j.springboot.starter.remote.HttpAgent; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.context.ApplicationListener; import java.util.List; import java.util.Map; diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java index b1b6cee9..f1909be4 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java @@ -32,10 +32,10 @@ import cn.hippo4j.common.web.base.Result; import cn.hippo4j.core.executor.DynamicThreadPool; import cn.hippo4j.core.executor.DynamicThreadPoolExecutor; import cn.hippo4j.core.executor.DynamicThreadPoolWrapper; -import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.core.executor.support.adpter.DynamicThreadPoolAdapterChoose; import cn.hippo4j.core.toolkit.DynamicThreadPoolAnnotationUtil; +import cn.hippo4j.message.service.GlobalNotifyAlarmManage; import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; import cn.hippo4j.springboot.starter.config.BootstrapProperties; import cn.hippo4j.springboot.starter.core.DynamicThreadPoolSubscribeConfig; diff --git a/pom.xml b/pom.xml index ca54d980..f3352663 100644 --- a/pom.xml +++ b/pom.xml @@ -48,13 +48,14 @@ 6.5.0 2.9.3 6.1.5.Final - 2.12.1 0.9.0 2.11.1 2.0.0 + 2.1.214 + 3.0.5 + 2.6.12 1.7.7 - 1.2.9 1.8.4 2.0.4 3.4.2 @@ -64,6 +65,7 @@ 1.7.2 2.2.2 4.1.56.Final + 6.8.17 9.0.55 5.1.0 2.2.6.RELEASE @@ -103,21 +105,6 @@ pom import - - cn.hippo4j - hippo4j-message - ${revision} - - - cn.hippo4j - hippo4j-core - ${revision} - - - cn.hippo4j - hippo4j-adapter-base - ${revision} - com.baomidou mybatis-plus-boot-starter @@ -128,47 +115,11 @@ dozer-core ${dozer.version} - - com.github.ben-manes.caffeine - caffeine - ${caffeine.version} - - - com.aliyun - alibaba-dingtalk-service-sdk - ${dingtalk-sdk.version} - - - com.alibaba - transmittable-thread-local - ${transmittable-thread-local.version} - - - org.hibernate.validator - hibernate-validator - ${hibernate-validator.version} - org.slf4j slf4j-api ${slf4j-api.version} - - ch.qos.logback - logback-core - ${logback.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - org.springframework.boot - spring-boot-starter-json - ${spring-boot.version} - compile - io.netty netty-all