public void updateNodes(AvailabilityPolicy availabilityPolicy, Collection<Node> newNodes, ClusterMonitor<Node> monitor) {
        List<Node> currentNodes = new ArrayList<>(newNodes);
        Map<Node, Node> retainedNodes = groups.nodes().stream().collect(toMap(node -> node, node -> node));
        for (int i = 0; i < currentNodes.size(); i++) {
            Node retained = retainedNodes.get(currentNodes.get(i));
            if (retained != null)
                currentNodes.set(i, retained);
        }
        SearchGroupsImpl groups = toGroups(availabilityPolicy, currentNodes);
        this.localCorpusDispatchTarget = findLocalCorpusDispatchTarget(HostName.getLocalhost(), groups);
        this.monitoredGroups = groups;
        monitor.reconfigure(groups.nodes());
        this.groups = groups;
    }
Sets the new nodes to monitor to be the new nodes, but keep any existing node instances which are equal the new ones.
container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java