@Override
    public void execute(Host host) throws CommunicationException {
        if (host.compareTo(routingTable_.getLocalhost()) == 0) {
            logger_.info("Exchange service stopped because the given host was the local host.");
            return;
        }
        logger_.info("Executing exchange service.");

        ExchangeHandle handle = getRemoteHandle(host);
        // send local routing table
        handle.exchange(Serializer.serializeRoutingTable(routingTable_));
        // receive remote routing table
        RoutingTable remoteRT = Deserializer.deserializeRoutingTable(handle.routingTable());

        ExchangeContext context = new ExchangeContext(routingTable_, false, MAX_REF);
        context.setRemoteInfo(remoteRT);

        logger_.debug("Local peer has all the information needed to execute the exchange algorithm.");
        algorithm_.execute(context);

        if (context.isRecursive() && recursions_ < MAX_RECURSIONS) {
            logger_.debug("Executing recursion: {}", recursions_);
            ++recursions_;
            Collection<Host> level = context.getRemoteRoutingTable().getLevel(context.getCommonPathLength());
            if (level == null || level.isEmpty()) {
                return;
            }
            for (Host toExchange : level) {
                // XXX: This is a temporary code duplication. Fixed an infinite recursion.
                ExchangeHandle recHandle = getRemoteHandle(host);
                // send local routing table
                recHandle.exchange(Serializer.serializeRoutingTable(routingTable_));
                // receive remote routing table
                RoutingTable recRemoteRT = Deserializer.deserializeRoutingTable(handle.routingTable());

                ExchangeContext recContext = new ExchangeContext(routingTable_, false, MAX_REF);
                recContext.setRemoteInfo(remoteRT);

                logger_.debug("[Recursive] Local peer has all the information needed to execute the exchange algorithm.");
                algorithm_.execute(recContext);
            }
        }
    }