private void cleanupDirectedPresences(final NodeID nodeID) {
        Log.debug("Remove traces of directed presences sent from node '{}' that is gone to entities hosted in this JVM.", nodeID);
        final Map<String, Collection<String>> senders = directedPresenceAddressingByClusterNode.remove(nodeID);
        if (senders != null) {
            for (final Map.Entry<String, Collection<String>> entry : senders.entrySet()) {
                final String sender = entry.getKey();
                final Collection<String> receivers = entry.getValue();
                for (final String receiver : receivers) {
                    try {
                        final Presence presence = new Presence(Presence.Type.unavailable);
                        presence.setFrom(sender);
                        presence.setTo(receiver);
                        XMPPServer.getInstance().getPresenceRouter().route(presence);
                    }
                    catch (final PacketException e) {
                        Log.error("Failed to cleanup directed presences", e);
                    }
                }
            }
        }
    }
When the local node is joining or leaving a cluster, {@link org.jivesoftware.util.cache.CacheFactory} will swap
the implementation used to instantiate caches. This causes the cache content to be 'reset': it will no longer
contain the data that's provided by the local node. This method restores data that's provided by the local node
in the cache. It is expected to be invoked right after joining ({@link #joinedCluster()} or leaving
({@link #leftCluster()} a cluster.
xmppserver/src/main/java/org/jivesoftware/openfire/handler/PresenceUpdateHandler.java