Search in sources :

Example 16 with PerHostMessages

use of org.ovirt.engine.core.common.scheduling.PerHostMessages in project ovirt-engine by oVirt.

the class HugePagesFilterPolicyUnitTest method testNotEnoughFreeHugePagesOnHostPending.

@Test
public void testNotEnoughFreeHugePagesOnHostPending() throws Exception {
    vm.setCustomProperties("hugepages=1024");
    host1.setHugePages(Collections.singletonList(new HugePage(1024, 1050)));
    pendingResourceManager.addPending(new PendingHugePages(host1, otherVm, 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) PendingHugePages(org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Example 17 with PerHostMessages

use of org.ovirt.engine.core.common.scheduling.PerHostMessages in project ovirt-engine by oVirt.

the class LabelFilterPolicyUnitTest method testEmpty.

@Test
public void testEmpty() throws Exception {
    Label red = new LabelBuilder().entities(vm, host1).build();
    Label blue = new LabelBuilder().entities(vm, host2).build();
    List<Label> labels = Arrays.asList(red, blue);
    doReturn(labels).when(labelDao).getAllByEntityIds(any());
    assertThat(unit.filter(cluster, hosts, vm, new HashMap<>(), new PerHostMessages())).isEmpty();
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Example 18 with PerHostMessages

use of org.ovirt.engine.core.common.scheduling.PerHostMessages in project ovirt-engine by oVirt.

the class HugePagesFilterPolicyUnit method filter.

@Override
public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters, PerHostMessages messages) {
    if (!HugePageUtils.isBackedByHugepages(vm.getStaticData())) {
        return new ArrayList<>(hosts);
    }
    Map<Integer, Integer> requiredPages = HugePageUtils.getHugePages(vm.getStaticData());
    List<VDS> newHosts = new ArrayList<>(hosts.size());
    for (VDS host : hosts) {
        Map<Integer, Integer> availablePages = subtractMaps(prepareHugePageMap(host), PendingHugePages.collectForHost(getPendingResourceManager(), host.getId()));
        if (!requiredPages.entrySet().stream().allMatch(pg -> availablePages.getOrDefault(pg.getKey(), 0) >= pg.getValue())) {
            log.debug("Host {} does not have enough free hugepages for VM {}", host.getId(), vm.getId());
            messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__NOT_ENOUGH_HUGE_PAGES.name());
        } else {
            newHosts.add(host);
        }
    }
    return newHosts;
}
Also used : SchedulingUnit(org.ovirt.engine.core.bll.scheduling.SchedulingUnit) Logger(org.slf4j.Logger) PolicyUnitImpl(org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) PolicyUnitType(org.ovirt.engine.core.common.scheduling.PolicyUnitType) ArrayList(java.util.ArrayList) PendingHugePages(org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit) HugePageUtils(org.ovirt.engine.core.common.utils.HugePageUtils) PendingResourceManager(org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager) Map(java.util.Map) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList)

Example 19 with PerHostMessages

use of org.ovirt.engine.core.common.scheduling.PerHostMessages in project ovirt-engine by oVirt.

the class HostedEngineMemoryReservationFilterPolicyUnitTest method setUp.

@Before
public void setUp() throws Exception {
    Cluster cluster = new Cluster();
    clusterId = Guid.newGuid();
    cluster.setId(clusterId);
    vm = new VM();
    vm.setId(Guid.newGuid());
    vm.setClusterId(clusterId);
    vm.setVmMemSizeMb(1024);
    hosts = new ArrayList<>();
    hosts.add(prepareHost("A", 8192, true, 2400, false));
    hosts.add(prepareHost("B", 8192, true, 2400, false));
    hosts.add(prepareHost("C", 8192, true, 2400, false));
    hosts.add(prepareHost("D", 8192, true, 2400, false));
    hosts.add(prepareHost("E", 8192, true, 2400, false));
    hostedEngine = new VM();
    hostedEngine.setOrigin(OriginType.HOSTED_ENGINE);
    hostedEngine.setVmMemSizeMb(4096);
    hostedEngine.setId(Guid.newGuid());
    hostedEngine.setClusterId(clusterId);
    hostedEngine.setRunOnVds(hosts.get(0).getId());
    parameters = new HashMap<>();
    parameters.put(PolicyUnitParameter.HE_SPARES_COUNT.getDbName(), "0");
    messages = new PerHostMessages();
    doReturn(hostedEngine).when(vmDao).getHostedEngineVm();
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Before(org.junit.Before)

Example 20 with PerHostMessages

use of org.ovirt.engine.core.common.scheduling.PerHostMessages in project ovirt-engine by oVirt.

the class HugePagesFilterPolicyUnitTest method testNoHugePages.

@Test
public void testNoHugePages() throws Exception {
    HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
    List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(hosts).isNotNull().isNotEmpty().contains(host1);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Aggregations

PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)31 Test (org.junit.Test)24 VDS (org.ovirt.engine.core.common.businessentities.VDS)24 VM (org.ovirt.engine.core.common.businessentities.VM)9 HugePage (org.ovirt.engine.core.common.businessentities.HugePage)8 HashMap (java.util.HashMap)5 AffinityGroup (org.ovirt.engine.core.common.scheduling.AffinityGroup)5 ArrayList (java.util.ArrayList)4 PendingHugePages (org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages)4 Guid (org.ovirt.engine.core.compat.Guid)4 List (java.util.List)3 Map (java.util.Map)3 PolicyUnitImpl (org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl)3 PendingResourceManager (org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 Label (org.ovirt.engine.core.common.businessentities.Label)3 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)3 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)3 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)3 Logger (org.slf4j.Logger)3