diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index af91cef3..3838abda 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -17,7 +17,8 @@
0.9.0
2.11.1
2.1.214
- 3.12.4
+ 4.11.0
+ 1.12.23
3.0.5
2.6.12
1.7.7
@@ -112,6 +113,16 @@
${h2.version}
runtime
+
+ net.bytebuddy
+ byte-buddy
+ ${bytebuddy.version}
+
+
+ net.bytebuddy
+ byte-buddy-agent
+ ${bytebuddy.version}
+
org.springframework.cloud
spring-cloud-starter-consul-config
diff --git a/docs/docs/user_docs/dev_manual/queue-custom.md b/docs/docs/user_docs/dev_manual/queue-custom.md
index 5d8c9075..addfbfcf 100644
--- a/docs/docs/user_docs/dev_manual/queue-custom.md
+++ b/docs/docs/user_docs/dev_manual/queue-custom.md
@@ -2,13 +2,13 @@
sidebar_position: 4
---
-# Custom Blocking Queue
+# 阻塞队列自定义
-Hippo4j extends blocking queues through SPI, allowing users to implement custom blocking queue types in Hippo4j.
+Hippo4j 通过 SPI 的方式对拒绝策略进行扩展,可以让用户在 Hippo4j 中完成自定义阻塞队列实现。
-## 1. Define Custom Queue Class
+## 1. 定义自定义队列类
-Implement the interface `cn.hippo4j.common.executor.support.CustomBlockingQueue`:
+实现接口 `cn.hippo4j.common.executor.support.CustomBlockingQueue`:
```java
public class MyArrayBlockingQueue implements CustomBlockingQueue {
@@ -30,51 +30,51 @@ public class MyArrayBlockingQueue implements CustomBlockingQueue {
}
```
-## 2. Declare SPI File
+## 2. 声明 SPI 文件
-Create a file in the `src/main/resources/META-INF/services/` directory:
+在 `src/main/resources/META-INF/services/` 目录下新增文件:
```
cn.hippo4j.common.executor.support.CustomBlockingQueue
```
-File content (single line):
+文件内容仅一行:
```
com.example.queue.MyArrayBlockingQueue
```
-## 3. Server-side Activation
+## 3. 服务端生效方式
-When the `queueType` and `capacity` delivered by the server match the custom type, the framework will automatically create the queue through SPI.
+当服务端下发的 `queueType` 与 `capacity` 命中自定义类型时,框架会通过 SPI 自动创建队列。
-### 3.1 Queue Creation and Validation
+### 3.1 队列创建与验证
```java
-// Create queue
+// 创建队列
BlockingQueue q = BlockingQueueManager.createQueue(queueType, capacity);
-// Validate queue configuration
+// 验证队列配置
boolean valid = BlockingQueueManager.validateQueueConfig(queueType, capacity);
-// Dynamic capacity adjustment (only supported by ResizableCapacityLinkedBlockingQueue)
+// 动态调整容量(仅 ResizableCapacityLinkedBlockingQueue 支持)
boolean ok = BlockingQueueManager.changeQueueCapacity(executor.getQueue(), newCapacity);
```
-### 3.2 Queue Type Switching
+### 3.2 队列类型切换
-When you need to switch queue types, use the `ThreadPoolRebuilder.rebuildAndSwitch` method, which creates a new thread pool instance and safely migrates tasks:
+当需要切换队列类型时,使用 `ThreadPoolRebuilder.rebuildAndSwitch` 方法,该方法会创建新的线程池实例并安全地迁移任务:
```java
boolean ok = ThreadPoolRebuilder.rebuildAndSwitch(
- executor, // Current thread pool
- newQueueType, // New queue type
- capacity, // Queue capacity
- threadPoolId // Thread pool ID
+ executor, // 当前线程池
+ newQueueType, // 新队列类型
+ capacity, // 队列容量
+ threadPoolId // 线程池ID
);
```
-Server-side dynamic refresh implementation:
+服务端动态刷新处的实现:
```java
// ServerThreadPoolDynamicRefresh#handleQueueChanges
@@ -82,7 +82,7 @@ boolean queueTypeChanged = parameter.getQueueType() != null &&
!Objects.equals(BlockingQueueManager.getQueueType(executor.getQueue()), parameter.getQueueType());
if (queueTypeChanged) {
- // Use safe rebuild approach for queue switching
+ // 使用安全的重建方式切换队列
boolean ok = ThreadPoolRebuilder.rebuildAndSwitch(
executor,
parameter.getQueueType(),
@@ -92,7 +92,7 @@ if (queueTypeChanged) {
if (ok) {
log.info("Queue type rebuilt and switched to: {}",
BlockingQueueTypeEnum.getBlockingQueueNameByType(parameter.getQueueType()));
- }
+ }
}
```
diff --git a/docs/docs/user_docs/dev_manual/queue-info.md b/docs/docs/user_docs/dev_manual/queue-info.md
index cd28fa8d..47e372db 100644
--- a/docs/docs/user_docs/dev_manual/queue-info.md
+++ b/docs/docs/user_docs/dev_manual/queue-info.md
@@ -2,27 +2,27 @@
sidebar_position: 3
---
-# Built-in Blocking Queues
+# 内置阻塞队列
-Hippo4j provides multiple built-in blocking queue types that are ready to use out of the box. You can also extend custom queue types through SPI.
+Hippo4j 内置多种常用阻塞队列类型,支持开箱即用,亦可通过 SPI 扩展自定义队列类型。
-## Built-in Queue Types
+## 内置类型清单
-The following types can be directly selected in the server or configuration (Enum: `BlockingQueueTypeEnum`):
+以下类型可直接在服务端或配置中选择(枚举:`BlockingQueueTypeEnum`):
-- ArrayBlockingQueue (bounded array-based queue)
-- LinkedBlockingQueue (linked list queue)
-- LinkedBlockingDeque (double-ended queue)
-- SynchronousQueue (synchronous handoff queue)
-- LinkedTransferQueue (transferable queue)
-- PriorityBlockingQueue (priority queue)
-- ResizableCapacityLinkedBlockingQueue (dynamically resizable linked list queue)
+- ArrayBlockingQueue(数组有界队列)
+- LinkedBlockingQueue(链表队列)
+- LinkedBlockingDeque(双端队列)
+- SynchronousQueue(同步移交队列)
+- LinkedTransferQueue(可转移队列)
+- PriorityBlockingQueue(优先级队列)
+- ResizableCapacityLinkedBlockingQueue(可在线动态调容量的链表队列)
-Among them, `ResizableCapacityLinkedBlockingQueue` supports online capacity changes without rebuilding the thread pool, making it suitable for dynamic tuning scenarios.
+其中 `ResizableCapacityLinkedBlockingQueue` 支持在线变更 `capacity`,无需重建线程池,适合动态调优场景。
-## Code Reference
+## 代码对应
-Enum definition:
+枚举定义:
```java
// cn.hippo4j.common.executor.support.BlockingQueueTypeEnum
@@ -38,7 +38,7 @@ RESIZABLE_LINKED_BLOCKING_QUEUE(9, "ResizableCapacityLinkedBlockingQueue") {
}
```
-Creation and validation:
+创建与验证:
```java
// cn.hippo4j.common.executor.support.BlockingQueueManager
@@ -47,13 +47,14 @@ boolean valid = BlockingQueueManager.validateQueueConfig(queueType, capacity);
boolean ok = BlockingQueueManager.changeQueueCapacity(executor.getQueue(), newCapacity);
```
-## Usage Recommendations
+## 使用建议
-- Need online capacity adjustment: prioritize `ResizableCapacityLinkedBlockingQueue`
-- Need strictly bounded: choose `ArrayBlockingQueue`
-- Need unbounded throughput: choose `LinkedBlockingQueue`
-- Need priority: choose `PriorityBlockingQueue`
-- Need synchronous handoff: choose `SynchronousQueue`
+- 需要在线调容量:优先选择 `ResizableCapacityLinkedBlockingQueue`
+- 需要严格有界:选择 `ArrayBlockingQueue`
+- 需要无界吞吐:选择 `LinkedBlockingQueue`
+- 需要优先级:选择 `PriorityBlockingQueue`
+- 需要同步移交:选择 `SynchronousQueue`
+
+如需自定义队列类型,请参考《阻塞队列自定义》。
-For custom queue types, please refer to "Custom Blocking Queue".
diff --git a/infra/common/pom.xml b/infra/common/pom.xml
index 607b5caf..b6397481 100644
--- a/infra/common/pom.xml
+++ b/infra/common/pom.xml
@@ -48,11 +48,6 @@
mockito-core
test
-
- org.mockito
- mockito-inline
- test
-
org.apache.tomcat.embed
tomcat-embed-core
diff --git a/pom.xml b/pom.xml
index b6dff1a5..8ab17d7c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,7 +55,7 @@
2.0.0-SNAPSHOT
- 3.12.4
+ 4.11.0
1.8
true
false
@@ -101,11 +101,6 @@
mockito-core
${mockito.version}
-
- org.mockito
- mockito-inline
- ${mockito.version}
-
org.mockito
mockito-junit-jupiter
diff --git a/threadpool/core/pom.xml b/threadpool/core/pom.xml
index 903c73de..41b1d3b0 100644
--- a/threadpool/core/pom.xml
+++ b/threadpool/core/pom.xml
@@ -41,7 +41,7 @@
org.mockito
- mockito-inline
+ mockito-core
test