Search in sources :

Example 6 with HugePage

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);
}
Also used : RpmVersion(org.ovirt.engine.core.compat.RpmVersion) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics) Matcher(java.util.regex.Matcher) EnumUtils(org.ovirt.engine.core.common.utils.EnumUtils) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmJob(org.ovirt.engine.core.common.businessentities.VmJob) Path(java.nio.file.Path) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) NameServer(org.ovirt.engine.core.common.businessentities.network.NameServer) Set(java.util.Set) CpuStatistics(org.ovirt.engine.core.common.businessentities.CpuStatistics) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) AutoNumaBalanceStatus(org.ovirt.engine.core.common.businessentities.AutoNumaBalanceStatus) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) Stream(java.util.stream.Stream) VDSDomainsData(org.ovirt.engine.core.common.businessentities.VDSDomainsData) Injector(org.ovirt.engine.core.di.Injector) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) NetworkCommonUtils(org.ovirt.engine.core.common.utils.NetworkCommonUtils) VmExitStatus(org.ovirt.engine.core.common.businessentities.VmExitStatus) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) BondMode(org.ovirt.engine.core.common.businessentities.network.BondMode) SessionState(org.ovirt.engine.core.common.businessentities.SessionState) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) NetworkStatisticsBuilder(org.ovirt.engine.core.vdsbroker.NetworkStatisticsBuilder) OsType(org.ovirt.engine.core.common.businessentities.OsType) SimpleDateFormat(java.text.SimpleDateFormat) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) LinkedHashSet(java.util.LinkedHashSet) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) VM(org.ovirt.engine.core.common.businessentities.VM) LeaseStatus(org.ovirt.engine.core.common.businessentities.LeaseStatus) NetworkInterface(org.ovirt.engine.core.common.businessentities.network.NetworkInterface) Paths(java.nio.file.Paths) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmJobType(org.ovirt.engine.core.common.businessentities.VmJobType) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) Date(java.util.Date) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) LoggerFactory(org.slf4j.LoggerFactory) VdsTransparentHugePagesState(org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) InterfaceByAddressPredicate(org.ovirt.engine.core.utils.network.predicate.InterfaceByAddressPredicate) SwitchType(org.ovirt.engine.core.common.network.SwitchType) KdumpStatus(org.ovirt.engine.core.common.businessentities.KdumpStatus) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) ParseException(java.text.ParseException) Version(org.ovirt.engine.core.compat.Version) DateFormat(java.text.DateFormat) VdsInterfaceType(org.ovirt.engine.core.common.businessentities.network.VdsInterfaceType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VmPauseStatus(org.ovirt.engine.core.common.businessentities.VmPauseStatus) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Predicate(java.util.function.Predicate) ManagementNetworkUtil(org.ovirt.engine.core.bll.network.cluster.ManagementNetworkUtil) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) IpAddressPredicate(org.ovirt.engine.core.utils.network.predicate.IpAddressPredicate) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Entry(java.util.Map.Entry) AuditLogType(org.ovirt.engine.core.common.AuditLogType) Pattern(java.util.regex.Pattern) NumaUtils(org.ovirt.engine.core.utils.NumaUtils) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmBalloonInfo(org.ovirt.engine.core.common.businessentities.VmBalloonInfo) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Entities(org.ovirt.engine.core.common.businessentities.Entities) HashMap(java.util.HashMap) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) DbFacade(org.ovirt.engine.core.dal.dbbroker.DbFacade) SizeConverter(org.ovirt.engine.core.common.utils.SizeConverter) VmBlockJobType(org.ovirt.engine.core.common.businessentities.VmBlockJobType) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) Config(org.ovirt.engine.core.common.config.Config) VmJobState(org.ovirt.engine.core.common.businessentities.VmJobState) Logger(org.slf4j.Logger) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) DecimalFormat(java.text.DecimalFormat) GuestContainer(org.ovirt.engine.core.common.businessentities.GuestContainer) V2VJobInfo(org.ovirt.engine.core.common.businessentities.V2VJobInfo) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) VmExitReason(org.ovirt.engine.core.common.businessentities.VmExitReason) SerializationFactory(org.ovirt.engine.core.utils.SerializationFactory) NetworkStatistics(org.ovirt.engine.core.common.businessentities.network.NetworkStatistics) Comparator(java.util.Comparator) NumaNodeStatistics(org.ovirt.engine.core.common.businessentities.NumaNodeStatistics) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VdsTransparentHugePagesState(org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkStatisticsBuilder(org.ovirt.engine.core.vdsbroker.NetworkStatisticsBuilder) Map(java.util.Map) HashMap(java.util.HashMap) HugePage(org.ovirt.engine.core.common.businessentities.HugePage)

Example 7 with HugePage

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();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Example 8 with HugePage

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);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Example 9 with HugePage

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();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Aggregations

HugePage (org.ovirt.engine.core.common.businessentities.HugePage)9 VDS (org.ovirt.engine.core.common.businessentities.VDS)8 Test (org.junit.Test)7 PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)7 PendingHugePages (org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages)3 HashMap (java.util.HashMap)2 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 DateFormat (java.text.DateFormat)1 DecimalFormat (java.text.DecimalFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1