private void updateHostnameVsIdMaps(ApplicationInfo applicationInfo, ApplicationId id) {
        Set<DomainName> removedHosts = new HashSet<>(hostnamesById.computeIfAbsent(id, k -> new HashSet<>()));

        applicationInfo.getModel().getHosts().stream()
                .map(HostInfo::getHostname)
                .map(DomainName::of)
                .forEach(hostname -> {
                    if (!removedHosts.remove(hostname)) {
                        // hostname has been added
                        hostnamesById.get(id).add(hostname);
                        ApplicationId previousId = idsByHostname.put(hostname, id);

                        if (previousId != null && !previousId.equals(id)) {
                            // If an activation contains a host that is currently assigned to a
                            // different application we will patch up our data structures to remain
                            // internally consistent. But listeners may be fooled.
                            logger.log(Level.WARNING, hostname + " has been reassigned from " +
                                    previousId.toFullString() + " to " + id.toFullString());

                            Set<DomainName> previousHostnames = hostnamesById.get(previousId);
                            if (previousHostnames != null) {
                                previousHostnames.remove(hostname);
                            }
                        }
                    }
                });

        removedHosts.forEach(hostname -> {
            // hostname has been removed
            idsByHostname.remove(hostname);
            hostnamesById.get(id).remove(hostname);
        });
    }
Update hostnamesById and idsByHostname based on a new applicationInfo.
service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java