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;
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations