public List<Long> getRequestsByStatus(RequestStatus status, int maxResults, boolean ascOrder) {
    List<Long> requests = db.getRequestsByStatus(status, maxResults, ascOrder);

    for (Request logicalRequest : topologyManager.getRequests(Collections.emptySet())) {
      //todo: Request.getStatus() returns HostRoleStatus and we are comparing to RequestStatus
      //todo: for now just compare the names as RequestStatus names are a subset of HostRoleStatus names
      HostRoleStatus logicalRequestStatus = logicalRequest.getStatus();
      if (status == null || (logicalRequestStatus != null
          && logicalRequest.getStatus().name().equals(status.name()))) {
        requests.add(logicalRequest.getRequestId());
      }
    }
    return requests;
  }
Get first or last maxResults requests that are in the specified status

@param status
         Desired request status
@param maxResults
         maximal number of returned id's
@param ascOrder
         defines sorting order for database query result
@return First or last maxResults request id's if ascOrder is true or false,
        respectively
ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java