public void setExclusiveToApplicationId(List<Node> hosts, ApplicationMutex lock, ApplicationId application) {
        List<Node> hostsToWrite = hosts.stream()
                                       .filter(host -> !host.exclusiveToApplicationId().equals(Optional.of(application)))
                                       .peek(host -> {
                                           if (host.type() != NodeType.host)
                                               throw new IllegalArgumentException("Unable to set " + host + " exclusive to " + application +
                                                                                  ": the node is not a tenant host");
                                           if (host.exclusiveToApplicationId().isPresent())
                                               throw new IllegalArgumentException("Unable to set " + host + " exclusive to " + application +
                                                                                  ": it is already set exclusive to " + host.exclusiveToApplicationId().get());
                                       })
                                       .map(host -> host.withExclusiveToApplicationId(application))
                                       .toList();
        write(hostsToWrite, lock);
    }
Sets the exclusiveToApplicationId field of the hosts to 'application'.
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java