private void createHostRequests(ClusterTopology topology,
                                  TopologyLogicalRequestEntity requestEntity) {

    Collection<TopologyHostGroupEntity> hostGroupEntities = requestEntity.getTopologyRequestEntity().getTopologyHostGroupEntities();
    Map<String, Set<String>> allReservedHostNamesByHostGroups = getReservedHostNamesByHostGroupName(hostGroupEntities);
    Map<String, Set<String>> pendingReservedHostNamesByHostGroups = new HashMap<>(allReservedHostNamesByHostGroups);

    for (TopologyHostRequestEntity hostRequestEntity : requestEntity.getTopologyHostRequestEntities()) {
      TopologyHostGroupEntity hostGroupEntity = hostRequestEntity.getTopologyHostGroupEntity();
      String hostGroupName = hostGroupEntity.getName();
      String hostName = hostRequestEntity.getHostName();

      if (hostName != null && pendingReservedHostNamesByHostGroups.containsKey(hostGroupName)) {
        Set<String> pendingReservedHostNamesInHostGroup = pendingReservedHostNamesByHostGroups.get(hostGroupName);

        if (pendingReservedHostNamesInHostGroup != null) {
          pendingReservedHostNamesInHostGroup.remove(hostName);
        }
      }
    }

    boolean skipFailure = topology.getBlueprint().shouldSkipFailure();
    for (TopologyHostRequestEntity hostRequestEntity : requestEntity.getTopologyHostRequestEntities()) {
      Long hostRequestId = hostRequestEntity.getId();
      synchronized (hostIdCounter) {
        if (hostIdCounter.get() <= hostRequestId) {
          hostIdCounter.set(hostRequestId + 1);
        }
      }
      TopologyHostGroupEntity hostGroupEntity = hostRequestEntity.getTopologyHostGroupEntity();
      Set<String> pendingReservedHostsInGroup = pendingReservedHostNamesByHostGroups.get(hostGroupEntity.getName());

      // get next host name from pending host names
      String reservedHostName = Iterables.getFirst(pendingReservedHostsInGroup, null);


      //todo: move predicate processing to host request
      HostRequest hostRequest = new HostRequest(getRequestId(), hostRequestId,
          reservedHostName, topology, hostRequestEntity, skipFailure);

      allHostRequests.add(hostRequest);
      if (! hostRequest.isCompleted()) {
        if (reservedHostName != null) {
          requestsWithReservedHosts.put(reservedHostName, hostRequest);
          pendingReservedHostsInGroup.remove(reservedHostName);
          LOG.info("LogicalRequest.createHostRequests: created new request for a reserved request ID = {} for host name = {}",
            hostRequest.getId(), reservedHostName);
        } else {
          outstandingHostRequests.add(hostRequest);
          LOG.info("LogicalRequest.createHostRequests: created new outstanding host request ID = {}", hostRequest.getId());
        }
      }
    }
  }
Returns if all the tasks in the logical request have completed state.
ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java