public void updateHostContainerMetrics(Map<Host, Set<Integer>> oldMapping, Map<Host, Set<Integer>> newMapping) {
        if (newMapping == null) {
            // Nothing to do if the new mapping is null.
            return;
        }

        // Report current number of Segment Store hosts with containers.
        DYNAMIC_LOGGER.reportGaugeValue(SEGMENT_STORE_HOST_NUMBER, newMapping.keySet().size());

        // Report the host/container relationships and the number of containers per host.
        newMapping.keySet().forEach(host -> reportContainerCountPerHost(host, newMapping.get(host)));
        if (oldMapping == null) {
            // Do not perform comparisons against the oldMapping if it is null.
            return;
        }

        // Report Segment Store failures and container failovers. We consider a host failure the event that the old
        // host/container map contains a host not existing in the new map; in this case, the related containers will
        // need to be relocated across the rest of running hosts (Container failover).
        Set<Host> workingNodes = new HashSet<>(oldMapping.keySet());
        if (workingNodes.retainAll(newMapping.keySet())) {
            oldMapping.keySet().stream()
                               .filter(host -> !workingNodes.contains(host))
                               .forEach(failedHost -> {
                                   reportHostFailures(failedHost);
                                   reportContainerFailovers(oldMapping.get(failedHost));
                               });
        }
    }
public void updateHostContainerMetrics ( Map < Host , Set < Integer > > oldMapping , Map < Host , Set < Integer > > newMapping ) { if ( newMapping == null ) { return ; } DYNAMIC_LOGGER . reportGaugeValue ( SEGMENT_STORE_HOST_NUMBER , newMapping . keySet ( ) . size ( ) ) ; newMapping . keySet ( ) . forEach ( host -> reportContainerCountPerHost ( host , newMapping . get ( host ) ) ) ; if ( oldMapping == null ) { return ; } Set < Host > workingNodes = new HashSet < > ( oldMapping . keySet ( ) ) ; if ( workingNodes . retainAll ( newMapping . keySet ( ) ) ) { oldMapping . keySet ( ) . stream ( ) . filter ( host -> ! workingNodes . contains ( host ) ) . forEach ( failedHost -> { reportHostFailures ( failedHost ) ; reportContainerFailovers ( oldMapping . get ( failedHost ) ) ; } ) ; } }
This method reports the number of available Segment Store hosts managing Containers, as well as the number of
Containers assigned to each host. Moreover, this method also reports failures for hosts and Containers; we
consider a failure the situation in which a host is present in the oldMapping, but not present in newMapping.

@param oldMapping    Previous host to Container relationships.
@param newMapping    Updated host to Container relationships.