private void createHostResource(Clusters clusters, Set<String> duplicates,
                                  Set<String> unknowns, Set<String> allHosts,
                                  HostRequest request)
      throws AmbariException {


    if (request.getHostname() == null
        || request.getHostname().isEmpty()) {
      throw new IllegalArgumentException("Invalid arguments, hostname"
          + " cannot be null");
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("Received a createHost request, hostname={}, request={}", request.getHostname(), request);
    }

    if (allHosts.contains(request.getHostname())) {
      // throw dup error later
      duplicates.add(request.getHostname());
      return;
    }
    allHosts.add(request.getHostname());

    try {
      // ensure host is registered
      clusters.getHost(request.getHostname());
    }
    catch (HostNotFoundException e) {
      unknowns.add(request.getHostname());
      return;
    }

    if (request.getClusterName() != null) {
      try {
        // validate that cluster_name is valid
        clusters.getCluster(request.getClusterName());
      } catch (ClusterNotFoundException e) {
        throw new ParentObjectNotFoundException("Attempted to add a host to a cluster which doesn't exist: "
            + " clusterName=" + request.getClusterName());
      }
    }
  }
If the rack info provided in the request differs from the rack info of the host
update the rack info of the host with the value from the host request

@param cluster The cluster to check user privileges against. User is required
               to have {@link RoleAuthorization#HOST_ADD_DELETE_HOSTS} rights on the cluster.
@param host The host of which rack information is to be updated
@param hostRequest
@return true is host was updated otherwise false
@throws AmbariException
@throws AuthorizationException
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java