Search in sources :

Example 51 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.

the class DefaultTestCampaign method test.

@Override
public TestCaseResult test(TestCase tc) {
    VerifierResult res = oracle.verify(tc);
    DefaultChocoScheduler sched = new DefaultChocoScheduler(params);
    try {
        ReconfigurationPlan plan = sched.solve(tc.instance());
        checkConsistency(plan, tc);
    } catch (RuntimeException e) {
        // A runtime exception is a CRASH. Should not happen
        return new TestCaseResult(tc, e, res);
    }
    return new TestCaseResult(tc, sched.getStatistics(), res);
}
Also used : VerifierResult(org.btrplace.safeplace.testing.verification.VerifierResult) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan)

Example 52 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.

the class FixedSizePartitioningTest method basicTesting.

@Test
public void basicTesting() {
    FixedSizePartitioning f = new FixedSizePartitioning(1000);
    f.setWorkersCount(5);
    Assert.assertEquals(f.getWorkersCount(), 5);
    Assert.assertEquals(f.getSize(), 1000);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setInstanceSolver(f);
    Assert.assertEquals(cra.getInstanceSolver(), f);
    f.setSize(300);
    Assert.assertEquals(f.getSize(), 300);
    Assert.assertEquals(f.randomPickUp(), false);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 53 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.

the class StaticPartitioningTest method testParallelSolve.

@Test
public void testParallelSolve() throws SchedulerException {
    SynchronizedElementBuilder eb = new SynchronizedElementBuilder(new DefaultElementBuilder());
    Model origin = new DefaultModel(eb);
    Node n1 = origin.newNode();
    Node n2 = origin.newNode();
    VM vm1 = origin.newVM();
    VM vm2 = origin.newVM();
    /*
         * 2 nodes among 2 instances, 2 VMs to boot on the nodes
         */
    origin.getMapping().addOnlineNode(n1);
    origin.getMapping().addOfflineNode(n2);
    origin.getMapping().addReadyVM(vm1);
    origin.getMapping().addReadyVM(vm2);
    Model s1 = new SubModel(origin, eb, Collections.singletonList(n1), Collections.singleton(vm1));
    Model s2 = new SubModel(origin, eb, Collections.singletonList(n2), Collections.singleton(vm2));
    Instance i0 = new Instance(origin, new MinMTTR());
    final Instance i1 = new Instance(s1, Running.newRunning(Collections.singletonList(vm1)), new MinMTTR());
    final Instance i2 = new Instance(s2, new MinMTTR());
    i2.getSatConstraints().add(new Running(vm2));
    StaticPartitioning st = new StaticPartitioning() {

        @Override
        public List<Instance> split(Parameters ps, Instance i) throws SchedulerException {
            return Arrays.asList(i1, i2);
        }
    };
    Parameters p = new DefaultChocoScheduler();
    ReconfigurationPlan plan = st.solve(p, i0);
    Assert.assertNotNull(plan);
    Model dst = plan.getResult();
    Assert.assertEquals(dst.getMapping().getOnlineNodes().size(), 2);
    Assert.assertEquals(dst.getMapping().getRunningVMs().size(), 2);
    // Now, there is no solution for i2. the resulting plan should be null
    i2.getSatConstraints().addAll(Offline.newOffline(Collections.singletonList(n2)));
    plan = st.solve(p, i0);
    Assert.assertNull(plan);
    Assert.assertEquals(st.getStatistics().getSolutions().size(), 0);
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MinMTTR(org.btrplace.model.constraint.MinMTTR) SubModel(org.btrplace.scheduler.runner.disjoint.model.SubModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) SubModel(org.btrplace.scheduler.runner.disjoint.model.SubModel) Running(org.btrplace.model.constraint.Running) Test(org.testng.annotations.Test)

Example 54 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.

the class CNetworkTest method defaultTest.

/**
 * Test the instantiation and the creation of the variables.
 *
 * @throws org.btrplace.scheduler.SchedulerException if an error occurs during the solving process (it should not)
 */
@Test
public void defaultTest() throws SchedulerException {
    // New default model
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    // Create and boot 1 source and 1 destination node
    Node srcNode = mo.newNode(), dstNode = mo.newNode();
    ma.addOnlineNode(srcNode);
    ma.addOnlineNode(dstNode);
    // Attach a network view
    Network net = new Network();
    mo.attach(net);
    // Connect the nodes through a main non-blocking switch using 1 Gbit/s links
    Switch swMain = net.newSwitch();
    int bw = 1000;
    net.connect(bw, swMain, srcNode, dstNode);
    // Create and host 1 running VM on the source node
    VM vm = mo.newVM();
    ma.addRunningVM(vm, srcNode);
    // The VM consumes 6 GiB memory and has a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
    int memUsed = 6000, hotDirtySize = 46, hotDirtyDuration = 2;
    double coldDirtyRate = 23.6;
    // 6 GiB
    mo.getAttributes().put(vm, "memUsed", memUsed);
    // 46 MiB
    mo.getAttributes().put(vm, "hotDirtySize", hotDirtySize);
    // 2 sec.
    mo.getAttributes().put(vm, "hotDirtyDuration", hotDirtyDuration);
    // 23.6 MiB/sec.
    mo.getAttributes().put(vm, "coldDirtyRate", coldDirtyRate);
    // Add constraints
    List<SatConstraint> cstrs = new ArrayList<>();
    // We force the migration to go on the destination node
    cstrs.add(new Fence(vm, Collections.singleton(dstNode)));
    // Try to solve using the custom Min MTTR objective for migration scheduling
    ReconfigurationPlan p = new DefaultChocoScheduler().solve(mo, cstrs, new MinMTTRMig());
    Assert.assertNotNull(p);
    // The switch is non-blocking
    Assert.assertEquals(swMain.getCapacity(), Integer.MAX_VALUE);
    // Check the migration path and bandwidth
    MigrateVM mig = (MigrateVM) p.getActions().stream().filter(s -> s instanceof MigrateVM).findFirst().get();
    Assert.assertTrue(net.getRouting().getPath(mig.getSourceNode(), mig.getDestinationNode()).containsAll(net.getLinks()));
    Assert.assertEquals(net.getRouting().getMaxBW(mig.getSourceNode(), mig.getDestinationNode()), bw);
    Assert.assertEquals(mig.getBandwidth(), bw);
    // Check the migration duration computation
    double bandwidth_octet = mig.getBandwidth() / 9, durationMin, durationColdPages, durationHotPages, durationTotal;
    durationMin = memUsed / bandwidth_octet;
    durationColdPages = ((hotDirtySize + ((durationMin - hotDirtyDuration) * coldDirtyRate)) / (bandwidth_octet - coldDirtyRate));
    durationHotPages = ((hotDirtySize / bandwidth_octet) * ((hotDirtySize / hotDirtyDuration) / (bandwidth_octet - (hotDirtySize / hotDirtyDuration))));
    durationTotal = durationMin + durationColdPages + durationHotPages;
    Assert.assertEquals((mig.getEnd() - mig.getStart()), (int) Math.round(durationTotal));
}
Also used : SchedulerException(org.btrplace.scheduler.SchedulerException) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Fence(org.btrplace.model.constraint.Fence) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) List(java.util.List) Assert(org.testng.Assert) org.btrplace.model(org.btrplace.model) ShareableResource(org.btrplace.model.view.ShareableResource) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Collections(java.util.Collections) Network(org.btrplace.model.view.network.Network) SatConstraint(org.btrplace.model.constraint.SatConstraint) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) MigrateVM(org.btrplace.plan.event.MigrateVM) SatConstraint(org.btrplace.model.constraint.SatConstraint) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network) MigrateVM(org.btrplace.plan.event.MigrateVM) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 55 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.

