jayblanc opened a new pull request, #746:
URL: https://github.com/apache/unomi/pull/746

   This pull request refactors the `HealthCheckService` to improve thread 
safety, caching, and concurrency, as well as to simplify the health check 
execution logic. The main changes include introducing a cache for health check 
results, switching to a cached thread pool, and removing unnecessary stream 
usage.
   
   **Thread safety and caching improvements:**
   * Added a cache (`healthCache`) for health check results, a timestamp 
(`cacheTimestamp`), and synchronization logic to prevent concurrent refreshes. 
This ensures results are not recomputed too frequently and improves performance 
under load. 
[[1]](diffhunk://#diff-fcfb0be4f3106eb845adf037a89f74198eb6dd88e88e4f51500858b15e22b095R44-L46)
 
[[2]](diffhunk://#diff-fcfb0be4f3106eb845adf037a89f74198eb6dd88e88e4f51500858b15e22b095L117-L149)
   * Introduced a `cacheLock` object and `busy` flag to coordinate cache 
refreshes and avoid race conditions. 
[[1]](diffhunk://#diff-fcfb0be4f3106eb845adf037a89f74198eb6dd88e88e4f51500858b15e22b095R44-L46)
 
[[2]](diffhunk://#diff-fcfb0be4f3106eb845adf037a89f74198eb6dd88e88e4f51500858b15e22b095L117-L149)
   
   **Concurrency and execution changes:**
   * Changed the executor from a single-threaded executor to a cached thread 
pool to better handle concurrent health check provider executions.
   * Removed the use of `Future` and timeouts when executing health check 
providers; now calls `provider.execute()` directly and handles exceptions by 
marking the provider as timed out.
   
   **Code simplification and cleanup:**
   * Removed unnecessary use of streams and collectors when filtering 
providers, simplifying the code with a direct `toList()` call. 
[[1]](diffhunk://#diff-fcfb0be4f3106eb845adf037a89f74198eb6dd88e88e4f51500858b15e22b095L31)
 
[[2]](diffhunk://#diff-fcfb0be4f3106eb845adf037a89f74198eb6dd88e88e4f51500858b15e22b095L117-L149)
   * Improved logging and early returns when the health check service is 
disabled.
   
    - [X] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   


-- 
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]

Reply via email to