@RequiresSession
  public Number getCountByStatus(Collection<HostRoleStatus> statuses) {
    TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery(
        "HostRoleCommandEntity.findCountByCommandStatuses", Number.class);

    query.setParameter("statuses", statuses);
    return daoUtils.selectSingle(query);
  }
Gets the number of commands in a particular status.

@param statuses
         the statuses to include (not {@code null}).
@return the count of commands in the given set of statuses.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java