@VisibleForTesting
  void validateHosts() {
    Set<String> clusterHosts = cluster.getHostNames();
    Set<String> requestHosts = state.getNewServices().values().stream()
      .flatMap(componentHosts -> componentHosts.values().stream())
      .flatMap(Collection::stream)
      .collect(toSet());
    Set<String> unknownHosts = new TreeSet<>(Sets.difference(requestHosts, clusterHosts));

    CHECK.checkArgument(unknownHosts.isEmpty(),
      "Requested host not associated with cluster %s: %s", cluster.getClusterName(), unknownHosts);
  }
Create an {@link AddServiceInfo} based on the validated request.
ambari-server/src/main/java/org/apache/ambari/server/topology/addservice/RequestValidator.java