Search in sources :

Example 1 with ThreadVOes

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

the class ThreadsWebService method getThreadsCpu.

@GET
@Path("cpu")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public synchronized Response getThreadsCpu() {
    List<ThreadView> threadViews = CoreSpringFactory.getImpl(ThreadInfosManager.class).getThreadViews();
    List<ThreadVO> threads = new ArrayList<ThreadVO>(threadViews.size());
    for (ThreadView view : threadViews) {
        threads.add(new ThreadVO(view));
    }
    Collections.sort(threads);
    ThreadVO[] threadVos = threads.toArray(new ThreadVO[threads.size()]);
    ThreadVOes voes = new ThreadVOes();
    voes.setThreads(threadVos);
    voes.setTotalCount(threadVos.length);
    return Response.ok(voes).build();
}
Also used : ThreadVOes(org.olat.restapi.system.vo.ThreadVOes) ThreadInfosManager(org.olat.admin.sysinfo.manager.ThreadInfosManager) ThreadVO(org.olat.restapi.system.vo.ThreadVO) ArrayList(java.util.ArrayList) ThreadView(org.olat.admin.sysinfo.model.ThreadView) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with ThreadVOes

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

the class SystemTest method testSystemThreadDetails.

@Test
public void testSystemThreadDetails() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("threads").path("cpu").build();
    ThreadVOes threadInfos = conn.get(systemUri, ThreadVOes.class);
    Assert.assertNotNull(threadInfos);
    Assert.assertNotNull(threadInfos.getThreads());
    Assert.assertTrue(threadInfos.getTotalCount() > 0);
    Assert.assertEquals(threadInfos.getTotalCount(), threadInfos.getThreads().length);
    ThreadVO threadVo = threadInfos.getThreads()[0];
    Assert.assertNotNull(threadVo.getName());
    Assert.assertTrue(threadVo.getCpuTime() >= 0);
    Assert.assertTrue(threadVo.getCpuUsage() >= 0.0f);
    Assert.assertTrue(threadVo.getId() > 0l);
    conn.shutdown();
}
Also used : ThreadVOes(org.olat.restapi.system.vo.ThreadVOes) ThreadVO(org.olat.restapi.system.vo.ThreadVO) URI(java.net.URI) Test(org.junit.Test)

Example 3 with ThreadVOes

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

the class ThreadsWebService method getThreadsCpu.

@GET
@Path("cpu")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public synchronized Response getThreadsCpu() {
    List<ThreadView> threadViews = CoreSpringFactory.getImpl(ThreadInfosManager.class).getThreadViews();
    List<ThreadVO> threads = new ArrayList<ThreadVO>(threadViews.size());
    for (ThreadView view : threadViews) {
        threads.add(new ThreadVO(view));
    }
    Collections.sort(threads);
    ThreadVO[] threadVos = threads.toArray(new ThreadVO[threads.size()]);
    ThreadVOes voes = new ThreadVOes();
    voes.setThreads(threadVos);
    voes.setTotalCount(threadVos.length);
    return Response.ok(voes).build();
}
Also used : ThreadVOes(org.olat.restapi.system.vo.ThreadVOes) ThreadInfosManager(org.olat.admin.sysinfo.manager.ThreadInfosManager) ThreadVO(org.olat.restapi.system.vo.ThreadVO) ArrayList(java.util.ArrayList) ThreadView(org.olat.admin.sysinfo.model.ThreadView) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with ThreadVOes

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

the class SystemTest method testSystemThreadDetails.

@Test
public void testSystemThreadDetails() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("threads").path("cpu").build();
    ThreadVOes threadInfos = conn.get(systemUri, ThreadVOes.class);
    Assert.assertNotNull(threadInfos);
    Assert.assertNotNull(threadInfos.getThreads());
    Assert.assertTrue(threadInfos.getTotalCount() > 0);
    Assert.assertEquals(threadInfos.getTotalCount(), threadInfos.getThreads().length);
    ThreadVO threadVo = threadInfos.getThreads()[0];
    Assert.assertNotNull(threadVo.getName());
    Assert.assertTrue(threadVo.getCpuTime() >= 0);
    Assert.assertTrue(threadVo.getCpuUsage() >= 0.0f);
    Assert.assertTrue(threadVo.getId() > 0l);
    conn.shutdown();
}
Also used : ThreadVOes(org.olat.restapi.system.vo.ThreadVOes) ThreadVO(org.olat.restapi.system.vo.ThreadVO) URI(java.net.URI) Test(org.junit.Test)

Aggregations

ThreadVO (org.olat.restapi.system.vo.ThreadVO)4 ThreadVOes (org.olat.restapi.system.vo.ThreadVOes)4 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Test (org.junit.Test)2 ThreadInfosManager (org.olat.admin.sysinfo.manager.ThreadInfosManager)2 ThreadView (org.olat.admin.sysinfo.model.ThreadView)2