private void restoreCacheContent()
    {
        Log.debug( "Restoring cache content for cache '{}' by adding all outgoing server routes that are connected to the local cluster node.", serversCache.getName() );

        // Check if there are local s2s connections that are already in the cache for remote nodes
        Set<DomainPair> localServerRoutesToRemove = new HashSet<>();
        localServerRoutingTable.getRoutes().forEach(
            route -> route.getOutgoingDomainPairs().forEach(
                address -> {
                    final Lock lock = serversCache.getLock(address);
                    lock.lock();
                    try {
                        if (serversCache.containsKey(address)) {
                            Log.info("We have an s2s connection to {}, but this connection also exists on other nodes. They are not allowed to both exist, so this local s2s connection will be terminated.", address);
                            localServerRoutesToRemove.add(address);
                        } else {
                            serversCache.put(address, server.getNodeID());
                        }
                    } finally {
                        lock.unlock();
                    }
                })
        );
        for (DomainPair localServerRouteToRemove : localServerRoutesToRemove) {
            final LocalOutgoingServerSession route = localServerRoutingTable.getRoute(localServerRouteToRemove);
            // Terminating the connection should also trigger the OutgoingServerSessionListener#onConnectionClose in SessionManagerImpl.
            // That will result in the s2s connection actually being removed from the LocalRoutingTable.
            try {
                route.close();
            } catch (Exception e) {
                Log.warn("Failed to terminate the local s2s connection for {}.", route, e);
            }
        }

        Log.debug( "Restoring cache content for cache '{}' by adding all component routes that are connected to the local cluster node.", componentsCache.getName() );
        localComponentRoutingTable.getRoutes().forEach( route -> CacheUtil.addValueToMultiValuedCache( componentsCache, route.getAddress().getDomain(), server.getNodeID(), HashSet::new ));

        addLocalClientRoutesToCache();
    }
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/spi/RoutingTableImpl.java