WIP: Host Report cache
Summarize your change. When the service is under heavy load, HostReports start to take a long time to be processed. The hostReports were organized in a simple queue, which caused old reports that became obsolete to take the place of fresh reports that would give the server the right picture of the status of hosts.
To solve this problem, the following solution was implemented:
- Use a
expireAfterWritecache to keep only the last report of every host - Use a
WeakReferenceto make sure processed reports get cleaned from the cache - Change the run command of the ThreadPool to query the cache and then run
With this we keep the order of the queue intact, but make sure every host only gets its last hostReport processed. It the service is not under load and hostReports are being processed in less than 100ms, there shouldn't be more than one report for the same host, given that every host reports every 10s-30s, therefore this change only affects the system when it's under pressure.
Stand by to merge this, I'm refactoring to simplify the logic.