diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index f611cef9..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 0a0f4f76..0b2f4240 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,7 @@ docs/.docusaurus ### Docker ### docker/conf -docker/target \ No newline at end of file +docker/target + +### OS ### +.DS_Store \ No newline at end of file diff --git a/docs/i18n/zh/code.json b/docs/i18n/zh/code.json index 8dec86f4..5e96ee21 100644 --- a/docs/i18n/zh/code.json +++ b/docs/i18n/zh/code.json @@ -271,7 +271,7 @@ }, "homepage.secondTitle": { "message": "Hippo4j能做什么?", - "description": "a title for introduciton part" + "description": "The title for the introduction part" }, "homepage.introduction.fristPartTitle": { "message": "动态变更", @@ -312,5 +312,49 @@ "companyPage.linkText": { "message": "点击进行登记", "description": "the text for the company page link" + }, + "homepage.introduction.fristPartDesc1": { + "message": "应用程序运行时动态更改线程池参数。", + "description": "The first desc for fristPart " + }, + "homepage.introduction.fristPartDesc2": { + "message": "包括但不限于核心大小、最大线程数、阻塞队列大小和拒绝策略。", + "description": "The second desc for fristPart " + }, + "homepage.introduction.fristPartDesc3": { + "message": "支持应用集群中不同节点的差异化线程池配置。", + "description": "The third desc for fristPart " + }, + "homepage.introduction.secondPartDesc1": { + "message": "应用程序线程池运行时点,提供四个告警维度。", + "description": "The first desc for secondPart " + }, + "homepage.introduction.secondPartDesc2": { + "message": "线程池超载,阻塞队列容量,运行时间过长以及拒绝策略警报。", + "description": "The second desc for secondPart " + }, + "homepage.introduction.secondPartDesc3": { + "message": "它还支持在自定义时间段内的非重复闹钟。", + "description": "The third desc for secondPart " + }, + "homepage.introduction.thirdPartDesc1": { + "message": "支持为数据收集和存储设置自定义持续时间的线程池。", + "description": "The first desc for thirdPart " + }, + "homepage.introduction.thirdPartDesc2": { + "message": "同时还支持Prometheus、InfluxDB和其他监控系统。", + "description": "The second desc for thirdPart " + }, + "homepage.introduction.thirdPartDesc3": { + "message": "通过Grafana或内置的监控页面提供可视化仪表盘监控指标。", + "description": "The third desc for thirdPart " + }, + "homepage.secondTitleDesc1": { + "message": "Hippo4j是一个Java线程池框架。", + "description": "The p1 for the secondTitle part" + }, + "homepage.secondTitleDesc2": { + "message": "提供了线程池动态调整、自定义警报和操作监控等功能,以帮助提高业务系统的运营支持能力。", + "description": "The p2 for the secondTitle part" } } diff --git a/docs/src/components/LandingPage/Hero.jsx b/docs/src/components/LandingPage/Hero.jsx index 9b0ffa50..3be732c6 100644 --- a/docs/src/components/LandingPage/Hero.jsx +++ b/docs/src/components/LandingPage/Hero.jsx @@ -6,19 +6,24 @@ import Translate, { translate } from "@docusaurus/Translate"; import Link from "@docusaurus/Link"; const Hero = () => { + const bgUrl = useBaseUrl("/img/bg.jpg"); + return ( -
-
-
+
+
+
{/* */} -
+
{/* title and desc */}
-

+

Hippo4j

-

+

