Search in sources :

Example 11 with VmNumaNode

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

the class VmNumaNodeDaoTest method testMassUpdateNumaNode.

@Test
public void testMassUpdateNumaNode() {
    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));
    nodes.get(vmNumaNode1).getVdsNumaNodeList().clear();
    nodes.get(vmNumaNode1).getVdsNumaNodeList().add(1);
    nodes.get(vmNumaNode2).getVdsNumaNodeList().clear();
    nodes.get(vmNumaNode2).getVdsNumaNodeList().add(0);
    newVmNode.clear();
    newVmNode.add(nodes.get(vmNumaNode1));
    newVmNode.add(nodes.get(vmNumaNode2));
    vmNumaNodeDao.massUpdateNumaNode(newVmNode);
    result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
    assertNotNull(result);
    assertEquals(2, result.size());
    nodes.clear();
    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(1, nodes.get(vmNumaNode1).getVdsNumaNodeList().get(0).intValue());
    assertEquals(1, nodes.get(vmNumaNode2).getVdsNumaNodeList().size());
    assertEquals(0, 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 12 with VmNumaNode

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

the class VmNumaNodeDaoTest method testGetAllVmNumaNodeByVmId.

@Test
public void testGetAllVmNumaNodeByVmId() {
    List<VmNumaNode> result = vmNumaNodeDao.getAllVmNumaNodeByVmId(EXISTING_VM_ID);
    assertNotNull(result);
    assertEquals(2, result.size());
    Guid vmNumaNode1 = new Guid("3c2b81e6-5080-4ad1-86a1-cf513b15b517");
    Guid vmNumaNode2 = new Guid("3c2b81e6-5080-4ad1-86a1-cf513b15b518");
    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(2, nodes.get(vmNumaNode1).getVdsNumaNodeList().size());
    assertTrue(nodes.get(vmNumaNode1).getVdsNumaNodeList().contains(0));
    assertTrue(nodes.get(vmNumaNode1).getVdsNumaNodeList().contains(1));
    assertEquals(0, nodes.get(vmNumaNode2).getVdsNumaNodeList().size());
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 13 with VmNumaNode

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

the class VmInfoBuildUtils method getVmNumaNodes.

public List<VmNumaNode> getVmNumaNodes(VM vm) {
    List<VmNumaNode> vmNumaNodes = vmNumaNodeDao.getAllVmNumaNodeByVmId(vm.getId());
    if (!vmNumaNodes.isEmpty()) {
        return vmNumaNodes;
    }
    // create a default one with one guest numa node
    if (FeatureSupported.hotPlugMemory(vm.getCompatibilityVersion(), vm.getClusterArch())) {
        VmNumaNode vmNode = new VmNumaNode();
        vmNode.setIndex(0);
        vmNode.setMemTotal(vm.getMemSizeMb());
        for (int i = 0; i < vm.getNumOfCpus(); i++) {
            vmNode.getCpuIds().add(i);
        }
        return Collections.singletonList(vmNode);
    }
    // no need to send numa if memory hotplug not supported
    return Collections.emptyList();
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 14 with VmNumaNode

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

the class NumaTestUtils method createVmNumaNode.

public static VmNumaNode createVmNumaNode(int index) {
    VmNumaNode vmNumaNode = new VmNumaNode();
    vmNumaNode.setIndex(index);
    vmNumaNode.setMemTotal(1000);
    return vmNumaNode;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 15 with VmNumaNode

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

the class NumaTestUtils method createVmNumaNodeWithId.

public static VmNumaNode createVmNumaNodeWithId(int index, Guid guid) {
    final VmNumaNode numaNode = createVmNumaNode(index);
    numaNode.setId(guid);
    return numaNode;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

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