public float getFreeVirtualMemory() { if (getMemCommited() != null && getPhysicalMemMb() != null && getReservedMem() != null) { float freeMemory = (getMaxVdsMemoryOverCommit() * getPhysicalMemMb() / 100.0f) - getMemCommited() - getReservedMem(); // avoid negative values return freeMemory > 0 ? freeMemory : 0; } else { return 0; } }
private void updateMemory() { setFreeMemory(null); setUsedMemory(null); if (getEntity().getPhysicalMemMb() != null && getEntity().getUsageMemPercent() != null) { setUsedMemory((int) Math.round(getEntity().getPhysicalMemMb() * (getEntity().getUsageMemPercent() / 100.0))); setFreeMemory(getEntity().getPhysicalMemMb() - getUsedMemory()); } }
private void calculateFreeSchedulingMemoryCache() { if (getMemCommited() != null && getPhysicalMemMb() != null && getReservedMem() != null) { maxSchedulingMemory = getFreeVirtualMemory() - getPendingVmemSize(); // avoid negative values maxSchedulingMemory = maxSchedulingMemory > 0 ? maxSchedulingMemory : 0; } }
static VDS setUpStatisticalEntityExpectations(VDS entity, VdsStatistics statistics) { when(entity.getPhysicalMemMb()).thenReturn(5120); when(entity.getStatisticsData()).thenReturn(statistics); when(statistics.getUsageMemPercent()).thenReturn(20); when(statistics.getSwapFree()).thenReturn(25L); when(statistics.getSwapTotal()).thenReturn(30L); when(statistics.getMemAvailable()).thenReturn(35L); when(statistics.getMemShared()).thenReturn(38L); when(statistics.getKsmCpuPercent()).thenReturn(40); when(statistics.getCpuUser()).thenReturn(45.0); when(statistics.getCpuSys()).thenReturn(50.0); when(statistics.getCpuIdle()).thenReturn(55.0); when(statistics.getCpuLoad()).thenReturn(0.60); return entity; }
private void populateHostSummary() { CollapsiblePanelPresenterWidget hostSummaryPanel = collapsiblePanelProvider.get(); setInSlot(TYPE_revealHostSummary, hostSummaryPanel); List<VM> vmsWithVNuma = supportModel.getVmsWithvNumaNodeList(); int totalVNuma = 0; for (VM vm: vmsWithVNuma) { totalVNuma += vm.getvNumaNodeList().size(); } VDS selectedVds = supportModel.getHosts().getSelectedItem(); hostSummaryPanel.getView().setTitleWidget(getView().getHostSummaryTitle( selectedVds.getCpuThreads(), selectedVds.getUsageCpuPercent(), selectedVds.getPhysicalMemMb(), selectedVds.getMemFree().intValue(), supportModel.getNumaNodeList().size(), totalVNuma)); hostSummaryPanel.getView().addContentWidget(getView().getHostSummaryContent( selectedVds, supportModel)); getView().setHostSummaryPanel(hostSummaryPanel); } }
public List<Statistic> getStatistics(VDS entity) { VdsStatistics s = entity.getStatisticsData(); // if user queries host statistics before host installation completed, null values are possible (therefore added checks). long memTotal = entity.getPhysicalMemMb()==null ? 0 : entity.getPhysicalMemMb() * Mb; long memUsed = (s==null || s.getUsageMemPercent()==null) ? 0 : memTotal * s.getUsageMemPercent() / 100; List<Statistic> statistics = asList(setDatum(clone(MEM_TOTAL), memTotal), setDatum(clone(MEM_USED), memUsed), setDatum(clone(MEM_FREE), memTotal-memUsed), setDatum(clone(MEM_SHARED), (s==null || s.getMemShared()==null) ? 0 : s.getMemShared()*Mb), setDatum(clone(MEM_BUFFERS), 0), setDatum(clone(MEM_CACHED), 0), setDatum(clone(SWAP_TOTAL), (s==null || s.getSwapTotal()==null) ? 0 : s.getSwapTotal()*Mb), setDatum(clone(SWAP_FREE), (s==null || s.getSwapFree()==null) ? 0 : s.getSwapFree()*Mb), setDatum(clone(SWAP_USED), getSwapUsed(s)*Mb), setDatum(clone(SWAP_CACHED), 0), setDatum(clone(CPU_KSM), (s==null || s.getKsmCpuPercent()==null) ? 0 : s.getKsmCpuPercent()), setDatum(clone(CPU_USER), (s==null || s.getCpuUser()==null) ? 0 : s.getCpuUser()), setDatum(clone(CPU_SYS), (s==null || s.getCpuSys()==null) ? 0 : s.getCpuSys()), setDatum(clone(CPU_IDLE), (s==null || s.getCpuIdle()==null) ? 0 : s.getCpuIdle()), setDatum(clone(CPU_LOAD), (s==null || s.getCpuLoad()==null) ? 0 : s.getCpuLoad()/100), setDatum(clone(BOOT_TIME), (s==null || s.getBootTime()==null) ? 0 : s.getBootTime())); if (s != null && s.getHugePages() != null) { s.getHugePages().stream() .filter(page -> page.getAmount() != null) .map(this::createHugePagesFree) .forEach(statistics::add); } return statistics; }
setActiveVms(vds.getVmActive()); setPhysicalMemory(vds.getPhysicalMemMb()); setSwapTotal(vds.getSwapTotal()); setSwapFree(vds.getSwapFree());
model.setType(type); model.setMemory(Long.valueOf(entity.getPhysicalMemMb() == null ? 0 : entity.getPhysicalMemMb()
vds.setIfTotalSpeed(getIfTotalSpeed()); vds.setKvmEnabled(getKvmEnabled()); vds.setPhysicalMemMb(getPhysicalMemMb()); vds.setCpuIdle(getCpuIdle()); vds.setCpuLoad(getCpuLoad());