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();
}
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;
}
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;
}
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();
}
Aggregations