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);
}
}
Aggregations