Search in sources :

Example 26 with VmNumaNode

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

the class VmNumaNodeDaoImpl method getVmNumaNodeInfoByClusterId.

@Override
public Map<Guid, List<VmNumaNode>> getVmNumaNodeInfoByClusterId(Guid clusterId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("cluster_id", clusterId);
    List<Pair<Guid, VmNumaNode>> vmNumaNodes = getCallsHandler().executeReadList("GetVmNumaNodeByCluster", vmNumaNodeInfoWithClusterRowMapper, parameterSource);
    Map<Guid, List<Integer>> numaNodesCpusMap = getAllNumaNodeCpuMap();
    Map<Guid, List<Integer>> vmNumaNodesPinMap = getAllVmNumaNodePinInfo();
    for (Pair<Guid, VmNumaNode> pair : vmNumaNodes) {
        if (numaNodesCpusMap.containsKey(pair.getSecond().getId())) {
            pair.getSecond().setCpuIds(numaNodesCpusMap.get(pair.getSecond().getId()));
        }
        if (vmNumaNodesPinMap.containsKey(pair.getSecond().getId())) {
            pair.getSecond().setVdsNumaNodeList(vmNumaNodesPinMap.get(pair.getSecond().getId()));
        }
    }
    return pairsToMap(vmNumaNodes);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 27 with VmNumaNode

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

the class VmNumaNodeDaoImpl method getAllVmNumaNodeByVmId.

@Override
public List<VmNumaNode> getAllVmNumaNodeByVmId(Guid vmId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_id", vmId);
    List<VmNumaNode> vmNumaNodes = getCallsHandler().executeReadList("GetNumaNodeByVmId", vmNumaNodeCpuRowMapper, parameterSource);
    Map<Guid, List<Integer>> vmNumaNodesPinMap = getAllVmNumaNodePinInfo();
    vmNumaNodes.stream().filter(node -> vmNumaNodesPinMap.containsKey(node.getId())).forEach(node -> node.setVdsNumaNodeList(vmNumaNodesPinMap.get(node.getId())));
    return vmNumaNodes;
}
Also used : Arrays(java.util.Arrays) CollectionUtils.pairsToMap(org.ovirt.engine.core.utils.CollectionUtils.pairsToMap) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Guid(org.ovirt.engine.core.compat.Guid) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) Pair(org.ovirt.engine.core.common.utils.Pair) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid)

Example 28 with VmNumaNode

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

the class VmNumaNodeDaoTest method testMassSaveNumaNode.

@Test
public void testMassSaveNumaNode() {
    List<VmNumaNode> result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
    assertNotNull(result);
    assertEquals(0, result.size());
    Guid vmNumaNode1 = Guid.newGuid();
    Guid vmNumaNode2 = Guid.newGuid();
    List<VmNumaNode> newVmNode = new ArrayList<>();
    VmNumaNode newVmNumaNode = new VmNumaNode();
    newVmNumaNode.setCpuIds(generateCpuList(0, 4));
    newVmNumaNode.setId(vmNumaNode1);
    newVmNumaNode.setIndex(0);
    newVmNumaNode.getVdsNumaNodeList().add(0);
    newVmNode.add(newVmNumaNode);
    newVmNumaNode = new VmNumaNode();
    newVmNumaNode.setCpuIds(generateCpuList(4, 4));
    newVmNumaNode.setId(vmNumaNode2);
    newVmNumaNode.setIndex(1);
    newVmNumaNode.getVdsNumaNodeList().add(1);
    newVmNode.add(newVmNumaNode);
    vmNumaNodeDao.massSaveNumaNode(newVmNode, ANOTHER_EXISTING_VM_ID);
    result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
    assertNotNull(result);
    assertEquals(2, result.size());
    Map<Guid, VmNumaNode> nodes = new HashMap<>(2);
    nodes.put(result.get(0).getId(), result.get(0));
    nodes.put(result.get(1).getId(), result.get(1));
    assertTrue(nodes.containsKey(vmNumaNode1));
    assertTrue(nodes.containsKey(vmNumaNode2));
    assertEquals(1, nodes.get(vmNumaNode1).getVdsNumaNodeList().size());
    assertEquals(0, nodes.get(vmNumaNode1).getVdsNumaNodeList().get(0).intValue());
    assertEquals(1, nodes.get(vmNumaNode2).getVdsNumaNodeList().size());
    assertEquals(1, nodes.get(vmNumaNode2).getVdsNumaNodeList().get(0).intValue());
    List<Guid> vmNodeList = new ArrayList<>();
    vmNodeList.add(vmNumaNode1);
    vmNodeList.add(vmNumaNode2);
    vmNumaNodeDao.massRemoveNumaNodeByNumaNodeId(vmNodeList);
    result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
    assertNotNull(result);
    assertEquals(0, result.size());
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 29 with VmNumaNode

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

the class NumaSettingFactoryTest method createTestVmNumaNodes.

private static List<VmNumaNode> createTestVmNumaNodes() {
    List<VmNumaNode> newVmNodes = new ArrayList<>();
    VmNumaNode newVmNumaNode = new VmNumaNode();
    newVmNumaNode.setCpuIds(generateCpuList(0, 4));
    newVmNumaNode.setId(Guid.newGuid());
    newVmNumaNode.setIndex(0);
    newVmNumaNode.setMemTotal(1024);
    newVmNumaNode.getVdsNumaNodeList().add(0);
    newVmNodes.add(newVmNumaNode);
    newVmNumaNode = new VmNumaNode();
    newVmNumaNode.setCpuIds(generateCpuList(4, 4));
    newVmNumaNode.setId(Guid.newGuid());
    newVmNumaNode.setIndex(1);
    newVmNumaNode.setMemTotal(1024);
    newVmNumaNode.getVdsNumaNodeList().add(1);
    newVmNodes.add(newVmNumaNode);
    return newVmNodes;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList)

Example 30 with VmNumaNode

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

the class NumaSettingFactoryTest method shouldNotCreateCpuPinningForVirtualNumaNodes.

@Test
public void shouldNotCreateCpuPinningForVirtualNumaNodes() {
    for (VmNumaNode numaNode : vmNumaNodes) {
        numaNode.getVdsNumaNodeList().clear();
    }
    Map<String, Object> cpuPinning = NumaSettingFactory.buildCpuPinningWithNumaSetting(vmNumaNodes, vdsNumaNodes);
    Assertions.assertThat(cpuPinning).isEmpty();
    Map<String, Object> mapping = NumaSettingFactory.buildVmNumatuneSetting(NumaTuneMode.INTERLEAVE, vmNumaNodes);
    Assertions.assertThat(mapping).doesNotContainKeys(VdsProperties.NUMA_TUNE_MODE, VdsProperties.NUMA_TUNE_NODESET);
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Test(org.junit.Test)

Aggregations

VmNumaNode (org.ovirt.engine.core.common.businessentities.VmNumaNode)34 ArrayList (java.util.ArrayList)17 Guid (org.ovirt.engine.core.compat.Guid)9 HashMap (java.util.HashMap)7 List (java.util.List)5 Map (java.util.Map)5 VM (org.ovirt.engine.core.common.businessentities.VM)5 VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)5 Test (org.junit.Test)4 VmNumaNodeOperationParameters (org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters)4 Arrays (java.util.Arrays)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)3 LinkedHashSet (java.util.LinkedHashSet)2 Collectors (java.util.stream.Collectors)2 Named (javax.inject.Named)2 Singleton (javax.inject.Singleton)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1