Search in sources :

Example 6 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class TimedBasedActionComparatorTest method testPrecedence.

@Test
public void testPrecedence() {
    Action a = new MockAction(vm, 0, 4);
    Action b = new MockAction(vm, 4, 10);
    Assert.assertTrue(startCmp.compare(a, b) < 0);
    Assert.assertTrue(startCmp.compare(b, a) > 0);
    Assert.assertTrue(stopCmp.compare(a, b) < 0);
    Assert.assertTrue(stopCmp.compare(b, a) > 0);
}
Also used : Action(org.btrplace.plan.event.Action) Test(org.testng.annotations.Test)

Example 7 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class TimedBasedActionComparatorTest method testOverlap2.

@Test
public void testOverlap2() {
    Action a = new MockAction(vm, 0, 4);
    Action b = new MockAction(vm, 0, 3);
    Assert.assertTrue(startCmp.compare(a, b) > 0);
    Assert.assertTrue(stopCmp.compare(a, b) > 0);
}
Also used : Action(org.btrplace.plan.event.Action) Test(org.testng.annotations.Test)

Example 8 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class RelocatableVM method insertActions.

@Override
public boolean insertActions(Solution s, ReconfigurationPlan plan) {
    DurationEvaluators dev = rp.getDurationEvaluators();
    // Only if the VM doesn't stay
    if (s.getIntVal(cSlice.getHoster()) != (s.getIntVal(dSlice.getHoster()))) {
        Action a;
        Node dst = rp.getNode(s.getIntVal(dSlice.getHoster()));
        // Migration
        if (s.getIntVal(doReinstantiation) == 0) {
            int st = s.getIntVal(getStart());
            int ed = s.getIntVal(getEnd());
            if (getBandwidth() != null) {
                a = new MigrateVM(vm, src, dst, st, ed, s.getIntVal(getBandwidth()));
            } else {
                a = new MigrateVM(vm, src, dst, st, ed);
            }
            plan.add(a);
        // Re-instantiation
        } else {
            VM newVM = rp.cloneVM(vm);
            if (newVM == null) {
                rp.getLogger().error("Unable to get a new int to plan the re-instantiate of VM {}", vm);
                return false;
            }
            org.btrplace.plan.event.ForgeVM fvm = new org.btrplace.plan.event.ForgeVM(newVM, s.getIntVal(dSlice.getStart()) - dev.evaluate(rp.getSourceModel(), org.btrplace.plan.event.ForgeVM.class, vm), s.getIntVal(dSlice.getStart()));
            // forge the new VM from a template
            plan.add(fvm);
            // Boot the new VM
            int endForging = fvm.getEnd();
            org.btrplace.plan.event.BootVM boot = new org.btrplace.plan.event.BootVM(newVM, dst, endForging, endForging + dev.evaluate(rp.getSourceModel(), org.btrplace.plan.event.BootVM.class, newVM));
            boot.addEvent(Action.Hook.PRE, new SubstitutedVMEvent(vm, newVM));
            return plan.add(boot) && plan.add(new org.btrplace.plan.event.ShutdownVM(vm, src, boot.getEnd(), s.getIntVal(cSlice.getEnd())));
        }
    }
    return true;
}
Also used : Action(org.btrplace.plan.event.Action) Node(org.btrplace.model.Node) MigrateVM(org.btrplace.plan.event.MigrateVM) SubstitutedVMEvent(org.btrplace.plan.event.SubstitutedVMEvent) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators)

Example 9 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class DependencyBasedPlanApplier method apply.

@Override
public Model apply(ReconfigurationPlan p) {
    int nbCommitted = 0;
    ReconfigurationPlanMonitor rpm = new DefaultReconfigurationPlanMonitor(p);
    Set<Action> feasible = new HashSet<>();
    for (Action a : p.getActions()) {
        if (!rpm.isBlocked(a)) {
            feasible.add(a);
        }
    }
    while (nbCommitted != p.getSize()) {
        Set<Action> newFeasible = new HashSet<>();
        for (Action a : feasible) {
            Set<Action> s = rpm.commit(a);
            fireAction(a);
            newFeasible.addAll(s);
            nbCommitted++;
        }
        feasible = newFeasible;
    }
    return rpm.getCurrentModel();
}
Also used : Action(org.btrplace.plan.event.Action) HashSet(java.util.HashSet)

Example 10 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class TimeBasedPlanApplier method apply.

@Override
public Model apply(ReconfigurationPlan p) {
    Model res = p.getOrigin().copy();
    List<Action> actions = new ArrayList<>(p.getActions());
    Collections.sort(actions, startFirstComparator);
    for (Action a : actions) {
        if (!a.apply(res)) {
            return null;
        }
        fireAction(a);
    }
    return res;
}
Also used : Action(org.btrplace.plan.event.Action) Model(org.btrplace.model.Model)

Aggregations

Action (org.btrplace.plan.event.Action)40 Test (org.testng.annotations.Test)25 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)18 MigrateVM (org.btrplace.plan.event.MigrateVM)10 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)10 HashSet (java.util.HashSet)9 Parameters (org.btrplace.scheduler.choco.Parameters)9 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)9 VM (org.btrplace.model.VM)8 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)8 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)8 Model (org.btrplace.model.Model)7 CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)7 ArrayList (java.util.ArrayList)6 SatConstraint (org.btrplace.model.constraint.SatConstraint)6 Node (org.btrplace.model.Node)5 ShareableResource (org.btrplace.model.view.ShareableResource)5 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)5 BootVM (org.btrplace.plan.event.BootVM)4 ShutdownNode (org.btrplace.plan.event.ShutdownNode)4