Search in sources :

Example 81 with Mapping

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

the class CSleeping method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    VM v = cstr.getInvolvedVMs().iterator().next();
    Mapping map = i.getModel().getMapping();
    if (!map.isSleeping(v)) {
        return Collections.singleton(v);
    }
    return Collections.emptySet();
}
Also used : VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping)

Example 82 with Mapping

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

the class CSplit method fullfillOthers.

private static void fullfillOthers(ReconfigurationProblem rp, TIntArrayList[] otherPositions, List<IntVar>[] otherEnds, List<List<VM>> vmGroups) {
    Mapping map = rp.getSourceModel().getMapping();
    // Fulfill the others stuff.
    for (int i = 0; i < vmGroups.size(); i++) {
        List<VM> grp = vmGroups.get(i);
        for (VM vm : grp) {
            if (map.isRunning(vm)) {
                int myPos = rp.getNode(map.getVMLocation(vm));
                IntVar myEnd = rp.getVMAction(vm).getCSlice().getEnd();
                for (int j = 0; j < vmGroups.size(); j++) {
                    if (i != j) {
                        otherPositions[j].add(myPos);
                        otherEnds[j].add(myEnd);
                    }
                }
            }
        }
    }
}
Also used : VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping) IntVar(org.chocosolver.solver.variables.IntVar)

Example 83 with Mapping

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

the class ExamplesTest method testExample.

@Test
public void testExample() throws ScriptBuilderException {
    // Set the environment
    Model mo = new DefaultModel();
    // Make the builder and add the sources location to the include path
    ScriptBuilder scrBuilder = new ScriptBuilder(mo);
    ((PathBasedIncludes) scrBuilder.getIncludes()).addPath(new File("src/test/resources/org/btrplace/btrpsl/examples"));
    // Parse myApp.btrp
    Script myApp = scrBuilder.build(new File("src/test/resources/org/btrplace/btrpsl/examples/myApp.btrp"));
    Assert.assertEquals(myApp.getVMs().size(), 24);
    Assert.assertEquals(myApp.getNodes().size(), 0);
    Assert.assertEquals(myApp.getConstraints().size(), 5);
    // Check the resulting mapping
    Mapping map = mo.getMapping();
    Assert.assertEquals(map.getReadyVMs().size(), 24);
    Assert.assertEquals(map.getOfflineNodes().size(), 251);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Mapping(org.btrplace.model.Mapping) PathBasedIncludes(org.btrplace.btrpsl.includes.PathBasedIncludes) File(java.io.File) 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