-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Implement blocking queue SPI extension and add documentation #1612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Implements a pluggable blocking queue SPI and a safe “rebuild-and-switch” path to dynamically change executor queue types without hardcoding, plus concurrency controls around thread-pool rebuilds.
- Adds CustomBlockingQueue SPI and integrates SPI loading into BlockingQueueTypeEnum/BlockingQueueManager.
- Introduces ThreadPoolRebuilder with per-pool locking, new-executor creation, task migration, atomic registry swap, and rollback.
- Updates ServerThreadPoolDynamicRefresh to use the SPI/manager and adds capacity-change support where possible.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolRebuilder.java | New helper to rebuild executors with new queues, migrate tasks, switch registry, and handle rollback with locking. |
| starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ServerThreadPoolDynamicRefresh.java | Uses BlockingQueueManager + ThreadPoolRebuilder to handle queue-type/capacity changes safely. |
| infra/common/src/main/java/cn/hippo4j/common/executor/support/BlockingQueueManager.java | New manager for creation, validation, recognition, and capacity changes; includes a reflective queue-replace method. |
| infra/common/src/test/resources/META-INF/services/cn.hippo4j.common.executor.support.CustomBlockingQueue | Registers a test SPI queue implementation for tests. |
| infra/common/src/test/java/cn/hippo4j/common/executor/support/ThreadPoolRebuilderConcurrencyTest.java | Adds concurrency “design validation” tests (mostly prints) for rebuild scenarios. |
| infra/common/src/test/java/cn/hippo4j/common/executor/support/BlockingQueueSpiTest.java | Adds SPI and manager unit tests for queue creation, validation, and recognition. |
| infra/common/src/test/java/cn/hippo4j/common/executor/integration/QueueSpiIntegrationTest.java | Adds integration-style tests for SPI path (still mostly direct calls/prints). |
| docs/.../queue-info.md | New docs page listing built-in queues and manager APIs. |
| docs/.../queue-custom.md | New docs page on SPI for custom queues; includes code snippets. |
Comments suppressed due to low confidence (1)
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
.../threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolRebuilder.java
Outdated
Show resolved
Hide resolved
.../threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolRebuilder.java
Outdated
Show resolved
Hide resolved
.../threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolRebuilder.java
Outdated
Show resolved
Hide resolved
.../threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolRebuilder.java
Outdated
Show resolved
Hide resolved
.../threadpool/server/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolRebuilder.java
Outdated
Show resolved
Hide resolved
infra/common/src/main/java/cn/hippo4j/common/executor/support/BlockingQueueManager.java
Outdated
Show resolved
Hide resolved
docs/i18n/zh/docusaurus-plugin-content-docs/version-1.5.0/user_docs/dev_manual/queue-custom.md
Outdated
Show resolved
Hide resolved
infra/common/src/main/java/cn/hippo4j/common/executor/support/BlockingQueueManager.java
Outdated
Show resolved
Hide resolved
.../server/src/main/java/cn/hippo4j/springboot/starter/core/ServerThreadPoolDynamicRefresh.java
Outdated
Show resolved
Hide resolved
|
Hi @Createsequence , I have a question regarding the Mockito version upgrade in this PR. Currently: Mockito 4.11.0 (for JDK 17 compatibility) Should we keep the upgrade to 4.11.0 for JDK 17 support, or should I revert it back to 3.12.4? Thank you for your feedback! |
@mingri31164 If the current version is not affected by this PR, keep the original version. The principle of a PR is to remain focused on a single purpose. |
|
Hi @mingri31164 I noticed you also modified the front-end code for the console, but after the server starts, the front-end page doesn't support switching custom blocking queues. Please confirm that after packaging your front-end code, you replaced the original files under the path |
|
Hi @Createsequence , Thank you for your feedback. I'd like to clarify the situation: Original Frontend BehaviorThe original code already supports editing queue types in the admin console, including all built-in queue types (ArrayBlockingQueue, LinkedBlockingQueue, etc.). There was no restriction on changing queue types in the frontend. My ChangesI followed the same pattern and added support for custom blocking queues:
Queue Type Change MechanismBoth built-in and custom queue type changes follow the same restart-based mechanism:
Next StepsIf you think rebuilding and deploying the frontend is not necessary, I will revert the frontend changes to the previous version instead. Please let me know if you'd like me to proceed. Thank you! |
Your solution is undoubtedly reasonable, and I don't think there's anything wrong with it. |
Createsequence
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job




Problem
ResizableCapacityLinkedBlockingQueuetype check inServerThreadPoolDynamicRefresh.changePoolInfo()Solution
CustomBlockingQueueSPI intoBlockingQueueTypeEnum.createBlockingQueue()BlockingQueueManageras unified facade for queue operationshandleQueueChanges()methodKey Changes
Remove hardcoded type check in
changePoolInfo():Objects.equals(RESIZABLE_LINKED_BLOCKING_QUEUE.getType(), parameter.getQueueType())with capability detectionhandleQueueChanges()method for better separationBlockingQueueManager.canChangeCapacity()for dynamic detectionAdd
BlockingQueueManagerunified facade:Integrate
CustomBlockingQueueSPI:BlockingQueueTypeEnum.createBlockingQueue()to load SPI custom queuescustomOrDefaultQueue()helper for SPI lookup with fallbackServiceLoaderRegistryAdd documentation:
queue-custom.mdfor SPI registration guidequeue-info.mdfor queue type lifecycle explanationTest Coverage
BlockingQueueSpiTest: 10 scenarios including SPI registration, capacity capability detection, and design consistencyQueueSpiIntegrationTest: 6 scenarios validating hardcoded restriction removal and end-to-end flowConfigServiceQueueCapacityTest: 11 scenarios for custom queue default capacity handling