OF-2298: Reverse order of cluster event listeners
To be able to distinguish between the cause for an occupant to 'leave' a MUC room, it is important that we reverse the order in which the Cluster event listeners are fired.
Without this change, the SessionManager/RoutingTable would mark a user as unavailable. As a result of that, the MUC implementation would make the corresponding occupant leave the room, as if it sent a presence unavailable. By ensuring that the MUC-based cluster event listener is invoked first, the cause (a cluster breakage) for the occupant to become unavailable is known. This can be used to add status code 333 to the presence unavailable that is sent on behalf of the occupant that is dropping out.
OF-2298: Add status code 333 when MUC occupant leaves caused by cluster breakage
When a cluster breaks, MUC occupants that are connected to now unavailable cluster nodes should be considered as having 'left' the room. This commit adds a status code to the corresponding presence update that indicates that this departure is due to a technical issue. See https://xmpp.org/extensions/xep-0045.html#service-error-kick
OF-2297: Gracefully remove 'lost' MUC Rooms (clustering)
When a cluster node breaks out of the cluster, it sometimes occur that it locally does not have access to all cache content. A common way to resolve issues surrounding this is to maintain a local copy of relevant data.
For MUC rooms, this approach is not feasible, as it would require a continuous synchronization of MUC room data (which is resource intensive).
Instead of 'recovering' lost cache data, this commit considers a MUC room that has disappeared from the cache (during a cluster leave event) to be 'broken'. Presence unavailable (with status code 333) is sent to all local occupants, indicating that they're no longer in the room.
OF-2299: Prevent NPE when processing directed presences
This NPE was observed when testing in a 3-node cluster. My assumption is that one node already caused the entry to be deleted, causing the second node to generate a NPE. Adding a null-check should be a safe way to prevent this.