use of org.ovirt.engine.core.common.businessentities.HugePage in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method updateVDSStatisticsData.
public static void updateVDSStatisticsData(VDS vds, Map<String, Object> struct) {
// ------------- vds memory usage ---------------------------
vds.setUsageMemPercent(assignIntValue(struct, VdsProperties.mem_usage));
// ------------- vds network statistics ---------------------
Map<String, Object> interfaces = (Map<String, Object>) struct.get(VdsProperties.NETWORK);
if (interfaces != null) {
int networkUsage = 0;
Map<String, VdsNetworkInterface> nicsByName = Entities.entitiesByName(vds.getInterfaces());
NetworkStatisticsBuilder statsBuilder = new NetworkStatisticsBuilder();
for (Entry<String, Object> entry : interfaces.entrySet()) {
if (nicsByName.containsKey(entry.getKey())) {
VdsNetworkInterface existingIface = nicsByName.get(entry.getKey());
existingIface.setVdsId(vds.getId());
Map<String, Object> dict = (Map<String, Object>) entry.getValue();
VdsNetworkInterface reportedIface = new VdsNetworkInterface();
extractInterfaceStatistics(dict, reportedIface);
statsBuilder.updateExistingInterfaceStatistics(existingIface, reportedIface);
existingIface.getStatistics().setStatus(assignInterfaceStatusValue(dict, VdsProperties.iface_status));
if (!NetworkCommonUtils.isVlan(existingIface) && !existingIface.isPartOfBond()) {
Double ifaceUsage = computeInterfaceUsage(existingIface);
if (ifaceUsage != null) {
networkUsage = (int) Math.max(networkUsage, ifaceUsage);
}
}
}
}
vds.setUsageNetworkPercent(networkUsage);
}
// ----------- vds cpu statistics info ---------------------
vds.setCpuSys(assignDoubleValue(struct, VdsProperties.cpu_sys));
vds.setCpuUser(assignDoubleValue(struct, VdsProperties.cpu_user));
if (vds.getCpuSys() != null && vds.getCpuUser() != null) {
vds.setUsageCpuPercent((int) (vds.getCpuSys() + vds.getCpuUser()));
}
// CPU load reported by VDSM is in uptime-style format, i.e. normalized
// to unity, so that say an 8% load is reported as 0.08
Double d = assignDoubleValue(struct, VdsProperties.cpu_load);
d = (d != null) ? d : 0;
vds.setCpuLoad(d.doubleValue() * 100.0);
vds.setCpuIdle(assignDoubleValue(struct, VdsProperties.cpu_idle));
vds.setMemAvailable(assignLongValue(struct, VdsProperties.mem_available));
vds.setMemFree(assignLongValue(struct, VdsProperties.memFree));
vds.setMemShared(assignLongValue(struct, VdsProperties.mem_shared));
vds.setSwapFree(assignLongValue(struct, VdsProperties.swap_free));
vds.setSwapTotal(assignLongValue(struct, VdsProperties.swap_total));
vds.setKsmCpuPercent(assignIntValue(struct, VdsProperties.ksm_cpu_percent));
vds.setKsmPages(assignLongValue(struct, VdsProperties.ksm_pages));
vds.setKsmState(assignBoolValue(struct, VdsProperties.ksm_state));
// dynamic data got from GetVdsStats
if (struct.containsKey(VdsProperties.transparent_huge_pages_state)) {
vds.setTransparentHugePagesState(EnumUtils.valueOf(VdsTransparentHugePagesState.class, struct.get(VdsProperties.transparent_huge_pages_state).toString(), true));
}
if (struct.containsKey(VdsProperties.anonymous_transparent_huge_pages)) {
vds.setAnonymousHugePages(assignIntValue(struct, VdsProperties.anonymous_transparent_huge_pages));
}
if (struct.containsKey(VdsProperties.hugepages)) {
Object hugepages = struct.get(VdsProperties.hugepages);
if (hugepages instanceof Map) {
Map<String, Map<String, String>> hugepagesMap = (Map<String, Map<String, String>>) hugepages;
List<HugePage> parsedHugePages = hugepagesMap.entrySet().stream().map(entry -> new HugePage(Integer.parseInt(entry.getKey()), assignIntValue(entry.getValue(), VdsProperties.free_hugepages))).collect(Collectors.toList());
vds.setHugePages(parsedHugePages);
}
}
vds.setNetConfigDirty(assignBoolValue(struct, VdsProperties.netConfigDirty));
vds.setImagesLastCheck(assignDoubleValue(struct, VdsProperties.images_last_check));
vds.setImagesLastDelay(assignDoubleValue(struct, VdsProperties.images_last_delay));
Integer vm_count = assignIntValue(struct, VdsProperties.vm_count);
vds.setVmCount(vm_count == null ? 0 : vm_count);
vds.setVmActive(assignIntValue(struct, VdsProperties.vm_active));
vds.setVmMigrating(assignIntValue(struct, VdsProperties.vm_migrating));
Integer inOutMigrations;
inOutMigrations = assignIntValue(struct, VdsProperties.INCOMING_VM_MIGRATIONS);
if (inOutMigrations != null) {
vds.setIncomingMigrations(inOutMigrations);
} else {
// TODO remove in 4.x when all hosts will send in/out migrations separately
vds.setIncomingMigrations(-1);
}
inOutMigrations = assignIntValue(struct, VdsProperties.OUTGOING_VM_MIGRATIONS);
if (inOutMigrations != null) {
vds.setOutgoingMigrations(inOutMigrations);
} else {
// TODO remove in 4.x when all hosts will send in/out migrations separately
vds.setOutgoingMigrations(-1);
}
updateVDSDomainData(vds, struct);
updateLocalDisksUsage(vds, struct);
// hosted engine
Integer haScore = null;
Boolean haIsConfigured = null;
Boolean haIsActive = null;
Boolean haGlobalMaint = null;
Boolean haLocalMaint = null;
if (struct.containsKey(VdsProperties.ha_stats)) {
Map<String, Object> haStats = (Map<String, Object>) struct.get(VdsProperties.ha_stats);
if (haStats != null) {
haScore = assignIntValue(haStats, VdsProperties.ha_stats_score);
haIsConfigured = assignBoolValue(haStats, VdsProperties.ha_stats_is_configured);
haIsActive = assignBoolValue(haStats, VdsProperties.ha_stats_is_active);
haGlobalMaint = assignBoolValue(haStats, VdsProperties.ha_stats_global_maintenance);
haLocalMaint = assignBoolValue(haStats, VdsProperties.ha_stats_local_maintenance);
}
} else {
haScore = assignIntValue(struct, VdsProperties.ha_score);
// prior to 3.4, haScore was returned if ha was installed; assume active if > 0
if (haScore != null) {
haIsConfigured = true;
haIsActive = haScore > 0;
}
}
vds.setHighlyAvailableScore(haScore != null ? haScore : 0);
vds.setHighlyAvailableIsConfigured(haIsConfigured != null ? haIsConfigured : false);
vds.setHighlyAvailableIsActive(haIsActive != null ? haIsActive : false);
vds.setHighlyAvailableGlobalMaintenance(haGlobalMaint != null ? haGlobalMaint : false);
vds.setHighlyAvailableLocalMaintenance(haLocalMaint != null ? haLocalMaint : false);
vds.setBootTime(assignLongValue(struct, VdsProperties.bootTime));
updateNumaStatisticsData(vds, struct);
updateV2VJobs(vds, struct);
}
use of org.ovirt.engine.core.common.businessentities.HugePage in project ovirt-engine by oVirt.
the class HugePagesFilterPolicyUnitTest method testHugePagesWrongSizeOnHost.
@Test
public void testHugePagesWrongSizeOnHost() throws Exception {
vm.setCustomProperties("hugepages=1024");
host1.setHugePages(Collections.singletonList(new HugePage(2048, 50)));
HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
assertThat(hosts).isEmpty();
}
use of org.ovirt.engine.core.common.businessentities.HugePage in project ovirt-engine by oVirt.
the class HugePagesFilterPolicyUnitTest method testEnoughFreeHugePagesOnHostSimple.
@Test
public void testEnoughFreeHugePagesOnHostSimple() throws Exception {
vm.setCustomProperties("hugepages=1024");
host1.setHugePages(Collections.singletonList(new HugePage(1024, 1024)));
HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
assertThat(hosts).isNotEmpty().contains(host1);
}
use of org.ovirt.engine.core.common.businessentities.HugePage in project ovirt-engine by oVirt.
the class HugePagesFilterPolicyUnitTest method testNotEnoughFreeHugePagesOnHost.
@Test
public void testNotEnoughFreeHugePagesOnHost() throws Exception {
vm.setCustomProperties("hugepages=1024");
host1.setHugePages(Collections.singletonList(new HugePage(1024, 50)));
HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
assertThat(hosts).isEmpty();
}
Aggregations