Search in sources :

Example 1 with HugePage

use of org.ovirt.engine.core.common.businessentities.HugePage 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 HugePage

use of org.ovirt.engine.core.common.businessentities.HugePage 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 HugePage

use of org.ovirt.engine.core.common.businessentities.HugePage in project ovirt-engine by oVirt.

the class HugePagesFilterPolicyUnitTest method testHugePagesGoodAndWrongSizeOnHost.

@Test
public void testHugePagesGoodAndWrongSizeOnHost() throws Exception {
    vm.setCustomProperties("hugepages=1024");
    host1.setHugePages(Arrays.asList(new HugePage(1024, 5), new HugePage(2048, 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) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Example 4 with HugePage

use of org.ovirt.engine.core.common.businessentities.HugePage 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 5 with HugePage

use of org.ovirt.engine.core.common.businessentities.HugePage in project ovirt-engine by oVirt.

the class HugePagesFilterPolicyUnit method prepareHugePageMap.

private Map<Integer, Integer> prepareHugePageMap(VDS host) {
    List<HugePage> reportedHugePages = host.getHugePages();
    Map<Integer, Integer> hugePages = new HashMap<>(reportedHugePages.size());
    for (HugePage hp : reportedHugePages) {
        hugePages.put(hp.getSizeKB(), hp.getAmount());
    }
    return Collections.unmodifiableMap(hugePages);
}
Also used : HashMap(java.util.HashMap) HugePage(org.ovirt.engine.core.common.businessentities.HugePage)

Aggregations

HugePage (org.ovirt.engine.core.common.businessentities.HugePage)9 VDS (org.ovirt.engine.core.common.businessentities.VDS)8 Test (org.junit.Test)7 PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)7 PendingHugePages (org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages)3 HashMap (java.util.HashMap)2 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 DateFormat (java.text.DateFormat)1 DecimalFormat (java.text.DecimalFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1