Search in sources :

Example 1 with Node

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

the class DefaultReconfigurationProblemTest method testManageableVMs.

@Test
public void testManageableVMs() 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);
    Set<VM> runnings = new HashSet<>(map.getRunningVMs());
    runnings.add(vm6);
    runnings.add(vm5);
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.emptySet(), runnings, map.getSleepingVMs(), Collections.emptySet()).setManageableVMs(map.getRunningVMs(n1)).build();
    /*
          vm1: running -> running
          vm2: running-> running
          vm3: running -> running
          vm4: sleeping -> sleeping
          vm5: ready -> running
          vm6: ready -> running

         * manageable_runnings: vm1, vm2
         * manageable: vm1, vm2, vm5, vm6 (with ids: vm#0, vm#1, vm#4, vm#5)
         */
    Set<VM> manageable = rp.getManageableVMs();
    Assert.assertEquals(manageable.size(), 4, manageable.toString());
    Assert.assertTrue(manageable.containsAll(Arrays.asList(vm6, vm5, vm1, vm2)));
    // Check the action model that has been used for each of the VM.
    for (VM vm : map.getAllVMs()) {
        Assert.assertEquals(manageable.contains(vm), rp.getVMAction(vm).isManaged());
    }
}
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) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 2 with Node

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

the class DefaultReconfigurationProblemTest method testVMToShutdown.

@Test
public void testVMToShutdown() 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(Collections.singleton(vm1), new HashSet<>(), new HashSet<>(), new HashSet<>()).build();
    VMTransition a = rp.getVMActions().get(0);
    Assert.assertEquals(a, rp.getVMAction(vm1));
    Assert.assertEquals(ShutdownVM.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 3 with Node

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

the class DefaultReconfigurationProblemTest method testVMStaySleeping.

@Test
public void testVMStaySleeping() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().addOnlineNode(n1);
    mo.getMapping().addSleepingVM(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(StayAwayVM.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) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 4 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)

Example 5 with Node

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

the class DefaultReconfigurationProblem method makeCardinalityVariables.

/**
 * Create the cardinality variables.
 */
private void makeCardinalityVariables() {
    vmsCountOnNodes = new ArrayList<>(nodes.size());
    int nbVMs = vms.size();
    for (Node n : nodes) {
        vmsCountOnNodes.add(csp.intVar(makeVarLabel("nbVMsOn('", n, "')"), 0, nbVMs, true));
    }
    vmsCountOnNodes = Collections.unmodifiableList(vmsCountOnNodes);
}
Also used : Node(org.btrplace.model.Node)

Aggregations

Node (org.btrplace.model.Node)382 DefaultModel (org.btrplace.model.DefaultModel)278 Model (org.btrplace.model.Model)276 VM (org.btrplace.model.VM)262 Test (org.testng.annotations.Test)259 Mapping (org.btrplace.model.Mapping)187 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)142 HashSet (java.util.HashSet)95 SatConstraint (org.btrplace.model.constraint.SatConstraint)87 ArrayList (java.util.ArrayList)86 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)82 MigrateVM (org.btrplace.plan.event.MigrateVM)72 ShareableResource (org.btrplace.model.view.ShareableResource)71 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)64 ShutdownNode (org.btrplace.plan.event.ShutdownNode)52 Instance (org.btrplace.model.Instance)43 BootNode (org.btrplace.plan.event.BootNode)41 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)40 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)36 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)36