diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/JettyWebThreadPoolHandler.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/JettyWebThreadPoolHandler.java index c3f8a7b5..c4a04da5 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/JettyWebThreadPoolHandler.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/JettyWebThreadPoolHandler.java @@ -18,6 +18,7 @@ package cn.hippo4j.adapter.web; import cn.hippo4j.common.constant.ChangeThreadPoolConstants; +import cn.hippo4j.common.enums.WebContainerEnum; import cn.hippo4j.common.model.ThreadPoolBaseInfo; import cn.hippo4j.common.model.ThreadPoolParameter; import cn.hippo4j.common.model.ThreadPoolParameterInfo; @@ -96,4 +97,9 @@ public class JettyWebThreadPoolHandler extends AbstractWebThreadPoolService { log.error("Failed to modify the jetty thread pool parameter.", ex); } } + + @Override + public WebContainerEnum getWebContainerType() { + return WebContainerEnum.JETTY; + } } diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java index 33a4d626..7546cb78 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java @@ -18,6 +18,7 @@ package cn.hippo4j.adapter.web; import cn.hippo4j.common.constant.ChangeThreadPoolConstants; +import cn.hippo4j.common.enums.WebContainerEnum; import cn.hippo4j.common.model.ThreadPoolBaseInfo; import cn.hippo4j.common.model.ThreadPoolParameter; import cn.hippo4j.common.model.ThreadPoolParameterInfo; @@ -164,4 +165,9 @@ public class TomcatWebThreadPoolHandler extends AbstractWebThreadPoolService { log.error("Failed to modify the Tomcat thread pool parameter.", ex); } } + + @Override + public WebContainerEnum getWebContainerType() { + return WebContainerEnum.TOMCAT; + } } diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java index c6b23fd2..2408cd57 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java @@ -25,6 +25,7 @@ import java.util.Objects; import java.util.concurrent.Executor; import cn.hippo4j.common.constant.ChangeThreadPoolConstants; +import cn.hippo4j.common.enums.WebContainerEnum; import cn.hippo4j.common.model.ThreadPoolBaseInfo; import cn.hippo4j.common.model.ThreadPoolParameter; import cn.hippo4j.common.model.ThreadPoolParameterInfo; @@ -155,4 +156,9 @@ public class UndertowWebThreadPoolHandler extends AbstractWebThreadPoolService { log.error("Failed to modify the undertow thread pool parameter.", ex); } } + + @Override + public WebContainerEnum getWebContainerType() { + return WebContainerEnum.UNDERTOW; + } } diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/WebThreadPoolService.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/WebThreadPoolService.java index ba88ed12..aae89244 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/WebThreadPoolService.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/WebThreadPoolService.java @@ -17,6 +17,7 @@ package cn.hippo4j.adapter.web; +import cn.hippo4j.common.enums.WebContainerEnum; import cn.hippo4j.common.model.ThreadPoolBaseInfo; import cn.hippo4j.common.model.ThreadPoolParameter; import cn.hippo4j.common.model.ThreadPoolParameterInfo; @@ -73,4 +74,11 @@ public interface WebThreadPoolService { default WebServer getWebServer() { return null; } + + /** + * resolve current web container type. + * + *

e.g: tomcat, jetty, undertow, etc.

+ */ + WebContainerEnum getWebContainerType(); } diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/enums/WebContainerEnum.java b/hippo4j-common/src/main/java/cn/hippo4j/common/enums/WebContainerEnum.java new file mode 100644 index 00000000..a942ff2b --- /dev/null +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/enums/WebContainerEnum.java @@ -0,0 +1,24 @@ +/* + * 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.enums; + +public enum WebContainerEnum { + TOMCAT, + JETTY, + UNDERTOW +} diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/spi/MyArrayBlockingQueue.java b/hippo4j-common/src/test/java/cn/hippo4j/common/spi/MyArrayBlockingQueue.java index 16b86e2e..47408032 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/spi/MyArrayBlockingQueue.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/spi/MyArrayBlockingQueue.java @@ -1,3 +1,20 @@ +/* + * 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.spi; import cn.hippo4j.common.executor.support.CustomBlockingQueue; diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java index 047bab28..57654b06 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java @@ -101,20 +101,9 @@ public class BootstrapConfigProperties implements BootstrapPropertiesInterface { private Map etcd; /** - * Tomcat thread pool config. + * web config */ - private WebThreadPoolProperties tomcat; - - /** - * Undertow thread pool config. - */ - private WebThreadPoolProperties undertow; - - /** - * Jetty thread pool config. - * KeepAliveTime is not supported temporarily. - */ - private WebThreadPoolProperties jetty; + private WebThreadPoolProperties web; /** * Notify platforms. diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/WebExecutorRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/WebExecutorRefreshListener.java index 1a438e1b..e7c2a269 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/WebExecutorRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/WebExecutorRefreshListener.java @@ -46,10 +46,7 @@ public class WebExecutorRefreshListener extends AbstractRefreshListener