Search in sources :

Example 1 with PendingHugePages

use of org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages in project ovirt-engine by oVirt.

the class HugePagesFilterPolicyUnitTest method testEnoughFreeHugePagesOnHostBadSizeAvailableAndPending.

@Test
public void testEnoughFreeHugePagesOnHostBadSizeAvailableAndPending() throws Exception {
    vm.setCustomProperties("hugepages=1024");
    host1.setHugePages(Arrays.asList(new HugePage(1024, 1050), new HugePage(2048, 1025)));
    pendingResourceManager.addPending(new PendingHugePages(host1, otherVm, 2048, 1024));
    HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
    List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(hosts).isNotEmpty().contains(host1);
}
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 2 with PendingHugePages

use of org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages in project ovirt-engine by oVirt.

the class HugePagesFilterPolicyUnitTest method testEnoughFreeHugePagesOnHostBadSizePending.

@Test
public void testEnoughFreeHugePagesOnHostBadSizePending() throws Exception {
    vm.setCustomProperties("hugepages=1024");
    host1.setHugePages(Collections.singletonList(new HugePage(1024, 1050)));
    pendingResourceManager.addPending(new PendingHugePages(host1, otherVm, 2048, 1024));
    HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
    List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(hosts).isNotEmpty().contains(host1);
}
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 3 with PendingHugePages

use of org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages 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 4 with PendingHugePages

use of org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages in project ovirt-engine by oVirt.

the class SchedulingManager method schedule.

public Optional<Guid> schedule(Cluster cluster, VM vm, List<Guid> hostBlackList, List<Guid> hostWhiteList, List<Guid> destHostIdList, List<String> messages, RunVmDelayer runVmDelayer, String correlationId) {
    prepareClusterLock(cluster.getId());
    try {
        log.debug("Scheduling started, correlation Id: {}", correlationId);
        checkAllowOverbooking(cluster);
        lockCluster(cluster.getId());
        List<VDS> vdsList = vdsDao.getAllForClusterWithStatus(cluster.getId(), VDSStatus.Up);
        vdsList = removeBlacklistedHosts(vdsList, hostBlackList);
        vdsList = keepOnlyWhitelistedHosts(vdsList, hostWhiteList);
        refreshCachedPendingValues(vdsList);
        ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
        Map<String, String> parameters = createClusterPolicyParameters(cluster);
        vdsList = runFilters(policy.getFilters(), cluster, vdsList, vm, parameters, policy.getFilterPositionMap(), messages, runVmDelayer, true, correlationId);
        if (vdsList.isEmpty()) {
            return Optional.empty();
        }
        Optional<Guid> bestHost = selectBestHost(cluster, vm, destHostIdList, vdsList, policy, parameters);
        if (bestHost.isPresent() && !bestHost.get().equals(vm.getRunOnVds())) {
            Guid bestHostId = bestHost.get();
            getPendingResourceManager().addPending(new PendingCpuCores(bestHostId, vm, vm.getNumOfCpus()));
            getPendingResourceManager().addPending(new PendingMemory(bestHostId, vm, vmOverheadCalculator.getStaticOverheadInMb(vm)));
            getPendingResourceManager().addPending(new PendingOvercommitMemory(bestHostId, vm, vmOverheadCalculator.getTotalRequiredMemoryInMb(vm)));
            getPendingResourceManager().addPending(new PendingVM(bestHostId, vm));
            // Add pending records for all specified hugepage sizes
            for (Map.Entry<Integer, Integer> hugepage : HugePageUtils.getHugePages(vm.getStaticData()).entrySet()) {
                getPendingResourceManager().addPending(new PendingHugePages(bestHostId, vm, hugepage.getKey(), hugepage.getValue()));
            }
            getPendingResourceManager().notifyHostManagers(bestHostId);
            markVfsAsUsedByVm(vm, bestHostId);
        }
        return bestHost;
    } catch (InterruptedException e) {
        log.error("scheduling interrupted, correlation Id: {}: {}", correlationId, e.getMessage());
        log.debug("Exception: ", e);
        return Optional.empty();
    } finally {
        releaseCluster(cluster.getId());
        log.debug("Scheduling ended, correlation Id: {}", correlationId);
    }
}
Also used : PendingMemory(org.ovirt.engine.core.bll.scheduling.pending.PendingMemory) VDS(org.ovirt.engine.core.common.businessentities.VDS) PendingVM(org.ovirt.engine.core.bll.scheduling.pending.PendingVM) PendingHugePages(org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages) Guid(org.ovirt.engine.core.compat.Guid) PendingCpuCores(org.ovirt.engine.core.bll.scheduling.pending.PendingCpuCores) PendingOvercommitMemory(org.ovirt.engine.core.bll.scheduling.pending.PendingOvercommitMemory) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

PendingHugePages (org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)4 Test (org.junit.Test)3 HugePage (org.ovirt.engine.core.common.businessentities.HugePage)3 PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)3 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PendingCpuCores (org.ovirt.engine.core.bll.scheduling.pending.PendingCpuCores)1 PendingMemory (org.ovirt.engine.core.bll.scheduling.pending.PendingMemory)1 PendingOvercommitMemory (org.ovirt.engine.core.bll.scheduling.pending.PendingOvercommitMemory)1 PendingVM (org.ovirt.engine.core.bll.scheduling.pending.PendingVM)1 ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)1 Guid (org.ovirt.engine.core.compat.Guid)1