Search in sources :

Example 1 with HibernateStatisticsVO

use of org.olat.restapi.system.vo.HibernateStatisticsVO in project OpenOLAT by OpenOLAT.

the class DatabaseWebService method getDatabaseStatistics.

/**
 * Return the statistics about database and hibernate
 *
 * @response.representation.200.qname {http://www.example.com}runtimeVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The version of the instance
 * @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_DATABASEVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @param request The HTTP request
 * @return The informations about runtime, uptime, classes loaded, memory summary...
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getDatabaseStatistics() {
    DatabaseConnectionVO connections = CoreSpringFactory.getImpl(DatabaseStatsManager.class).getConnectionInfos();
    HibernateStatisticsVO hibernateStats = getHibernateStatistics();
    DatabaseVO vo = new DatabaseVO();
    vo.setConnectionInfos(connections);
    vo.setHibernateStatistics(hibernateStats);
    return Response.ok(vo).build();
}
Also used : DatabaseStatsManager(org.olat.admin.sysinfo.manager.DatabaseStatsManager) DatabaseVO(org.olat.restapi.system.vo.DatabaseVO) HibernateStatisticsVO(org.olat.restapi.system.vo.HibernateStatisticsVO) DatabaseConnectionVO(org.olat.admin.sysinfo.model.DatabaseConnectionVO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with HibernateStatisticsVO

use of org.olat.restapi.system.vo.HibernateStatisticsVO in project openolat by klemens.

the class DatabaseWebService method getHibernateStatistics.

private HibernateStatisticsVO getHibernateStatistics() {
    Statistics statistics = DBFactory.getInstance().getStatistics();
    if (!statistics.isStatisticsEnabled()) {
        return null;
    }
    HibernateStatisticsVO stats = new HibernateStatisticsVO();
    stats.setOpenSessionsCount(statistics.getSessionOpenCount());
    stats.setTransactionsCount(statistics.getTransactionCount());
    stats.setSuccessfulTransactionCount(statistics.getSuccessfulTransactionCount());
    stats.setFailedTransactionsCount(statistics.getTransactionCount() - statistics.getSuccessfulTransactionCount());
    stats.setOptimisticFailureCount(statistics.getOptimisticFailureCount());
    stats.setQueryExecutionCount(statistics.getQueryExecutionCount());
    stats.setQueryExecutionMaxTime(statistics.getQueryExecutionMaxTime());
    stats.setQueryExecutionMaxTimeQueryString(statistics.getQueryExecutionMaxTimeQueryString());
    return stats;
}
Also used : HibernateStatisticsVO(org.olat.restapi.system.vo.HibernateStatisticsVO) Statistics(org.hibernate.stat.Statistics)

Example 3 with HibernateStatisticsVO

use of org.olat.restapi.system.vo.HibernateStatisticsVO in project openolat by klemens.

the class DatabaseWebService method getDatabaseStatistics.

/**
 * Return the statistics about database and hibernate
 *
 * @response.representation.200.qname {http://www.example.com}runtimeVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The version of the instance
 * @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_DATABASEVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @param request The HTTP request
 * @return The informations about runtime, uptime, classes loaded, memory summary...
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getDatabaseStatistics() {
    DatabaseConnectionVO connections = CoreSpringFactory.getImpl(DatabaseStatsManager.class).getConnectionInfos();
    HibernateStatisticsVO hibernateStats = getHibernateStatistics();
    DatabaseVO vo = new DatabaseVO();
    vo.setConnectionInfos(connections);
    vo.setHibernateStatistics(hibernateStats);
    return Response.ok(vo).build();
}
Also used : DatabaseStatsManager(org.olat.admin.sysinfo.manager.DatabaseStatsManager) DatabaseVO(org.olat.restapi.system.vo.DatabaseVO) HibernateStatisticsVO(org.olat.restapi.system.vo.HibernateStatisticsVO) DatabaseConnectionVO(org.olat.admin.sysinfo.model.DatabaseConnectionVO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with HibernateStatisticsVO

use of org.olat.restapi.system.vo.HibernateStatisticsVO in project OpenOLAT by OpenOLAT.

the class DatabaseWebService method getHibernateStatistics.

private HibernateStatisticsVO getHibernateStatistics() {
    Statistics statistics = DBFactory.getInstance().getStatistics();
    if (!statistics.isStatisticsEnabled()) {
        return null;
    }
    HibernateStatisticsVO stats = new HibernateStatisticsVO();
    stats.setOpenSessionsCount(statistics.getSessionOpenCount());
    stats.setTransactionsCount(statistics.getTransactionCount());
    stats.setSuccessfulTransactionCount(statistics.getSuccessfulTransactionCount());
    stats.setFailedTransactionsCount(statistics.getTransactionCount() - statistics.getSuccessfulTransactionCount());
    stats.setOptimisticFailureCount(statistics.getOptimisticFailureCount());
    stats.setQueryExecutionCount(statistics.getQueryExecutionCount());
    stats.setQueryExecutionMaxTime(statistics.getQueryExecutionMaxTime());
    stats.setQueryExecutionMaxTimeQueryString(statistics.getQueryExecutionMaxTimeQueryString());
    return stats;
}
Also used : HibernateStatisticsVO(org.olat.restapi.system.vo.HibernateStatisticsVO) Statistics(org.hibernate.stat.Statistics)

Aggregations

HibernateStatisticsVO (org.olat.restapi.system.vo.HibernateStatisticsVO)4 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Statistics (org.hibernate.stat.Statistics)2 DatabaseStatsManager (org.olat.admin.sysinfo.manager.DatabaseStatsManager)2 DatabaseConnectionVO (org.olat.admin.sysinfo.model.DatabaseConnectionVO)2 DatabaseVO (org.olat.restapi.system.vo.DatabaseVO)2