Search in sources :

Example 1 with VdsNumaNode

use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.

the class NumaTestUtils method createVmNumaNode.

public static VmNumaNode createVmNumaNode(int index, List<VdsNumaNode> vdsNumaNodes) {
    VmNumaNode numaNode = createVmNumaNode(index);
    final List<Integer> numaPinning = new ArrayList<>();
    for (VdsNumaNode vdsNumaNode : vdsNumaNodes) {
        numaPinning.add(vdsNumaNode.getIndex());
    }
    numaNode.setVdsNumaNodeList(numaPinning);
    return numaNode;
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList)

Example 2 with VdsNumaNode

use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.

the class NumaTestUtils method createVdsNumaNode.

public static VdsNumaNode createVdsNumaNode(int index) {
    VdsNumaNode vdsNumaNode = new VdsNumaNode();
    vdsNumaNode.setIndex(index);
    vdsNumaNode.setId(Guid.newGuid());
    vdsNumaNode.setMemTotal(2000);
    return vdsNumaNode;
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode)

Example 3 with VdsNumaNode

use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method updateNumaNodesData.

/**
 * Build through the received NUMA nodes information
 */
private static void updateNumaNodesData(VDS vds, Map<String, Object> struct) {
    if (struct.containsKey(VdsProperties.AUTO_NUMA)) {
        vds.getDynamicData().setAutoNumaBalancing(AutoNumaBalanceStatus.forValue(assignIntValue(struct, VdsProperties.AUTO_NUMA)));
    }
    if (struct.containsKey(VdsProperties.NUMA_NODES)) {
        Map<String, Map<String, Object>> numaNodeMap = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NUMA_NODES);
        Map<String, Object> numaNodeDistanceMap = (Map<String, Object>) struct.get(VdsProperties.NUMA_NODE_DISTANCE);
        List<VdsNumaNode> newNumaNodeList = new ArrayList<>(numaNodeMap.size());
        for (Map.Entry<String, Map<String, Object>> item : numaNodeMap.entrySet()) {
            int index = Integer.parseInt(item.getKey());
            Map<String, Object> itemMap = item.getValue();
            List<Integer> cpuIds = extractList(itemMap, VdsProperties.NUMA_NODE_CPU_LIST, false);
            long memTotal = assignLongValue(itemMap, VdsProperties.NUMA_NODE_TOTAL_MEM);
            VdsNumaNode numaNode = new VdsNumaNode();
            numaNode.setIndex(index);
            if (cpuIds != null) {
                numaNode.setCpuIds(cpuIds);
            }
            numaNode.setMemTotal(memTotal);
            newNumaNodeList.add(numaNode);
        }
        Collections.sort(newNumaNodeList, numaNodeComparator);
        for (VdsNumaNode vdsNumaNode : newNumaNodeList) {
            int index = vdsNumaNode.getIndex();
            Map<Integer, Integer> distanceMap = new HashMap<>();
            List<Integer> distances = Collections.emptyList();
            if (numaNodeDistanceMap != null) {
                // Save the received NUMA node distances
                distances = extractList(numaNodeDistanceMap, String.valueOf(index), false);
                for (int i = 0; i < distances.size(); i++) {
                    distanceMap.put(newNumaNodeList.get(i).getIndex(), distances.get(i));
                }
            }
            if (distances.isEmpty()) {
                // Save faked distances
                for (VdsNumaNode otherNumaNode : newNumaNodeList) {
                    // There is no distance if the node is the same one
                    if (otherNumaNode.getIndex() == vdsNumaNode.getIndex()) {
                        continue;
                    }
                    distanceMap.put(otherNumaNode.getIndex(), 0);
                }
            }
            VdsNumaNode newNumaNode = NumaUtils.getVdsNumaNodeByIndex(newNumaNodeList, index);
            if (newNumaNode != null) {
                newNumaNode.setNumaNodeDistances(distanceMap);
            }
        }
        vds.getDynamicData().setNumaNodeList(newNumaNodeList);
        vds.setNumaSupport(newNumaNodeList.size() > 1);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with VdsNumaNode

use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method updateNumaStatisticsData.

public static void updateNumaStatisticsData(VDS vds, Map<String, Object> struct) {
    List<VdsNumaNode> vdsNumaNodes = new ArrayList<>();
    if (vds.getNumaNodeList() != null && !vds.getNumaNodeList().isEmpty()) {
        vdsNumaNodes.addAll(vds.getNumaNodeList());
    }
    List<CpuStatistics> cpuStatsData = new ArrayList<>();
    if (struct.containsKey(VdsProperties.CPU_STATS)) {
        Map<String, Map<String, Object>> cpuStats = (Map<String, Map<String, Object>>) struct.get(VdsProperties.CPU_STATS);
        Map<Integer, List<CpuStatistics>> numaNodeCpuStats = new HashMap<>();
        for (Map.Entry<String, Map<String, Object>> item : cpuStats.entrySet()) {
            CpuStatistics data = buildVdsCpuStatistics(item);
            cpuStatsData.add(data);
            int numaNodeIndex = assignIntValue(item.getValue(), VdsProperties.NUMA_NODE_INDEX);
            if (!numaNodeCpuStats.containsKey(numaNodeIndex)) {
                numaNodeCpuStats.put(numaNodeIndex, new ArrayList<>());
            }
            numaNodeCpuStats.get(numaNodeIndex).add(data);
        }
        DecimalFormat percentageFormatter = new DecimalFormat("#.##");
        for (Map.Entry<Integer, List<CpuStatistics>> item : numaNodeCpuStats.entrySet()) {
            VdsNumaNode nodeWithStatistics = buildVdsNumaNodeStatistics(percentageFormatter, item);
            if (vdsNumaNodes.isEmpty()) {
                vdsNumaNodes.add(nodeWithStatistics);
            } else {
                boolean foundNumaNode = false;
                // append the statistics to the correct numaNode (search by its Index.)
                for (VdsNumaNode currNumaNode : vdsNumaNodes) {
                    if (currNumaNode.getIndex() == nodeWithStatistics.getIndex()) {
                        currNumaNode.setNumaNodeStatistics(nodeWithStatistics.getNumaNodeStatistics());
                        foundNumaNode = true;
                        break;
                    }
                }
                // append new numaNode (contains only statistics) if not found existing
                if (!foundNumaNode) {
                    vdsNumaNodes.add(nodeWithStatistics);
                }
            }
        }
    }
    if (struct.containsKey(VdsProperties.NUMA_NODE_FREE_MEM_STAT)) {
        Map<String, Map<String, Object>> memStats = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NUMA_NODE_FREE_MEM_STAT);
        for (Map.Entry<String, Map<String, Object>> item : memStats.entrySet()) {
            VdsNumaNode node = NumaUtils.getVdsNumaNodeByIndex(vdsNumaNodes, Integer.parseInt(item.getKey()));
            if (node != null && node.getNumaNodeStatistics() != null) {
                node.getNumaNodeStatistics().setMemFree(assignLongValue(item.getValue(), VdsProperties.NUMA_NODE_FREE_MEM));
                node.getNumaNodeStatistics().setMemUsagePercent(assignIntValue(item.getValue(), VdsProperties.NUMA_NODE_MEM_PERCENT));
            }
        }
    }
    vds.getNumaNodeList().clear();
    vds.getNumaNodeList().addAll(vdsNumaNodes);
    vds.getStatisticsData().getCpuCoreStatistics().clear();
    vds.getStatisticsData().getCpuCoreStatistics().addAll(cpuStatsData);
}
Also used : HashMap(java.util.HashMap) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) ArrayList(java.util.ArrayList) List(java.util.List) CpuStatistics(org.ovirt.engine.core.common.businessentities.CpuStatistics) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with VdsNumaNode

