@Transactional
  void unmapHostFromClusters(Host host, Set<Cluster> clusters) throws AmbariException {
    HostEntity hostEntity = null;

    if (clusters.isEmpty()) {
      return;
    }

    String hostname = host.getHostName();
    hostEntity = hostDAO.findByName(hostname);

    for (Cluster cluster : clusters) {
      long clusterId = cluster.getClusterId();
      if (LOG.isDebugEnabled()) {
        LOG.debug("Unmapping host {} from cluster {} (id={})", hostname, cluster.getClusterName(),
            clusterId);
      }

      unmapHostClusterEntities(hostname, cluster.getClusterId());

      getHostClustersMap().get(hostname).remove(cluster);
      getClusterHostsMap().get(cluster.getClusterName()).remove(host);
    }

    deleteConfigGroupHostMapping(hostEntity.getHostId());

    // Remove mapping of principals to the unmapped host
    kerberosKeytabPrincipalDAO.removeByHost(hostEntity.getHostId());
  }
Attempts to map the host to the cluster via clusterhostmapping table if not already present, and add a host_version
record for the cluster's currently applied (stack, version) if not already present.
@param hostname Host name
@param clusterName Cluster name
@throws AmbariException May throw a DuplicateResourceException.
ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java