Search in sources :

Example 66 with Mapping

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

the class ReconfigurationPlanFuzzer method setDestinationState.

private void setDestinationState(ReconfigurationPlan p, VM v) {
    Mapping map = p.getOrigin().getMapping();
    Node host = map.getVMLocation(v);
    int n = rnd.nextInt(dstReadyVMs + dstRunningVMs + dstSleepingVMs);
    int[] bounds = schedule();
    int duration = bounds[1] - bounds[0];
    if (n < dstReadyVMs) {
        if (host != null) {
            p.add(new ShutdownVM(v, host, bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(v, "shutdown", duration);
        }
    } else if (n < dstReadyVMs + dstRunningVMs) {
        if (host == null) {
            p.add(new BootVM(v, pick(map.getAllNodes()), bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(v, "boot", duration);
        } else {
            // was running -> migrate
            if (map.isRunning(v)) {
                Node dst = pick(map.getAllNodes());
                if (!host.equals(dst)) {
                    p.add(new MigrateVM(v, host, dst, bounds[0], bounds[1]));
                    p.getOrigin().getAttributes().put(v, "migrate", duration);
                }
            } else {
                // was sleeping -> resume
                p.add(new ResumeVM(v, host, pick(map.getAllNodes()), bounds[0], bounds[1]));
                p.getOrigin().getAttributes().put(v, "resume", duration);
            }
        }
    } else {
        // moving to sleeping state
        if (map.isRunning(v)) {
            p.add(new SuspendVM(v, host, host, bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(v, "sleeping", duration);
        }
    }
}
Also used : ResumeVM(org.btrplace.plan.event.ResumeVM) SuspendVM(org.btrplace.plan.event.SuspendVM) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) BootVM(org.btrplace.plan.event.BootVM) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM)

Example 67 with Mapping

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

the class NetworkFuzzer method decorate.

@Override
public void decorate(ReconfigurationPlan p) {
    Network net = new Network();
    Mapping m = p.getOrigin().getMapping();
    Switch s = net.newSwitch(1000 * (1 + rnd.nextInt(40)));
    for (Node n : m.getAllNodes()) {
        int bw = 1000 * (1 + rnd.nextInt(40));
        net.connect(bw, s, n);
    }
}
Also used : Switch(org.btrplace.model.view.network.Switch) Network(org.btrplace.model.view.network.Network) Node(org.btrplace.model.Node) Mapping(org.btrplace.model.Mapping)

Example 68 with Mapping

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

the class FixedNodeSetsPartitioning method getVMsToLaunch.

private Set<VM> getVMsToLaunch(Instance i) {
    Mapping m = i.getModel().getMapping();
    Set<VM> toLaunch = new THashSet<>();
    for (SatConstraint cstr : i.getSatConstraints()) {
        // Extract the VMs to launch
        if (cstr instanceof Running) {
            for (VM v : cstr.getInvolvedVMs()) {
                if (m.isReady(v)) {
                    m.remove(v);
                    toLaunch.add(v);
                }
            }
        }
    }
    return toLaunch;
}
Also used : VM(org.btrplace.model.VM) SatConstraint(org.btrplace.model.constraint.SatConstraint) Running(org.btrplace.model.constraint.Running) Mapping(org.btrplace.model.Mapping) THashSet(gnu.trove.set.hash.THashSet)

Example 69 with Mapping

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

the class RelocatableVMTest method testForcedToMove.

@Test
public void testForcedToMove() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addRunningVM(vm1, n1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(MigrateVM.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.emptySet(), map.getAllVMs(), Collections.emptySet(), Collections.emptySet()).setParams(ps).build();
    rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
    rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
    RelocatableVM am = (RelocatableVM) rp.getVMAction(vm1);
    Assert.assertTrue(am.getRelocationMethod().isInstantiatedTo(0));
    Assert.assertEquals(vm1, am.getVM());
    Assert.assertEquals(2, am.getDuration().getDomainSize());
    Assert.assertEquals(0, am.getDuration().getLB());
    Assert.assertEquals(5, am.getDuration().getUB());
    Assert.assertFalse(am.getStart().isInstantiated());
    Assert.assertFalse(am.getEnd().isInstantiated());
    Assert.assertNotNull(am.getCSlice());
    Assert.assertTrue(am.getCSlice().getHoster().isInstantiatedTo(rp.getNode(n1)));
    Assert.assertTrue(am.getState().isInstantiatedTo(1));
    Assert.assertNotNull(am.getDSlice());
    Assert.assertFalse(am.getDSlice().getHoster().isInstantiated());
    // No VMs on n1, discrete mode
    rp.getModel().post(rp.getModel().arithm(rp.getNbRunningVMs().get(rp.getNode(n1)), "=", 0));
    new CMinMTTR().inject(new DefaultParameters(), rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Model m = p.getResult();
    Assert.assertEquals(n2, m.getMapping().getVMLocation(vm1));
    MigrateVM a = (MigrateVM) p.getActions().iterator().next();
    Assert.assertEquals(0, a.getStart());
    Assert.assertEquals(5, a.getEnd());
    Assert.assertEquals(n1, a.getSourceNode());
    Assert.assertEquals(n2, a.getDestinationNode());
    Assert.assertEquals(vm1, a.getVM());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) Parameters(org.btrplace.scheduler.choco.Parameters) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Example 70 with Mapping

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

the class RelocatableVMTest method testForcedToStay.

@Test
public void testForcedToStay() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addRunningVM(vm1, n1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(MigrateVM.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.emptySet(), map.getAllVMs(), Collections.emptySet(), Collections.emptySet()).setParams(ps).build();
    rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
    rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
    RelocatableVM am = (RelocatableVM) rp.getVMAction(vm1);
    // No VMs on n2
    rp.getNbRunningVMs().get(rp.getNode(n2)).instantiateTo(0, Cause.Null);
    new CMinMTTR().inject(new DefaultParameters(), rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Assert.assertEquals(0, p.getSize());
    Assert.assertTrue(am.getDuration().isInstantiatedTo(0));
    Assert.assertTrue(am.getDSlice().getHoster().isInstantiatedTo(rp.getNode(n1)));
    Assert.assertTrue(am.getStart().isInstantiatedTo(0));
    Assert.assertTrue(am.getEnd().isInstantiatedTo(0));
    Model m = p.getResult();
    Assert.assertEquals(n1, m.getMapping().getVMLocation(vm1));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) Parameters(org.btrplace.scheduler.choco.Parameters) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Mapping(org.btrplace.model.Mapping) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Aggregations

Mapping (org.btrplace.model.Mapping)83 Node (org.btrplace.model.Node)68 VM (org.btrplace.model.VM)62 Model (org.btrplace.model.Model)42 DefaultModel (org.btrplace.model.DefaultModel)39 Test (org.testng.annotations.Test)39 HashSet (java.util.HashSet)29 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)23 ShareableResource (org.btrplace.model.view.ShareableResource)16 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)16 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)15 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)15 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)15 IntVar (org.chocosolver.solver.variables.IntVar)15 SatConstraint (org.btrplace.model.constraint.SatConstraint)14 BootVM (org.btrplace.scheduler.choco.transition.BootVM)14 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)14 KillVM (org.btrplace.scheduler.choco.transition.KillVM)14 ResumeVM (org.btrplace.scheduler.choco.transition.ResumeVM)14 ShutdownVM (org.btrplace.scheduler.choco.transition.ShutdownVM)14