Search in sources :

Example 36 with VMTransition

use of org.btrplace.scheduler.choco.transition.VMTransition in project scheduler by btrplace.

the class DefaultReconfigurationProblemTest method testVMRunningToSleeping.

@Test
public void testVMRunningToSleeping() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    VM vm5 = mo.newVM();
    VM vm6 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Mapping map = mo.getMapping();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addOfflineNode(n3);
    map.addRunningVM(vm1, n1);
    map.addRunningVM(vm2, n1);
    map.addRunningVM(vm3, n2);
    map.addSleepingVM(vm4, n2);
    map.addReadyVM(vm5);
    map.addReadyVM(vm6);
    Mapping m = mo.getMapping();
    m.addOnlineNode(n1);
    m.addRunningVM(vm1, n1);
    DefaultReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(new HashSet<>(), new HashSet<>(), Collections.singleton(vm1), new HashSet<>()).build();
    VMTransition a = rp.getVMActions().get(0);
    Assert.assertEquals(a, rp.getVMAction(vm1));
    Assert.assertEquals(SuspendVM.class, a.getClass());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SuspendVM(org.btrplace.scheduler.choco.transition.SuspendVM) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) VM(org.btrplace.model.VM) StayAwayVM(org.btrplace.scheduler.choco.transition.StayAwayVM) ResumeVM(org.btrplace.scheduler.choco.transition.ResumeVM) KillVM(org.btrplace.scheduler.choco.transition.KillVM) BootVM(org.btrplace.scheduler.choco.transition.BootVM) ForgeVM(org.btrplace.scheduler.choco.transition.ForgeVM) ShutdownVM(org.btrplace.scheduler.choco.transition.ShutdownVM) ShutdownableNode(org.btrplace.scheduler.choco.transition.ShutdownableNode) Node(org.btrplace.model.Node) BootableNode(org.btrplace.scheduler.choco.transition.BootableNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 37 with VMTransition

use of org.btrplace.scheduler.choco.transition.VMTransition in project scheduler by btrplace.

the class DefaultReconfigurationProblemTest method testVMSleepToRun.

@Test
public void testVMSleepToRun() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    VM vm5 = mo.newVM();
    VM vm6 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Mapping map = mo.getMapping();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addOfflineNode(n3);
    map.addRunningVM(vm1, n1);
    map.addRunningVM(vm2, n1);
    map.addRunningVM(vm3, n2);
    map.addSleepingVM(vm4, n2);
    map.addReadyVM(vm5);
    map.addReadyVM(vm6);
    Mapping m = mo.getMapping();
    m.addOnlineNode(n1);
    m.addSleepingVM(vm1, n1);
    DefaultReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(new HashSet<>(), Collections.singleton(vm1), new HashSet<>(), new HashSet<>()).build();
    VMTransition a = rp.getVMActions().get(0);
    Assert.assertEquals(a, rp.getVMAction(vm1));
    Assert.assertEquals(ResumeVM.class, a.getClass());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SuspendVM(org.btrplace.scheduler.choco.transition.SuspendVM) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) VM(org.btrplace.model.VM) StayAwayVM(org.btrplace.scheduler.choco.transition.StayAwayVM) ResumeVM(org.btrplace.scheduler.choco.transition.ResumeVM) KillVM(org.btrplace.scheduler.choco.transition.KillVM) BootVM(org.btrplace.scheduler.choco.transition.BootVM) ForgeVM(org.btrplace.scheduler.choco.transition.ForgeVM) ShutdownVM(org.btrplace.scheduler.choco.transition.ShutdownVM) ShutdownableNode(org.btrplace.scheduler.choco.transition.ShutdownableNode) Node(org.btrplace.model.Node) BootableNode(org.btrplace.scheduler.choco.transition.BootableNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 38 with VMTransition

use of org.btrplace.scheduler.choco.transition.VMTransition in project scheduler by btrplace.

the class IssuesTest method issue33.

@Test
public void issue33() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Node n = mo.newNode();
    VM v = mo.newVM();
    mo.getMapping().addOnlineNode(n);
    mo.getMapping().addRunningVM(v, n);
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.emptySet(), Collections.emptySet(), Collections.singleton(v), Collections.emptySet()).build();
    NodeTransition na = rp.getNodeAction(n);
    na.getStart().instantiateTo(0, Cause.Null);
    na.getEnd().instantiateTo(1, Cause.Null);
    VMTransition vma = rp.getVMAction(v);
    vma.getStart().instantiateTo(0, Cause.Null);
    vma.getEnd().instantiateTo(1, Cause.Null);
    ReconfigurationPlan plan = rp.solve(0, false);
    Assert.assertEquals(plan, null);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Test(org.testng.annotations.Test)

