Search in sources :

Example 1 with DatabaseVO

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

the class SystemTest method testDatabase.

@Test
public void testDatabase() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("database").build();
    DatabaseVO databaseInfos = conn.get(systemUri, DatabaseVO.class);
    assertNotNull(databaseInfos);
    assertNotNull(databaseInfos.getConnectionInfos());
    assertNotNull(databaseInfos.getHibernateStatistics());
    // connections
    assertTrue(databaseInfos.getConnectionInfos().getActiveConnectionCount() >= 0);
    assertTrue(databaseInfos.getConnectionInfos().getCurrentConnectionCount() > 0);
    // hibernate
    assertTrue(databaseInfos.getHibernateStatistics().getFailedTransactionsCount() >= 0);
    assertTrue(databaseInfos.getHibernateStatistics().getOpenSessionsCount() >= 0);
    assertTrue(databaseInfos.getHibernateStatistics().getOptimisticFailureCount() >= 0);
    assertTrue(databaseInfos.getHibernateStatistics().getQueryExecutionCount() > 0);
    assertTrue(databaseInfos.getHibernateStatistics().getQueryExecutionMaxTime() > 0);
    assertNotNull(databaseInfos.getHibernateStatistics().getQueryExecutionMaxTimeQueryString());
    assertTrue(databaseInfos.getHibernateStatistics().getSuccessfulTransactionCount() > 0);
    assertTrue(databaseInfos.getHibernateStatistics().getTransactionsCount() > 0);
    conn.shutdown();
}
Also used : DatabaseVO(org.olat.restapi.system.vo.DatabaseVO) URI(java.net.URI) Test(org.junit.Test)

Example 2 with DatabaseVO

use of org.olat.restapi.system.vo.DatabaseVO 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 3 with DatabaseVO

use of org.olat.restapi.system.vo.DatabaseVO 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 DatabaseVO

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

the class SystemTest method testDatabase.

@Test
public void testDatabase() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("database").build();
    DatabaseVO databaseInfos = conn.get(systemUri, DatabaseVO.class);
    assertNotNull(databaseInfos);
    assertNotNull(databaseInfos.getConnectionInfos());
    assertNotNull(databaseInfos.getHibernateStatistics());
    // connections
    assertTrue(databaseInfos.getConnectionInfos().getActiveConnectionCount() >= 0);
    assertTrue(databaseInfos.getConnectionInfos().getCurrentConnectionCount() > 0);
    // hibernate
    assertTrue(databaseInfos.getHibernateStatistics().getFailedTransactionsCount() >= 0);
    assertTrue(databaseInfos.getHibernateStatistics().getOpenSessionsCount() >= 0);
    assertTrue(databaseInfos.getHibernateStatistics().getOptimisticFailureCount() >= 0);
    assertTrue(databaseInfos.getHibernateStatistics().getQueryExecutionCount() > 0);
    assertTrue(databaseInfos.getHibernateStatistics().getQueryExecutionMaxTime() > 0);
    assertNotNull(databaseInfos.getHibernateStatistics().getQueryExecutionMaxTimeQueryString());
    assertTrue(databaseInfos.getHibernateStatistics().getSuccessfulTransactionCount() > 0);
    assertTrue(databaseInfos.getHibernateStatistics().getTransactionsCount() > 0);
    conn.shutdown();
}
Also used : DatabaseVO(org.olat.restapi.system.vo.DatabaseVO) URI(java.net.URI) Test(org.junit.Test)

Aggregations

DatabaseVO (org.olat.restapi.system.vo.DatabaseVO)4 URI (java.net.URI)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Test (org.junit.Test)2 DatabaseStatsManager (org.olat.admin.sysinfo.manager.DatabaseStatsManager)2 DatabaseConnectionVO (org.olat.admin.sysinfo.model.DatabaseConnectionVO)2 HibernateStatisticsVO (org.olat.restapi.system.vo.HibernateStatisticsVO)2