zqr10159 opened a new pull request, #3872: URL: https://github.com/apache/hertzbeat/pull/3872
This pull request introduces significant updates to the HTTP collector and the alerting worker pool to modernize the codebase and improve performance. The most important changes are the migration of HTTP client usage from Apache HttpClient 4.x to HttpClient 5.x, refactoring of HTTP request/response handling, and updating the alerting worker pool to use Java 21 virtual threads. Additionally, the project has been updated to require Java 21. **HTTP Client Modernization and Refactoring:** * Migrated all HTTP client code in `HttpCollectImpl` from Apache HttpClient 4.x to 5.x, updating imports and replacing deprecated classes and methods with their modern equivalents. This includes switching to `ClassicHttpRequest`, `ClassicHttpResponse`, and using `HttpClientResponseHandler` for response handling. [[1]](diffhunk://#diff-71217ece1f4e1c5fe1e0d12227ab6d1267a3b02fa5571a0de7537f8b605e53c5L70-R88) [[2]](diffhunk://#diff-71217ece1f4e1c5fe1e0d12227ab6d1267a3b02fa5571a0de7537f8b605e53c5L137-R178) [[3]](diffhunk://#diff-71217ece1f4e1c5fe1e0d12227ab6d1267a3b02fa5571a0de7537f8b605e53c5L321-R355) [[4]](diffhunk://#diff-71217ece1f4e1c5fe1e0d12227ab6d1267a3b02fa5571a0de7537f8b605e53c5L219-R254) * Refactored HTTP request creation to return a new inner class `HttpRequestWithConfig`, bundling the request and its configuration together. This enables more flexible and type-safe handling of custom timeouts and request parameters. [[1]](diffhunk://#diff-71217ece1f4e1c5fe1e0d12227ab6d1267a3b02fa5571a0de7537f8b605e53c5R110-R131) [[2]](diffhunk://#diff-71217ece1f4e1c5fe1e0d12227ab6d1267a3b02fa5571a0de7537f8b605e53c5L858-R895) * Updated the context creation logic to accept and apply request configuration, improved digest authentication setup, and ensured compatibility with HttpClient 5.x API. **Alerting Worker Pool Modernization:** * Refactored `AlerterWorkerPool` to use Java 21 virtual threads (`Thread.ofVirtual()` and `Executors.newThreadPerTaskExecutor`) instead of traditional thread pools, improving scalability and simplifying thread management. [[1]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593L20-R36) [[2]](diffhunk://#diff-6776f3dd31e7cf77986a217161fa71970497a6b92f2a0a1b4330ddcd1f644593L47-R87) **Project Configuration Update:** * Updated the project’s Java version requirement from 17 to 21 in `pom.xml`, enabling the use of virtual threads and other modern language features. These changes collectively improve performance, maintainability, and scalability, and ensure the codebase is up-to-date with current Java and HTTP client best practices. -- 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]