Example 39 with VMTransition

use of org.btrplace.scheduler.choco.transition.VMTransition in project scheduler by btrplace.

the class CNoDelay method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) {
    VM v = noDelay.getInvolvedVMs().iterator().next();
    // For each vm involved in the constraint
    VMTransition vt = rp.getVMAction(v);
    // Get the VMTransition start time
    // Add the constraint "start = 0" to the solver
    Slice d = vt.getDSlice();
    if (d == null) {
        return true;
    }
    if (!(vt instanceof RelocatableVM)) {
        try {
            d.getStart().instantiateTo(0, Cause.Null);
        } catch (ContradictionException ex) {
            rp.getLogger().error("Unable to prevent any delay on '" + v + "'", ex);
            return false;
        }
    } else {
        Constraint c = rp.getModel().arithm(d.getStart(), "=", 0);
        BoolVar move = ((RelocatableVM) vt).isStaying().not();
        ChocoUtils.postImplies(rp, move, c);
    }
    return true;
}
Also used : Constraint(org.chocosolver.solver.constraints.Constraint) Slice(org.btrplace.scheduler.choco.Slice) ContradictionException(org.chocosolver.solver.exception.ContradictionException) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) VM(org.btrplace.model.VM) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) BoolVar(org.chocosolver.solver.variables.BoolVar)

Example 40 with VMTransition

use of org.btrplace.scheduler.choco.transition.VMTransition in project scheduler by btrplace.

the class CResourceCapacity method injectContinuous.

private boolean injectContinuous(ReconfigurationProblem rp, CShareableResource rcm) throws SchedulerException {
    // The constraint must be already satisfied
    if (!cstr.isSatisfied(rp.getSourceModel())) {
        rp.getLogger().error("The constraint '{}' must be already satisfied to provide a continuous restriction", cstr);
        return false;
    }
    int[] alias = new int[cstr.getInvolvedNodes().size()];
    int i = 0;
    for (Node n : cstr.getInvolvedNodes()) {
        alias[i++] = rp.getNode(n);
    }
    TIntArrayList cUse = new TIntArrayList();
    List<IntVar> dUse = new ArrayList<>();
    for (VM vmId : rp.getVMs()) {
        VMTransition a = rp.getVMAction(vmId);
        Slice c = a.getCSlice();
        Slice d = a.getDSlice();
        if (c != null) {
            cUse.add(rcm.getSourceResource().getConsumption(vmId));
        }
        if (d != null) {
            int m = rcm.getVMAllocation(rp.getVM(vmId));
            dUse.add(rp.fixed(m, "vmAllocation('", rcm.getResourceIdentifier(), "', '", vmId, "'"));
        }
    }
    ChocoView v = rp.getView(AliasedCumulatives.VIEW_ID);
    if (v == null) {
        throw SchedulerModelingException.missingView(rp.getSourceModel(), AliasedCumulatives.VIEW_ID);
    }
    ((AliasedCumulatives) v).addDim(cstr.getAmount(), cUse.toArray(), dUse.toArray(new IntVar[dUse.size()]), alias);
    return true;
}
Also used : ChocoView(org.btrplace.scheduler.choco.view.ChocoView) Slice(org.btrplace.scheduler.choco.Slice) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) AliasedCumulatives(org.btrplace.scheduler.choco.view.AliasedCumulatives) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) IntVar(org.chocosolver.solver.variables.IntVar) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Aggregations

VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)41 VM (org.btrplace.model.VM)34 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)23 Node (org.btrplace.model.Node)22 IntVar (org.chocosolver.solver.variables.IntVar)22 ArrayList (java.util.ArrayList)18 Model (org.btrplace.model.Model)17 HashSet (java.util.HashSet)16 Mapping (org.btrplace.model.Mapping)16 Slice (org.btrplace.scheduler.choco.Slice)16 DefaultModel (org.btrplace.model.DefaultModel)12 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)12 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)12 StayAwayVM (org.btrplace.scheduler.choco.transition.StayAwayVM)12 Test (org.testng.annotations.Test)12 BootVM (org.btrplace.scheduler.choco.transition.BootVM)11 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)11 KillVM (org.btrplace.scheduler.choco.transition.KillVM)11 ResumeVM (org.btrplace.scheduler.choco.transition.ResumeVM)11 ShutdownVM (org.btrplace.scheduler.choco.transition.ShutdownVM)11