use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.

the class NumaSupportPopupView method addVNumaInfoPanel.

@Override
public void addVNumaInfoPanel(Set<VdsNumaNode> numaNodes, int socketIndex, NumaSupportModel supportModel) {
    SocketPanel socketPanel = socketPanelProvider.get();
    socketPanel.setHeaderText(messages.numaSocketNumber(socketIndex));
    for (VdsNumaNode numaNode : numaNodes) {
        NumaPanel numaPanel = numaPanelProvider.get();
        numaPanel.getCpuSummaryPanel().setName(messages.numaNode(numaNode.getIndex()));
        numaPanel.getCpuSummaryPanel().setCpus(numaNode.getCpuIds().size(), numaNode.getNumaNodeStatistics().getCpuUsagePercent());
        numaPanel.getMemorySummaryPanel().setMemoryStats(numaNode.getMemTotal(), numaNode.getMemTotal() - numaNode.getNumaNodeStatistics().getMemFree());
        socketPanel.addWidget(numaPanel);
        AssignedVNumaNodesPanel assignedPanel = assignedVNumaPanelProvider.get();
        assignedPanel.setNodes(supportModel.getVNumaNodeByNodeIndx(numaNode.getIndex()), numaNode.getIndex(), supportModel.getNumaNodeList());
        socketPanel.addWidget(assignedPanel);
    }
    this.socketListPanel.add(socketPanel);
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode)

Aggregations

VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)22 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 VmNumaNode (org.ovirt.engine.core.common.businessentities.VmNumaNode)6 Map (java.util.Map)3 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 Test (org.junit.Test)2 NumaNode (org.ovirt.engine.api.model.NumaNode)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)2 CpuStatistics (org.ovirt.engine.core.common.businessentities.CpuStatistics)2 NumaNodeStatistics (org.ovirt.engine.core.common.businessentities.NumaNodeStatistics)2 Guid (org.ovirt.engine.core.compat.Guid)2 HTML (com.google.gwt.user.client.ui.HTML)1 DecimalFormat (java.text.DecimalFormat)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 Core (org.ovirt.engine.api.model.Core)1 Cores (org.ovirt.engine.api.model.Cores)1