Search in sources :

Example 66 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class CQuarantineTest method testWithNoSolution1.

/**
 * A VM try to come into the quarantine zone.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution1() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4);
    Quarantine q = new Quarantine(n1);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(q);
    cstrs.add(new Fence(vm4, Collections.singleton(n1)));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) ArrayList(java.util.ArrayList) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 67 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class CMinMigrationsTest method simpleTest.

@Test
public void simpleTest() {
    Model mo = new DefaultModel();
    Node n0 = mo.newNode();
    Node n1 = mo.newNode();
    VM vm0 = mo.newVM();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    mo.getMapping().on(n0, n1).run(n0, vm0, vm1, vm2);
    ShareableResource mem = new ShareableResource("mem", 5, 1);
    // cpu dimension to create the violation
    ShareableResource cpu = new ShareableResource("cpu", 5, 1);
    // VM0 as the big VM
    mem.setConsumption(vm0, 3);
    mo.attach(cpu);
    mo.attach(mem);
    List<SatConstraint> cstrs = new ArrayList<>();
    // The 3 VMs no longer feet on n0
    cstrs.add(new Preserve(vm0, "cpu", 5));
    ChocoScheduler s = new DefaultChocoScheduler();
    s.doOptimize(true);
    ReconfigurationPlan p = s.solve(mo, cstrs, new MinMigrations());
    System.out.println(s.getStatistics());
    System.out.println(p);
    // VM0 to n1
    Assert.assertEquals(p.getActions().size(), 1);
    // VM0 to n1
    Assert.assertEquals(p.getResult().getMapping().getVMLocation(vm0), n1);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) Preserve(org.btrplace.model.constraint.Preserve) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMigrations(org.btrplace.model.constraint.MinMigrations) Test(org.testng.annotations.Test)

Example 68 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class CMinMigrationsTest method testWithFreeNodes.

/**
 * Issue #137.
 * ShutdownableNode.isOnline() is not instantiated at the end of the problem
 */
@Test
public void testWithFreeNodes() {
    Model mo = new DefaultModel();
    Node n0 = mo.newNode();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    VM v1 = mo.newVM();
    VM v2 = mo.newVM();
    DefaultChocoScheduler s = new DefaultChocoScheduler();
    mo.getMapping().on(n0, n1, n2).run(n0, v1, v2);
    Instance i = new Instance(mo, Arrays.asList(new Spread(mo.getMapping().getAllVMs(), false)), new MinMigrations());
    ReconfigurationPlan p = s.solve(i);
    Assert.assertNotNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Spread(org.btrplace.model.constraint.Spread) Instance(org.btrplace.model.Instance) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Node(org.btrplace.model.Node) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMigrations(org.btrplace.model.constraint.MinMigrations) Test(org.testng.annotations.Test)

Example 69 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class QuarantineBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodQuarantines")
public void testGoodSignatures(String str, int nbNodes) throws Exception {
    ScriptBuilder b = new ScriptBuilder(new DefaultModel());
    Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n@N[1..20] : defaultNode;\n" + str).getConstraints();
    Assert.assertEquals(cstrs.size(), nbNodes);
    Set<Node> nodes = new HashSet<>();
    for (SatConstraint x : cstrs) {
        Assert.assertTrue(x instanceof Quarantine);
        Assert.assertTrue(nodes.addAll(x.getInvolvedNodes()));
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) Node(org.btrplace.model.Node) Quarantine(org.btrplace.model.constraint.Quarantine) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 70 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class DefaultReconfigurationProblem method makeNodeTransitions.

private void makeNodeTransitions() {
    Mapping m = model.getMapping();
    nodeActions = new ArrayList<>(nodes.size());
    for (Node nId : nodes) {
        NodeState state = m.getState(nId);
        NodeTransitionBuilder b = amFactory.getBuilder(state);
        if (b == null) {
            throw new LifeCycleViolationException(model, nId, state, EnumSet.of(NodeState.OFFLINE, NodeState.ONLINE));
        }
        nodeActions.add(b.build(this, nId));
    }
}
Also used : NodeState(org.btrplace.model.NodeState) NodeTransitionBuilder(org.btrplace.scheduler.choco.transition.NodeTransitionBuilder) Node(org.btrplace.model.Node) Mapping(org.btrplace.model.Mapping)

Aggregations

Node (org.btrplace.model.Node)188 VM (org.btrplace.model.VM)110 Model (org.btrplace.model.Model)92 DefaultModel (org.btrplace.model.DefaultModel)91 Test (org.testng.annotations.Test)85 Mapping (org.btrplace.model.Mapping)68 HashSet (java.util.HashSet)48 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)35 ArrayList (java.util.ArrayList)34 IntVar (org.chocosolver.solver.variables.IntVar)29 ShareableResource (org.btrplace.model.view.ShareableResource)28 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)23 MigrateVM (org.btrplace.plan.event.MigrateVM)22 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)19 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)19 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)19 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)18 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)16 BootVM (org.btrplace.scheduler.choco.transition.BootVM)16