the class CNetworkTest method testWithSwitchCapacity.

@Test
public void testWithSwitchCapacity() {
    Model mo = new DefaultModel();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    VM v = mo.newVM();
    mo.getMapping().on(n1, n2).run(n1, v);
    ShareableResource mem = new ShareableResource("mem", 10000, 5000);
    Network net = new Network();
    mo.attach(net);
    mo.attach(mem);
    mo.getAttributes().put(v, "memUsed", 10000);
    Switch sw = net.newSwitch(1000);
    net.connect(2000, sw, n1, n2);
    ChocoScheduler s = new DefaultChocoScheduler();
    ReconfigurationPlan p = s.solve(mo, Collections.singletonList(new Fence(v, n2)));
    Assert.assertNotNull(p);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) MigrateVM(org.btrplace.plan.event.MigrateVM) Network(org.btrplace.model.view.network.Network) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Fence(org.btrplace.model.constraint.Fence) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Aggregations

DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)104 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)94 Test (org.testng.annotations.Test)90 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)83 ShareableResource (org.btrplace.model.view.ShareableResource)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)40 ArrayList (java.util.ArrayList)37 DefaultModel (org.btrplace.model.DefaultModel)19 Model (org.btrplace.model.Model)19 Node (org.btrplace.model.Node)19 VM (org.btrplace.model.VM)18 MigrateVM (org.btrplace.plan.event.MigrateVM)17 Fence (org.btrplace.model.constraint.Fence)14 Network (org.btrplace.model.view.network.Network)14 BootVM (org.btrplace.plan.event.BootVM)14 ShutdownVM (org.btrplace.plan.event.ShutdownVM)14 Offline (org.btrplace.model.constraint.Offline)13 Switch (org.btrplace.model.view.network.Switch)13 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)11 SchedulerException (org.btrplace.scheduler.SchedulerException)11