Search in sources :

Example 1 with MemoryStatisticsVO

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

the class SystemTest method testRuntimeMemoryStatsSystem.

@Test
public void testRuntimeMemoryStatsSystem() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("runtime").path("memory").build();
    MemoryStatisticsVO memoryInfos = conn.get(systemUri, MemoryStatisticsVO.class);
    assertNotNull(memoryInfos);
    assertTrue(memoryInfos.getFreeMemory() > 0);
    assertTrue(memoryInfos.getTotalMemory() > 0);
    assertTrue(memoryInfos.getUsedMemory() > 0);
    assertTrue(memoryInfos.getInitHeap() >= 0);
    assertTrue(memoryInfos.getInitNonHeap() >= 0);
    assertTrue(memoryInfos.getUsedHeap() > 0);
    assertTrue(memoryInfos.getUsedNonHeap() > 0);
    assertTrue(memoryInfos.getCommittedHeap() > 0);
    assertTrue(memoryInfos.getCommittedNonHeap() > 0);
    assertTrue(memoryInfos.getMaxHeap() > 0);
    assertTrue(memoryInfos.getMaxNonHeap() >= 0);
    conn.shutdown();
}
Also used : MemoryStatisticsVO(org.olat.restapi.system.vo.MemoryStatisticsVO) URI(java.net.URI) Test(org.junit.Test)

Example 2 with MemoryStatisticsVO

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

the class RuntimeWebService method getMemoryStatisticsVO.

private MemoryStatisticsVO getMemoryStatisticsVO() {
    MemoryStatisticsVO stats = new MemoryStatisticsVO();
    Runtime runtime = Runtime.getRuntime();
    stats.setUsedMemory((runtime.totalMemory() - runtime.freeMemory()) / mb);
    stats.setFreeMemory(runtime.freeMemory() / mb);
    stats.setTotalMemory(runtime.totalMemory() / mb);
    MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
    stats.setInitHeap(memoryBean.getHeapMemoryUsage().getInit() / mb);
    stats.setInitNonHeap(memoryBean.getNonHeapMemoryUsage().getInit() / mb);
    stats.setUsedHeap(memoryBean.getHeapMemoryUsage().getUsed() / mb);
    stats.setUsedNonHeap(memoryBean.getNonHeapMemoryUsage().getUsed() / mb);
    stats.setCommittedHeap(memoryBean.getHeapMemoryUsage().getCommitted() / mb);
    stats.setCommittedNonHeap(memoryBean.getNonHeapMemoryUsage().getCommitted() / mb);
    stats.setMaxHeap(memoryBean.getHeapMemoryUsage().getMax() / mb);
    stats.setMaxNonHeap(memoryBean.getNonHeapMemoryUsage().getMax() / mb);
    long collectionTime = 0l;
    long collectionCount = 0l;
    List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean gcBean : gcBeans) {
        collectionCount += gcBean.getCollectionCount();
        collectionTime += gcBean.getCollectionTime();
    }
    stats.setGarbageCollectionCount(collectionCount);
    stats.setGarbageCollectionTime(collectionTime);
    return stats;
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) MemoryStatisticsVO(org.olat.restapi.system.vo.MemoryStatisticsVO)

Example 3 with MemoryStatisticsVO

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

the class RuntimeWebService method getMemoryStatisticsVO.

private MemoryStatisticsVO getMemoryStatisticsVO() {
    MemoryStatisticsVO stats = new MemoryStatisticsVO();
    Runtime runtime = Runtime.getRuntime();
    stats.setUsedMemory((runtime.totalMemory() - runtime.freeMemory()) / mb);
    stats.setFreeMemory(runtime.freeMemory() / mb);
    stats.setTotalMemory(runtime.totalMemory() / mb);
    MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
    stats.setInitHeap(memoryBean.getHeapMemoryUsage().getInit() / mb);
    stats.setInitNonHeap(memoryBean.getNonHeapMemoryUsage().getInit() / mb);
    stats.setUsedHeap(memoryBean.getHeapMemoryUsage().getUsed() / mb);
    stats.setUsedNonHeap(memoryBean.getNonHeapMemoryUsage().getUsed() / mb);
    stats.setCommittedHeap(memoryBean.getHeapMemoryUsage().getCommitted() / mb);
    stats.setCommittedNonHeap(memoryBean.getNonHeapMemoryUsage().getCommitted() / mb);
    stats.setMaxHeap(memoryBean.getHeapMemoryUsage().getMax() / mb);
    stats.setMaxNonHeap(memoryBean.getNonHeapMemoryUsage().getMax() / mb);
    long collectionTime = 0l;
    long collectionCount = 0l;
    List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean gcBean : gcBeans) {
        collectionCount += gcBean.getCollectionCount();
        collectionTime += gcBean.getCollectionTime();
    }
    stats.setGarbageCollectionCount(collectionCount);
    stats.setGarbageCollectionTime(collectionTime);
    return stats;
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) MemoryStatisticsVO(org.olat.restapi.system.vo.MemoryStatisticsVO)

Example 4 with MemoryStatisticsVO

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

the class SystemTest method testRuntimeMemoryStatsSystem.

@Test
public void testRuntimeMemoryStatsSystem() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("runtime").path("memory").build();
    MemoryStatisticsVO memoryInfos = conn.get(systemUri, MemoryStatisticsVO.class);
    assertNotNull(memoryInfos);
    assertTrue(memoryInfos.getFreeMemory() > 0);
    assertTrue(memoryInfos.getTotalMemory() > 0);
    assertTrue(memoryInfos.getUsedMemory() > 0);
    assertTrue(memoryInfos.getInitHeap() >= 0);
    assertTrue(memoryInfos.getInitNonHeap() >= 0);
    assertTrue(memoryInfos.getUsedHeap() > 0);
    assertTrue(memoryInfos.getUsedNonHeap() > 0);
    assertTrue(memoryInfos.getCommittedHeap() > 0);
    assertTrue(memoryInfos.getCommittedNonHeap() > 0);
    assertTrue(memoryInfos.getMaxHeap() > 0);
    assertTrue(memoryInfos.getMaxNonHeap() >= 0);
    conn.shutdown();
}
Also used : MemoryStatisticsVO(org.olat.restapi.system.vo.MemoryStatisticsVO) URI(java.net.URI) Test(org.junit.Test)

Aggregations

MemoryStatisticsVO (org.olat.restapi.system.vo.MemoryStatisticsVO)4 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)2 MemoryMXBean (java.lang.management.MemoryMXBean)2 URI (java.net.URI)2 Test (org.junit.Test)2