Integer usageHistoryLimit = Config.getValue(ConfigValues.UsageHistoryLimit); setElapsedTime(vmStatistics.getElapsedTime()); setDisksUsage(vmStatistics.getDisksUsage()); setCpuSys(vmStatistics.getCpuSys()); setCpuUser(vmStatistics.getCpuUser()); if ((getCpuSys() != null) && (getCpuUser() != null)) { Double percent = (getCpuSys() + getCpuUser()) / numOfCpus; setUsageCpuPercent(percent.intValue()); if (getUsageCpuPercent() != null && getUsageCpuPercent() > 100) { setUsageCpuPercent(100); addCpuUsageHistory(getUsageCpuPercent(), usageHistoryLimit); setUsageMemPercent(vmStatistics.getUsageMemPercent()); addMemoryUsageHistory(getUsageMemPercent(), usageHistoryLimit); setGuestMemoryBuffered(vmStatistics.getGuestMemoryBuffered()); setGuestMemoryCached(vmStatistics.getGuestMemoryCached()); setGuestMemoryFree(vmStatistics.getGuestMemoryFree()); setMigrationProgressPercent(vmStatistics.getMigrationProgressPercent());
@Override protected VmStatistics generateNewEntity() { VmStatistics newVmStatistics = new VmStatistics(); newVmStatistics.setId(FixturesTool.VM_RHEL5_POOL_50_ID); newVmStatistics.setCpuSys(22.0D); newVmStatistics.setCpuUser(35.0D); newVmStatistics.setUsageCpuPercent(44); newVmStatistics.setUsageMemPercent(67); newVmStatistics.setDisksUsage("disk_usage"); newVmStatistics.setGuestMemoryBuffered(32L); newVmStatistics.setGuestMemoryCached(34L); return newVmStatistics; }
@Override protected MapSqlParameterSource createFullParametersMapper(VmStatistics statistics) { return createIdParameterMapper(statistics.getId()) .addValue("cpu_sys", statistics.getCpuSys()) .addValue("cpu_user", statistics.getCpuUser()) .addValue("elapsed_time", statistics.getElapsedTime()) .addValue("usage_cpu_percent", statistics.getUsageCpuPercent()) .addValue("usage_mem_percent", statistics.getUsageMemPercent()) .addValue("usage_network_percent", statistics.getUsageNetworkPercent()) .addValue("disks_usage", statistics.getDisksUsage()) .addValue("guest_mem_buffered", statistics.getGuestMemoryBuffered()) .addValue("guest_mem_cached", statistics.getGuestMemoryCached()); }
VmStatistics vmStatistics = new VmStatistics(); vmStatistics.setCpuSys(0D); vmStatistics.setCpuUser(0D); vmStatistics.setElapsedTime(0D); vmStatistics.setUsageCpuPercent(0); vmStatistics.setUsageMemPercent(0); vmStatistics.setUsageNetworkPercent(0); vm.setStatisticsData(vmStatistics); vm.setMigrationProgressPercent(50);
static org.ovirt.engine.core.common.businessentities.VM setUpStatisticalEntityExpectations( org.ovirt.engine.core.common.businessentities.VM entity, VmStatistics statistics) { entity.setVmMemSizeMb(10); entity.setStatisticsData(statistics); statistics.setUsageMemPercent(20); statistics.setCpuUser(30.0); statistics.setCpuSys(40.0); statistics.setUsageCpuPercent(50); statistics.setDisksUsage("{}"); statistics.setElapsedTime(600.0); entity.setMigrationProgressPercent(50); entity.setGuestMemoryFree(5120L); entity.setGuestMemoryBuffered(2048L); entity.setGuestMemoryCached(1024L); entity.setUsageNetworkPercent(10); entity.setCpuUsageHistory(Arrays.asList(1, 2, 3)); entity.setMemoryUsageHistory(Arrays.asList(4, 5, 6)); entity.setNetworkUsageHistory(Arrays.asList(7, 8, 9)); return entity; }
public List<Statistic> getStatistics(org.ovirt.engine.core.common.businessentities.VM entity) { VmStatistics s = entity.getStatisticsData(); long mem = entity.getMemSizeMb() * Mb; long memUsedByCent = s.getUsageMemPercent() == null ? 0 : mem * s.getUsageMemPercent(); long memFree = entity.getGuestMemoryFree() == null ? 0 : entity.getGuestMemoryFree() * Kb; long memBuffered = entity.getGuestMemoryBuffered() == null ? 0 : entity.getGuestMemoryBuffered() * Kb; long migrationProgress = entity.getMigrationProgressPercent() == null ? 0 : entity.getMigrationProgressPercent(); int networkUsagePercent = entity.getUsageNetworkPercent() == null ? 0 : entity.getUsageNetworkPercent(); String disksUsage = s.getDisksUsage() == null ? "" : s.getDisksUsage(); long elapsedTime = s.getElapsedTime() == null ? 0 : s.getElapsedTime().intValue(); Double cpuUser = s.getCpuUser() == null ? zero : s.getCpuUser(); Double cpuSys = s.getCpuSys() == null ? zero : s.getCpuSys();
@Override protected org.ovirt.engine.core.common.businessentities.VM getInverse(VmStatic to) { VmStatistics statistics = new VmStatistics(); statistics.setCpuUser(10.0); statistics.setCpuSys(20.0); VmDynamic dynamic = new VmDynamic(); dynamic.setStatus(VMStatus.Up); dynamic.setBootSequence(to.getDefaultBootSequence()); dynamic.getGraphicsInfos().put(GraphicsType.SPICE, new GraphicsInfo()); org.ovirt.engine.core.common.businessentities.VM ret = new org.ovirt.engine.core.common.businessentities.VM(to, dynamic, statistics); ret.setUsageMemPercent(50); return ret; }
@Test public void testUpdateAll() { VmStatistics existingVm = dao.get(FixturesTool.VM_RHEL5_POOL_57); VmStatistics existingVm2 = dao.get(FixturesTool.VM_RHEL5_POOL_51); existingVm.setCpuSys(50.0); existingVm2.setCpuUser(50.0); dao.updateAll(Arrays.asList(existingVm, existingVm2)); assertEquals(existingVm, dao.get(existingVm.getId())); assertEquals(existingVm2, dao.get(existingVm2.getId())); } }
@Override protected void updateExistingEntity() { existingEntity.setUsageMemPercent(17); existingEntity.setDisksUsage("java.util.map { [ ] }"); }
private void createHostedEngineVm(Guid id) { VmStatic vmStatic = new VmStatic(); vmStatic.setId(id); vmStatic.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI); vmStatic.setName("HostedEngine"); vmStatic.setOrigin(OriginType.HOSTED_ENGINE); vmStatic.setCpuProfileId(FixturesTool.CPU_PROFILE_1); vmStaticDao.save(vmStatic); VmDynamic vmDynamic = new VmDynamic(); vmDynamic.setId(id); vmDynamicDao.save(vmDynamic); VmStatistics vmStatistics = new VmStatistics(); vmStatistics.setId(id); vmStatisticsDao.save(vmStatistics); }
public VM() { this(new VmStatic(), new VmDynamic(), new VmStatistics()); }
public void setCpuUser(Double value) { this.vmStatistics.setCpuUser(value); }
public void setCpuSys(Double value) { this.vmStatistics.setCpuSys(value); }
public Double getCpuUser() { return this.vmStatistics.getCpuUser(); }
public Double getElapsedTime() { return this.vmStatistics.getElapsedTime(); }
public Integer getUsageMemPercent() { return this.vmStatistics.getUsageMemPercent(); }
public void setUsageCpuPercent(Integer value) { this.vmStatistics.setUsageCpuPercent(value); }
public Double getCpuSys() { return this.vmStatistics.getCpuSys(); }
protected VM mapToVM(VmPool model, VmTemplate template, Cluster cluster) { // apply template VmStatic fromTemplate = getMapper(VmTemplate.class, VmStatic.class).map(template, null); VmStatic fromInstanceType = null; if (model.isSetInstanceType()) { org.ovirt.engine.core.common.businessentities.InstanceType instanceType = loadInstanceType(model); fromTemplate.setInstanceTypeId(instanceType.getId()); fromInstanceType = VmMapper.map(instanceType, fromTemplate, cluster.getCompatibilityVersion()); fromInstanceType.setInstanceTypeId(instanceType.getId()); } // override with client-provided data VM vm = new VM(getMapper(VmPool.class, VmStatic.class).map( model, fromInstanceType != null ? fromInstanceType : fromTemplate), new VmDynamic(), new VmStatistics()); return vm; }