{ Thread Pool Framework For Java

-

+

{

{/* */} -
+
Hippo4j System
diff --git a/docs/src/components/LandingPage/Introduction.jsx b/docs/src/components/LandingPage/Introduction.jsx index e67ba148..41a78df5 100644 --- a/docs/src/components/LandingPage/Introduction.jsx +++ b/docs/src/components/LandingPage/Introduction.jsx @@ -3,101 +3,205 @@ import useBaseUrl from "@docusaurus/useBaseUrl"; import Translate from "@docusaurus/Translate"; const Introduction = () => { return ( -
-
-

- {/* Hippo4j能做什么 */} - - What can Hippo4j do? - -

-
-
-
- -
-
-

- {/* 动态变更 */} - - Dynamic Change - -

-

- {/* 应用运行时动态变更线程池参数,包括不限于核心、最大线程、阻塞队列大小和拒绝策略等,支持应用集群下不同节点线程池配置差异化 */} - - Application runtime dynamically changes thread pool parameters, - including but not limited to core size, maximum threads, - blocking queue size, and rejection policy. It supports - differentiated thread pool configurations for different nodes in - the application cluster. - -
-
-

+
+
+
+
+ Hippo4j System
-
-

- {/* 自定义报警 */} +
+

- Custom Alarm + What can Hippo4j do? -

-

- {/* 应用线程池运行时埋点,提供四种报警维度,线程池过载、阻塞队列容量、运行超长以及拒绝策略报警,并支持自定义时间内不重复报警 */} +

+

- Application thread pool runtime point, providing four alarm - dimensions: thread pool overload, blocking queue capacity, - running for too long, and rejection strategy alarm. It also - supports non-repetitive alarms within a custom time period. + Hippo4j is a Java thread pool framework. -
-

-
-
-

- {/* 运行监控 */} +

- Operation Monitoring + Provided functions such as dynamic adjustment of thread pool, + custom alerts, and operation monitoring to help improve the + operational support capabilities of business systems. -

-

- {/* 支持自定义时长线程池运行数据采集存储,同时也支持 - Prometheus、InfluxDB 等采集监控,通过 Grafana - 或内置监控页面提供可视化大屏监控运行指标 */} - - Supports custom duration thread pool for data collection and - storage, while also supporting Prometheus, InfluxDB, and other - monitoring systems. Provides visualized dashboard monitoring - metrics through Grafana or built-in monitoring pages. - -
-

+ +
+
+
+

+ + Dynamic Change + +

+
+

+ + Application runtime dynamically changes thread pool + parameters. + {" "} +

+

+ + Including but not limited to core size, maximum threads, + blocking queue size, and rejection policy. + +

+

+ + It supports differentiated thread pool configurations for + different nodes in the application cluster. + +

+
+
+
+ {/* */} + Hippo4j System +
+
+
+
+ Hippo4j System +
+
+
+

+ + Custom Alarm + +

+
+

+ + Application thread pool runtime point, providing four + alarm dimensions. + +

+

+ + Thread pool overload, blocking queue capacity, running for + too long, and rejection strategy alarm. + {" "} +

+

+ + It also supports non-repetitive alarms within a custom + time period. + +

+
+
+
+
+
+
+

+ + Operation Monitoring + +

+
+

+ + Supports custom duration thread pool for data collection and + storage. + +

+

+ + while also supporting Prometheus, InfluxDB, and other + monitoring systems. + +

+

+ + Provides visualized dashboard monitoring metrics through + Grafana or built-in monitoring pages. + +

+
+
+
+ {/* */} + Hippo4j System +
+
+
); diff --git a/docs/src/css/custom.css b/docs/src/css/custom.css index db4d0be4..8701dc1b 100644 --- a/docs/src/css/custom.css +++ b/docs/src/css/custom.css @@ -219,3 +219,31 @@ div[class^="announcementBar_"] { height: 100%; } } + +/* Custom by youbo */ +.bg-cousom { + background-position: 50% 65%; +} + +.bg-svg { + background-color: #ffffff; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='192' height='192' viewBox='0 0 192 192'%3E%3Cpath fill='%23c2b9cf' fill-opacity='0.31' d='M192 15v2a11 11 0 0 0-11 11c0 1.94 1.16 4.75 2.53 6.11l2.36 2.36a6.93 6.93 0 0 1 1.22 7.56l-.43.84a8.08 8.08 0 0 1-6.66 4.13H145v35.02a6.1 6.1 0 0 0 3.03 4.87l.84.43c1.58.79 4 .4 5.24-.85l2.36-2.36a12.04 12.04 0 0 1 7.51-3.11 13 13 0 1 1 .02 26 12 12 0 0 1-7.53-3.11l-2.36-2.36a4.93 4.93 0 0 0-5.24-.85l-.84.43a6.1 6.1 0 0 0-3.03 4.87V143h35.02a8.08 8.08 0 0 1 6.66 4.13l.43.84a6.91 6.91 0 0 1-1.22 7.56l-2.36 2.36A10.06 10.06 0 0 0 181 164a11 11 0 0 0 11 11v2a13 13 0 0 1-13-13 12 12 0 0 1 3.11-7.53l2.36-2.36a4.93 4.93 0 0 0 .85-5.24l-.43-.84a6.1 6.1 0 0 0-4.87-3.03H145v35.02a8.08 8.08 0 0 1-4.13 6.66l-.84.43a6.91 6.91 0 0 1-7.56-1.22l-2.36-2.36A10.06 10.06 0 0 0 124 181a11 11 0 0 0-11 11h-2a13 13 0 0 1 13-13c2.47 0 5.79 1.37 7.53 3.11l2.36 2.36a4.94 4.94 0 0 0 5.24.85l.84-.43a6.1 6.1 0 0 0 3.03-4.87V145h-35.02a8.08 8.08 0 0 1-6.66-4.13l-.43-.84a6.91 6.91 0 0 1 1.22-7.56l2.36-2.36A10.06 10.06 0 0 0 107 124a11 11 0 0 0-22 0c0 1.94 1.16 4.75 2.53 6.11l2.36 2.36a6.93 6.93 0 0 1 1.22 7.56l-.43.84a8.08 8.08 0 0 1-6.66 4.13H49v35.02a6.1 6.1 0 0 0 3.03 4.87l.84.43c1.58.79 4 .4 5.24-.85l2.36-2.36a12.04 12.04 0 0 1 7.51-3.11A13 13 0 0 1 81 192h-2a11 11 0 0 0-11-11c-1.94 0-4.75 1.16-6.11 2.53l-2.36 2.36a6.93 6.93 0 0 1-7.56 1.22l-.84-.43a8.08 8.08 0 0 1-4.13-6.66V145H11.98a6.1 6.1 0 0 0-4.87 3.03l-.43.84c-.79 1.58-.4 4 .85 5.24l2.36 2.36a12.04 12.04 0 0 1 3.11 7.51A13 13 0 0 1 0 177v-2a11 11 0 0 0 11-11c0-1.94-1.16-4.75-2.53-6.11l-2.36-2.36a6.93 6.93 0 0 1-1.22-7.56l.43-.84a8.08 8.08 0 0 1 6.66-4.13H47v-35.02a6.1 6.1 0 0 0-3.03-4.87l-.84-.43c-1.59-.8-4-.4-5.24.85l-2.36 2.36A12 12 0 0 1 28 109a13 13 0 1 1 0-26c2.47 0 5.79 1.37 7.53 3.11l2.36 2.36a4.94 4.94 0 0 0 5.24.85l.84-.43A6.1 6.1 0 0 0 47 84.02V49H11.98a8.08 8.08 0 0 1-6.66-4.13l-.43-.84a6.91 6.91 0 0 1 1.22-7.56l2.36-2.36A10.06 10.06 0 0 0 11 28 11 11 0 0 0 0 17v-2a13 13 0 0 1 13 13c0 2.47-1.37 5.79-3.11 7.53l-2.36 2.36a4.94 4.94 0 0 0-.85 5.24l.43.84A6.1 6.1 0 0 0 11.98 47H47V11.98a8.08 8.08 0 0 1 4.13-6.66l.84-.43a6.91 6.91 0 0 1 7.56 1.22l2.36 2.36A10.06 10.06 0 0 0 68 11 11 11 0 0 0 79 0h2a13 13 0 0 1-13 13 12 12 0 0 1-7.53-3.11l-2.36-2.36a4.93 4.93 0 0 0-5.24-.85l-.84.43A6.1 6.1 0 0 0 49 11.98V47h35.02a8.08 8.08 0 0 1 6.66 4.13l.43.84a6.91 6.91 0 0 1-1.22 7.56l-2.36 2.36A10.06 10.06 0 0 0 85 68a11 11 0 0 0 22 0c0-1.94-1.16-4.75-2.53-6.11l-2.36-2.36a6.93 6.93 0 0 1-1.22-7.56l.43-.84a8.08 8.08 0 0 1 6.66-4.13H143V11.98a6.1 6.1 0 0 0-3.03-4.87l-.84-.43c-1.59-.8-4-.4-5.24.85l-2.36 2.36A12 12 0 0 1 124 13a13 13 0 0 1-13-13h2a11 11 0 0 0 11 11c1.94 0 4.75-1.16 6.11-2.53l2.36-2.36a6.93 6.93 0 0 1 7.56-1.22l.84.43a8.08 8.08 0 0 1 4.13 6.66V47h35.02a6.1 6.1 0 0 0 4.87-3.03l.43-.84c.8-1.59.4-4-.85-5.24l-2.36-2.36A12 12 0 0 1 179 28a13 13 0 0 1 13-13zM84.02 143a6.1 6.1 0 0 0 4.87-3.03l.43-.84c.8-1.59.4-4-.85-5.24l-2.36-2.36A12 12 0 0 1 83 124a13 13 0 1 1 26 0c0 2.47-1.37 5.79-3.11 7.53l-2.36 2.36a4.94 4.94 0 0 0-.85 5.24l.43.84a6.1 6.1 0 0 0 4.87 3.03H143v-35.02a8.08 8.08 0 0 1 4.13-6.66l.84-.43a6.91 6.91 0 0 1 7.56 1.22l2.36 2.36A10.06 10.06 0 0 0 164 107a11 11 0 0 0 0-22c-1.94 0-4.75 1.16-6.11 2.53l-2.36 2.36a6.93 6.93 0 0 1-7.56 1.22l-.84-.43a8.08 8.08 0 0 1-4.13-6.66V49h-35.02a6.1 6.1 0 0 0-4.87 3.03l-.43.84c-.79 1.58-.4 4 .85 5.24l2.36 2.36a12.04 12.04 0 0 1 3.11 7.51A13 13 0 1 1 83 68a12 12 0 0 1 3.11-7.53l2.36-2.36a4.93 4.93 0 0 0 .85-5.24l-.43-.84A6.1 6.1 0 0 0 84.02 49H49v35.02a8.08 8.08 0 0 1-4.13 6.66l-.84.43a6.91 6.91 0 0 1-7.56-1.22l-2.36-2.36A10.06 10.06 0 0 0 28 85a11 11 0 0 0 0 22c1.94 0 4.75-1.16 6.11-2.53l2.36-2.36a6.93 6.93 0 0 1 7.56-1.22l.84.43a8.08 8.08 0 0 1 4.13 6.66V143h35.02z'%3E%3C/path%3E%3C/svg%3E"); +} + +:root[data-theme="light"] { + --hero-image-url: url("../../static/img/hero/hero-removebg.png"); + --hero-bg-url: url("../../static/img/hero/bg.jpg"); +} + +:root[data-theme="dark"] { + --hero-image-url: url("../../static/img/hero/hero.jpg"); + /* --hero-bg-url:url("../../static/img/bg.jpg"); */ +} + +.hero-img { + content: var(--hero-image-url); +} + +.hero-bg-img { + background-image: var(--hero-bg-url); +} diff --git a/docs/static/img/hero/bg.jpg b/docs/static/img/hero/bg.jpg new file mode 100644 index 00000000..d091d3ff Binary files /dev/null and b/docs/static/img/hero/bg.jpg differ diff --git a/docs/static/img/hero/bg2.jpg b/docs/static/img/hero/bg2.jpg new file mode 100644 index 00000000..00fff65e Binary files /dev/null and b/docs/static/img/hero/bg2.jpg differ diff --git a/docs/static/img/hero/hero-removebg.png b/docs/static/img/hero/hero-removebg.png new file mode 100644 index 00000000..d402847d Binary files /dev/null and b/docs/static/img/hero/hero-removebg.png differ diff --git a/docs/static/img/hero/hero.jpg b/docs/static/img/hero/hero.jpg new file mode 100644 index 00000000..84fabc9b Binary files /dev/null and b/docs/static/img/hero/hero.jpg differ diff --git a/docs/static/img/introduction/p1.svg b/docs/static/img/introduction/p1.svg new file mode 100644 index 00000000..b8036b71 --- /dev/null +++ b/docs/static/img/introduction/p1.svg @@ -0,0 +1 @@ + diff --git a/docs/static/img/introduction/p2.svg b/docs/static/img/introduction/p2.svg new file mode 100644 index 00000000..f28d4722 --- /dev/null +++ b/docs/static/img/introduction/p2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/static/img/introduction/p3.svg b/docs/static/img/introduction/p3.svg new file mode 100644 index 00000000..b5c179e2 --- /dev/null +++ b/docs/static/img/introduction/p3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/static/img/introduction/title-image.svg b/docs/static/img/introduction/title-image.svg new file mode 100644 index 00000000..d7078a32 --- /dev/null +++ b/docs/static/img/introduction/title-image.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java b/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java index 2f47e414..110c3f5e 100644 --- a/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java +++ b/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java @@ -90,7 +90,7 @@ public interface BootstrapPropertiesInterface { /** * Get apollo. */ - default Map getApollo(){ + default Map getApollo() { return null; } diff --git a/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java b/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java index 7dd86213..263317f7 100644 --- a/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java +++ b/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java @@ -105,8 +105,8 @@ public class WebThreadPoolHandlerConfiguration { * the Web embedded server loads the {@link ServletWebServerFactory} top-level interface type at the same time */ @Bean - public UndertowWebThreadPoolHandlerAdapt undertowWebThreadPoolHandler() { - return new DefaultUndertowWebThreadPoolHandler(); + public UndertowWebThreadPoolHandlerAdapt undertowWebThreadPoolHandler(WebThreadPoolRunStateHandler webThreadPoolRunStateHandler) { + return new DefaultUndertowWebThreadPoolHandler(webThreadPoolRunStateHandler); } } } diff --git a/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/config/WebThreadPoolHandlerConfiguration1x.java b/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/config/WebThreadPoolHandlerConfiguration1x.java index 80df456a..fa41e3f1 100644 --- a/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/config/WebThreadPoolHandlerConfiguration1x.java +++ b/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/config/WebThreadPoolHandlerConfiguration1x.java @@ -89,8 +89,8 @@ public class WebThreadPoolHandlerConfiguration1x { static class EmbeddedUndertow { @Bean - public WebThreadPoolService undertowWebThreadPoolHandler() { - return new UndertowWebThreadPoolHandler1x(); + public WebThreadPoolService undertowWebThreadPoolHandler(WebThreadPoolRunStateHandler webThreadPoolRunStateHandler) { + return new UndertowWebThreadPoolHandler1x(webThreadPoolRunStateHandler); } } } diff --git a/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/web/undertow/UndertowWebThreadPoolHandler1x.java b/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/web/undertow/UndertowWebThreadPoolHandler1x.java index 53e34907..4d10a79d 100644 --- a/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/web/undertow/UndertowWebThreadPoolHandler1x.java +++ b/starters/threadpool/config-spring-boot-1x/src/main/java/cn/hippo4j/config/springboot1x/starter/web/undertow/UndertowWebThreadPoolHandler1x.java @@ -18,6 +18,7 @@ package cn.hippo4j.config.springboot1x.starter.web.undertow; import cn.hippo4j.adapter.web.undertow.UndertowWebThreadPoolHandlerSupport; +import cn.hippo4j.common.support.AbstractThreadPoolRuntime; import cn.hippo4j.config.springboot1x.starter.web.AbstractWebThreadPoolService1x; import io.undertow.Undertow; import lombok.extern.slf4j.Slf4j; @@ -35,8 +36,8 @@ public class UndertowWebThreadPoolHandler1x extends AbstractWebThreadPoolService private static final String UNDERTOW_NAME = "undertow"; - public UndertowWebThreadPoolHandler1x() { - super(new UndertowWebThreadPoolHandlerSupport()); + public UndertowWebThreadPoolHandler1x(AbstractThreadPoolRuntime runtime) { + super(new UndertowWebThreadPoolHandlerSupport(runtime)); } @Override diff --git a/threadpool/.DS_Store b/threadpool/.DS_Store deleted file mode 100644 index f70d1c0d..00000000 Binary files a/threadpool/.DS_Store and /dev/null differ diff --git a/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/DefaultUndertowWebThreadPoolHandler.java b/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/DefaultUndertowWebThreadPoolHandler.java index 5b2f81ae..78fe89da 100644 --- a/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/DefaultUndertowWebThreadPoolHandler.java +++ b/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/DefaultUndertowWebThreadPoolHandler.java @@ -22,6 +22,7 @@ import java.util.Objects; import java.util.concurrent.Executor; import cn.hippo4j.adapter.web.DefaultAbstractWebThreadPoolService; +import cn.hippo4j.common.support.AbstractThreadPoolRuntime; import io.undertow.Undertow; import lombok.extern.slf4j.Slf4j; @@ -39,8 +40,8 @@ public class DefaultUndertowWebThreadPoolHandler extends DefaultAbstractWebThrea private static final String UNDERTOW_NAME = "undertow"; - public DefaultUndertowWebThreadPoolHandler() { - super(new UndertowWebThreadPoolHandlerSupport()); + public DefaultUndertowWebThreadPoolHandler(AbstractThreadPoolRuntime runtime) { + super(new UndertowWebThreadPoolHandlerSupport(runtime)); } /** diff --git a/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/UndertowWebThreadPoolHandlerSupport.java b/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/UndertowWebThreadPoolHandlerSupport.java index 2d3d3c06..d22d0c91 100644 --- a/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/UndertowWebThreadPoolHandlerSupport.java +++ b/threadpool/adapter/web/src/main/java/cn/hippo4j/adapter/web/undertow/UndertowWebThreadPoolHandlerSupport.java @@ -24,9 +24,12 @@ import cn.hippo4j.common.model.ThreadPoolBaseInfo; import cn.hippo4j.common.model.ThreadPoolParameter; import cn.hippo4j.common.model.ThreadPoolParameterInfo; import cn.hippo4j.common.model.ThreadPoolRunStateInfo; +import cn.hippo4j.common.support.AbstractThreadPoolRuntime; import cn.hippo4j.common.toolkit.CalculateUtil; +import cn.hippo4j.common.toolkit.ReflectUtil; import cn.hippo4j.core.executor.DynamicThreadPoolExecutor; import lombok.extern.slf4j.Slf4j; +import org.jboss.threads.EnhancedQueueExecutor; import org.springframework.util.ReflectionUtils; import org.xnio.Options; import org.xnio.XnioWorker; @@ -44,8 +47,14 @@ import java.util.concurrent.Executor; @Slf4j public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandlerSupport { + private final AbstractThreadPoolRuntime runtime; + private Executor executor; + public UndertowWebThreadPoolHandlerSupport(AbstractThreadPoolRuntime runtime) { + this.runtime = runtime; + } + /** * A callback will be invoked and the Executor will be set up when the web container has been started. * @param executor Thread-pool executor in Undertow container. @@ -56,6 +65,7 @@ public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandle } private final long noRejectCount = -1L; + @Override public ThreadPoolBaseInfo simpleInfo() { ThreadPoolBaseInfo poolBaseInfo = new ThreadPoolBaseInfo(); @@ -67,8 +77,17 @@ public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandle poolBaseInfo.setCoreSize(coreSize); poolBaseInfo.setMaximumSize(maximumPoolSize); poolBaseInfo.setKeepAliveTime((long) keepAliveTime); - poolBaseInfo.setRejectedName("-"); - poolBaseInfo.setQueueType("-"); + poolBaseInfo.setRejectedName("RejectedExecutionException"); + poolBaseInfo.setQueueType("org.jboss.threads.EnhancedQueueExecutor.TaskNode:FIFO"); + + EnhancedQueueExecutor enhancedQueueExecutor = + (EnhancedQueueExecutor) ReflectUtil.getFieldValue( + ReflectUtil.getFieldValue(xnioWorker, "taskPool"), "executor"); + + Method getMaximumQueueSize = ReflectionUtils.findMethod(enhancedQueueExecutor.getClass(), "getMaximumQueueSize"); + ReflectionUtils.makeAccessible(getMaximumQueueSize); + int queueCapacity = (int) ReflectionUtils.invokeMethod(getMaximumQueueSize, enhancedQueueExecutor); + poolBaseInfo.setQueueCapacity(queueCapacity); } catch (Exception ex) { log.error("The undertow container failed to get thread pool parameters.", ex); } @@ -112,6 +131,33 @@ public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandle Method getActiveCount = ReflectionUtils.findMethod(fieldObject.getClass(), "getActiveCount"); ReflectionUtils.makeAccessible(getActiveCount); int activeCount = (int) ReflectionUtils.invokeMethod(getActiveCount, fieldObject); + + Field executorFiled = ReflectionUtils.findField(fieldObject.getClass(), "executor"); + ReflectionUtils.makeAccessible(executorFiled); + EnhancedQueueExecutor enhancedQueueExecutor = (EnhancedQueueExecutor) ReflectionUtils.getField(executorFiled, fieldObject); + + Method getLargestPoolSize = ReflectionUtils.findMethod(enhancedQueueExecutor.getClass(), "getLargestPoolSize"); + ReflectionUtils.makeAccessible(getLargestPoolSize); + int largestPoolSize = (int) ReflectionUtils.invokeMethod(getLargestPoolSize, enhancedQueueExecutor); + + Method getQueueSize = ReflectionUtils.findMethod(enhancedQueueExecutor.getClass(), "getQueueSize"); + ReflectionUtils.makeAccessible(getQueueSize); + int queueSize = (int) ReflectionUtils.invokeMethod(getQueueSize, enhancedQueueExecutor); + + Method getMaximumQueueSize = ReflectionUtils.findMethod(enhancedQueueExecutor.getClass(), "getMaximumQueueSize"); + ReflectionUtils.makeAccessible(getMaximumQueueSize); + int queueCapacity = (int) ReflectionUtils.invokeMethod(getMaximumQueueSize, enhancedQueueExecutor); + + int remainingCapacity = queueCapacity - queueSize; + + Method getCompletedTaskCount = ReflectionUtils.findMethod(enhancedQueueExecutor.getClass(), "getCompletedTaskCount"); + ReflectionUtils.makeAccessible(getCompletedTaskCount); + long completedTaskCount = (long) ReflectionUtils.invokeMethod(getCompletedTaskCount, enhancedQueueExecutor); + + Method getHandoffExecutor = ReflectionUtils.findMethod(enhancedQueueExecutor.getClass(), "getHandoffExecutor"); + ReflectionUtils.makeAccessible(getHandoffExecutor); + Executor handoffExecutor = (Executor) ReflectionUtils.invokeMethod(getHandoffExecutor, enhancedQueueExecutor); + activeCount = Math.max(activeCount, 0); String currentLoad = CalculateUtil.divide(activeCount, maximumPoolSize) + ""; String peakLoad = CalculateUtil.divide(activeCount, maximumPoolSize) + ""; @@ -127,7 +173,16 @@ public class UndertowWebThreadPoolHandlerSupport implements IWebThreadPoolHandle stateInfo.setRejectCount(rejectCount); stateInfo.setClientLastRefreshTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); stateInfo.setTimestamp(System.currentTimeMillis()); - return stateInfo; + + stateInfo.setQueueType("org.jboss.threads.EnhancedQueueExecutor.TaskNode:FIFO"); + stateInfo.setQueueSize(queueSize); + stateInfo.setQueueCapacity(queueCapacity); + stateInfo.setQueueRemainingCapacity(remainingCapacity); + stateInfo.setLargestPoolSize(largestPoolSize); + stateInfo.setCompletedTaskCount(completedTaskCount); + stateInfo.setRejectedName(handoffExecutor.getClass().getName()); + + return runtime.supplement(stateInfo); } @Override