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