private void processDeleteHostRequests(List<HostRequest> requests,  Clusters clusters, DeleteStatusMetaData deleteStatusMetaData) throws AmbariException {
    Set<String> hostsClusters = new HashSet<>();
    Set<String> hostNames = new HashSet<>();
    Set<Long> hostIds = new HashSet<>();
    TreeMap<String, TopologyCluster> topologyUpdates = new TreeMap<>();
    for (HostRequest hostRequest : requests) {
      // Assume the user also wants to delete it entirely, including all clusters.
      String hostname = hostRequest.getHostname();
      Long hostId = clusters.getHost(hostname).getHostId();
      hostNames.add(hostname);
      hostIds.add(hostId);

      if (hostRequest.getClusterName() != null) {
        hostsClusters.add(hostRequest.getClusterName());
      }

      LOG.info("Received Delete request for host {} from cluster {}.", hostname, hostRequest.getClusterName());

      // delete all host components
      Set<ServiceComponentHostRequest> schrs = new HashSet<>();
      for (Cluster cluster : clusters.getClustersForHost(hostname)) {
        List<ServiceComponentHost> list = cluster.getServiceComponentHosts(hostname);
        for (ServiceComponentHost sch : list) {
          ServiceComponentHostRequest schr = new ServiceComponentHostRequest(cluster.getClusterName(),
                                                                             sch.getServiceName(),
                                                                             sch.getServiceComponentName(),
                                                                             sch.getHostName(),
                                                                             null);
          schrs.add(schr);
        }
      }
      DeleteStatusMetaData componentDeleteStatus = null;
      if (schrs.size() > 0) {
        try {
          componentDeleteStatus = getManagementController().deleteHostComponents(schrs);
        } catch (Exception ex) {
          deleteStatusMetaData.addException(hostname, ex);
        }
      }

      if (componentDeleteStatus != null) {
        for (String key : componentDeleteStatus.getDeletedKeys()) {
          deleteStatusMetaData.addDeletedKey(key);
        }
        for (String key : componentDeleteStatus.getExceptionForKeys().keySet()) {
          deleteStatusMetaData.addException(key, componentDeleteStatus.getExceptionForKeys().get(key));
        }
      }

      if (hostRequest.getClusterName() != null) {
        hostsClusters.add(hostRequest.getClusterName());
      }
      try {
        Set<Cluster> hostClusters = new HashSet<>(clusters.getClustersForHost(hostname));
        clusters.deleteHost(hostname);
        for (Cluster cluster : hostClusters) {
          String clusterId = Long.toString(cluster.getClusterId());
          if (!topologyUpdates.containsKey(clusterId)) {
            topologyUpdates.put(clusterId, new TopologyCluster());
          }
          topologyUpdates.get(clusterId).getTopologyHosts().add(new TopologyHost(hostId, hostname));
        }
        deleteStatusMetaData.addDeletedKey(hostname);
      } catch (Exception ex) {
        deleteStatusMetaData.addException(hostname, ex);
      }
      removeHostFromClusterTopology(clusters, hostRequest);
      for (LogicalRequest logicalRequest: topologyManager.getRequests(Collections.emptyList())) {
        logicalRequest.removeHostRequestByHostName(hostname);
      }
    }
    clusters.publishHostsDeletion(hostIds, hostNames);
    TopologyUpdateEvent topologyUpdateEvent = new TopologyUpdateEvent(topologyUpdates,
        UpdateEventType.DELETE);
    topologyHolder.updateData(topologyUpdateEvent);
  }
@param osFamily provides OS to OS family lookup; may be null if OS family is ignored anyway (eg. for liveness check)
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java