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