zqr10159 opened a new pull request, #4062:
URL: https://github.com/apache/hertzbeat/pull/4062

   This pull request introduces significant improvements to the concurrency 
management and thread pool infrastructure in the alerting module, with a focus 
on supporting virtual threads and fine-grained execution control. The changes 
modernize thread pool usage, add per-channel concurrency limits, enhance 
resource cleanup, and provide better configurability through 
`VirtualThreadProperties`.
   
   **Concurrency and Thread Pool Modernization**
   
   * Refactored thread pools in `AlerterWorkerPool`, `AlarmEvaluator`, and 
`PeriodicAlertRuleScheduler` to support both traditional and virtual 
thread-based executors using `ManagedExecutor` and `ManagedExecutors`. This 
enables more efficient resource use and easier scaling. 
[[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R21-R60)
 
[[2]](diffhunk://#diff-b65e398d6d4d4a62e17ee776d6e47aafc7c6a991d7af7879ce018d2d9fc199d5R23-R27)
 
[[3]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL43-R76)
   
   * Updated constructors to accept `VirtualThreadProperties` via dependency 
injection, allowing dynamic configuration of thread pool behavior and 
concurrency limits. 
[[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R21-R60)
 
[[2]](diffhunk://#diff-b65e398d6d4d4a62e17ee776d6e47aafc7c6a991d7af7879ce018d2d9fc199d5R23-R27)
 
[[3]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL43-R76)
   
   **Fine-grained Concurrency Control**
   
   * Introduced per-channel concurrency limits for notification tasks in 
`AlerterWorkerPool` using `Semaphore`, preventing overload of specific 
notification channels. 
[[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593L64-R106)
 
[[2]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R160-R194)
   
   * Enhanced periodic alert rule scheduling with a new `ScheduledTaskState` 
class in `PeriodicAlertRuleScheduler`, supporting concurrent execution limits 
and task deduplication when using virtual threads. 
[[1]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL64-R106)
 
[[2]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL86-R123)
 
[[3]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbR139-R241)
   
   **Resource Management and Cleanup**
   
   * Implemented the `DisposableBean` interface in key classes 
(`AlerterWorkerPool`, `AlarmEvaluator`, `PeriodicAlertRuleScheduler`) to ensure 
proper shutdown and cleanup of thread pools and scheduled tasks during 
application shutdown. 
[[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R21-R60)
 
[[2]](diffhunk://#diff-b65e398d6d4d4a62e17ee776d6e47aafc7c6a991d7af7879ce018d2d9fc199d5R23-R27)
 
[[3]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL43-R76)
 
[[4]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbR139-R241)
 
[[5]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R204-R210)
   
   **Dependency and Configuration Updates**
   
   * Added a dependency on `hertzbeat-common-spring` in `pom.xml` to support 
new configuration and executor classes.
   
   These changes collectively improve the reliability, scalability, and 
maintainability of the alerting subsystem, while paving the way for more 
efficient use of Java's virtual threads.
   
   ---
   
   **References:**
   - Concurrency and thread pool modernization: 
[[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R21-R60)
 
[[2]](diffhunk://#diff-b65e398d6d4d4a62e17ee776d6e47aafc7c6a991d7af7879ce018d2d9fc199d5R23-R27)
 
[[3]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL43-R76)
   - Fine-grained concurrency control: 
[[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593L64-R106)
 
[[2]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R160-R194)
 
[[3]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL64-R106)
 
[[4]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL86-R123)
 
[[5]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbR139-R241)
   - Resource management and cleanup: 
[[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R21-R60)
 
[[2]](diffhunk://#diff-b65e398d6d4d4a62e17ee776d6e47aafc7c6a991d7af7879ce018d2d9fc199d5R23-R27)
 
[[3]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbL43-R76)
 
[[4]](diffhunk://#diff-262867e3294c6b186387f299608b3c427f138616d88b02d05cd287773b558ecbR139-R241)
 
[[5]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593R204-R210)
   - Dependency and configuration updates: 
[hertzbeat-alerter/pom.xmlR43-R47](diffhunk://#diff-3252bc45cdf8afc2e3823fc2f74a9ed7f7eca5a5282dcd95d92ca2856736e439R43-R47)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to