OF-1700: When stopping the manager, cleanly shut down its components.
When a manager of components is stopped, its managed components should also be gracefully stopped.
My assumption is that this didn't occur, as ordinarily, stopping a manager indicates a shutdown of Openfire, in which all components are stopped anyways.
In a clustered setup, it is desirable to have components shut down gracefully. An important effect of this is that other cluster nodes are notified of the shutdown.
OF-1707: Should not send disco#info to already available components.
Openfire allows more than one instance of a component to operate behind a JID. This is mainly used for load-distribution.
When a new Component connects, a service discovery request is sent to it. Its response is used to trigger event listeners.
If the subdomain of the component is already active (if another than the first component connects for a domain), then doing service discovery is not needed. The response triggers unwanted events in registered ComponentEventListener instances.
OF-1700: Clean Component caches when cluster nodes go down.
Cluster nodes retain state related to external components that were connected to cluster nodes after those nodes have gone offline. This is undesirable, as it does not reflect the runtime environment.
This commit:
- Introduces a utility class that hides the complexity of working with various Cache implementations.
- Removes local component data from clustered caches when the local node is shut down (controlled shutdown).
- Removes remote component data from clustered caches when a remote node is shut down (uncontrolled network issues).
Notable omissions not fixed by this commit:
- ComponentEventListener instances are not invoked.
- Other caches (unrelated to components) in the same classes likely benefit from these changes.
My intention is to first complete work on the issue of clustered Component state, after which the same principles can be applied to other caches.
Refactoring: add values to multi-valued cache. OF-1700 and OF-1701 introduced new utility methods to remove elements from a multi-valued cache. To reduce boilerplate code, a similar construct should be used for adding elements to such a cache.