コード例 #1
0
  public int getServerCount() {
    Query query = PersistenceUtility.createCountQuery(entityManager, Server.QUERY_FIND_ALL);

    try {
      long serverCount = (Long) query.getSingleResult();
      return (int) serverCount;
    } catch (NoResultException nre) {
      log.debug("Could not get count of cloud instances, returning 0...");
      return 0;
    }
  }
コード例 #2
0
  @RequiredPermissions({
    @RequiredPermission(Permission.MANAGE_SETTINGS),
    @RequiredPermission(Permission.MANAGE_INVENTORY)
  })
  public PageList<FailoverListDetails> getFailoverListDetailsByAgentId(
      Subject subject, int agentId, PageControl pc) {
    pc.initDefaultOrderingField("fld.ordinal");

    Query query =
        PersistenceUtility.createQueryWithOrderBy(
            entityManager, FailoverListDetails.QUERY_GET_VIA_AGENT_ID_WITH_SERVERS, pc);
    Query countQuery =
        PersistenceUtility.createCountQuery(
            entityManager, FailoverListDetails.QUERY_GET_VIA_AGENT_ID);

    query.setParameter("agentId", agentId);
    countQuery.setParameter("agentId", agentId);

    @SuppressWarnings("unchecked")
    List<FailoverListDetails> list = query.getResultList();
    long count = (Long) countQuery.getSingleResult();

    return new PageList<FailoverListDetails>(list, (int) count, pc);
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  @RequiredPermissions({
    @RequiredPermission(Permission.MANAGE_SETTINGS),
    @RequiredPermission(Permission.MANAGE_INVENTORY)
  })
  public PageList<ServerWithAgentCountComposite> getServerComposites(
      Subject subject, PageControl pc) {
    pc.initDefaultOrderingField("s.name");

    Query query =
        PersistenceUtility.createQueryWithOrderBy(
            entityManager, Server.QUERY_FIND_ALL_COMPOSITES, pc);

    List<ServerWithAgentCountComposite> results = query.getResultList();
    int count = getServerCount();

    return new PageList<ServerWithAgentCountComposite>(results, count, pc);
  }
コード例 #4
0
ファイル: SystemManagerBean.java プロジェクト: pilhuhn/rhq
 @Override
 public void enableHibernateStatistics() {
   PersistenceUtility.enableHibernateStatistics(
       this.entityManager, ManagementFactory.getPlatformMBeanServer());
 }