Search in sources :

Example 1 with PendingMemory

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

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 PendingHugePages (org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages)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 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)1 Guid (org.ovirt.engine.core.compat.Guid)1