Search in sources :

Example 1 with Fence

use of org.btrplace.model.constraint.Fence in project scheduler by btrplace.

the class UCC15 method decommissioning_40gb.

public SolvingStatistics decommissioning_40gb() throws SchedulerException {
    // Set nb of nodes and vms
    int nbNodesRack = 24;
    int nbSrcNodes = nbNodesRack * 8;
    int nbDstNodes = nbNodesRack * 4;
    int nbVMs = nbSrcNodes * 2;
    // Set mem + cpu for VMs and Nodes
    int memVM = 4;
    int cpuVM = 1;
    int memSrcNode = 16;
    int cpuSrcNode = 4;
    int memDstNode = 16;
    int cpuDstNode = 4;
    // Set memoryUsed and dirtyRate (for all VMs)
    int tpl1MemUsed = 2000;
    int tpl1MaxDirtySize = 5;
    int tpl1MaxDirtyDuration = 3;
    // idle vm
    double tpl1DirtyRate = 0;
    int tpl2MemUsed = 4000;
    int tpl2MaxDirtySize = 96;
    int tpl2MaxDirtyDuration = 2;
    // stress --vm 1000 --bytes 70K
    double tpl2DirtyRate = 3;
    int tpl3MemUsed = 2000;
    int tpl3MaxDirtySize = 96;
    int tpl3MaxDirtyDuration = 2;
    // stress --vm 1000 --bytes 70K
    double tpl3DirtyRate = 3;
    int tpl4MemUsed = 4000;
    int tpl4MaxDirtySize = 5;
    int tpl4MaxDirtyDuration = 3;
    // idle vm
    double tpl4DirtyRate = 0;
    // New default model
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    // Create online source nodes and offline destination nodes
    List<Node> srcNodes = new ArrayList<>();
    List<Node> dstNodes = new ArrayList<>();
    for (int i = 0; i < nbSrcNodes; i++) {
        srcNodes.add(mo.newNode());
        ma.addOnlineNode(srcNodes.get(i));
    }
    for (int i = 0; i < nbDstNodes; i++) {
        dstNodes.add(mo.newNode());
        ma.addOfflineNode(dstNodes.get(i));
    }
    // Set boot and shutdown time
    for (Node n : dstNodes) {
        mo.getAttributes().put(n, "boot", 120);
    /*~2 minutes to boot*/
    }
    for (Node n : srcNodes) {
        mo.getAttributes().put(n, "shutdown", 17);
    /*~30 seconds to shutdown*/
    }
    // Create running VMs on src nodes
    List<VM> vms = new ArrayList<>();
    VM v;
    for (int i = 0; i < nbSrcNodes; i++) {
        if (i % 2 == 0) {
            v = mo.newVM();
            vms.add(v);
            mo.getAttributes().put(v, "memUsed", tpl1MemUsed);
            mo.getAttributes().put(v, "coldDirtyRate", tpl1DirtyRate);
            mo.getAttributes().put(v, "hotDirtySize", tpl1MaxDirtySize);
            mo.getAttributes().put(v, "hotDirtyDuration", tpl1MaxDirtyDuration);
            ma.addRunningVM(v, srcNodes.get(i));
            v = mo.newVM();
            vms.add(v);
            mo.getAttributes().put(v, "memUsed", tpl2MemUsed);
            mo.getAttributes().put(v, "coldDirtyRate", tpl2DirtyRate);
            mo.getAttributes().put(v, "hotDirtySize", tpl2MaxDirtySize);
            mo.getAttributes().put(v, "hotDirtyDuration", tpl2MaxDirtyDuration);
            ma.addRunningVM(v, srcNodes.get(i));
        } else {
            v = mo.newVM();
            vms.add(v);
            mo.getAttributes().put(v, "memUsed", tpl3MemUsed);
            mo.getAttributes().put(v, "coldDirtyRate", tpl3DirtyRate);
            mo.getAttributes().put(v, "hotDirtySize", tpl3MaxDirtySize);
            mo.getAttributes().put(v, "hotDirtyDuration", tpl3MaxDirtyDuration);
            ma.addRunningVM(v, srcNodes.get(i));
            v = mo.newVM();
            vms.add(v);
            mo.getAttributes().put(v, "memUsed", tpl4MemUsed);
            mo.getAttributes().put(v, "coldDirtyRate", tpl4DirtyRate);
            mo.getAttributes().put(v, "hotDirtySize", tpl4MaxDirtySize);
            mo.getAttributes().put(v, "hotDirtyDuration", tpl4MaxDirtyDuration);
            ma.addRunningVM(v, srcNodes.get(i));
        }
    }
    // Add resource decorators
    ShareableResource rcMem = new ShareableResource("mem", 0, 0);
    ShareableResource rcCPU = new ShareableResource("cpu", 0, 0);
    for (Node n : srcNodes) {
        rcMem.setCapacity(n, memSrcNode);
        rcCPU.setCapacity(n, cpuSrcNode);
    }
    for (Node n : dstNodes) {
        rcMem.setCapacity(n, memDstNode);
        rcCPU.setCapacity(n, cpuDstNode);
    }
    for (VM vm : vms) {
        rcMem.setConsumption(vm, memVM);
        rcCPU.setConsumption(vm, cpuVM);
    }
    mo.attach(rcMem);
    mo.attach(rcCPU);
    // Add a NetworkView view
    Network net = new Network();
    Switch swSrcRack1 = net.newSwitch();
    Switch swSrcRack2 = net.newSwitch();
    Switch swSrcRack3 = net.newSwitch();
    Switch swSrcRack4 = net.newSwitch();
    Switch swSrcRack5 = net.newSwitch();
    Switch swSrcRack6 = net.newSwitch();
    Switch swSrcRack7 = net.newSwitch();
    Switch swSrcRack8 = net.newSwitch();
    Switch swDstRack1 = net.newSwitch();
    Switch swDstRack2 = net.newSwitch();
    Switch swDstRack3 = net.newSwitch();
    Switch swDstRack4 = net.newSwitch();
    Switch swMain = net.newSwitch();
    net.connect(1000, swSrcRack1, srcNodes.subList(0, nbNodesRack));
    net.connect(1000, swSrcRack2, srcNodes.subList(nbNodesRack, nbNodesRack * 2));
    net.connect(1000, swSrcRack3, srcNodes.subList(nbNodesRack * 2, nbNodesRack * 3));
    net.connect(1000, swSrcRack4, srcNodes.subList(nbNodesRack * 3, nbNodesRack * 4));
    net.connect(1000, swSrcRack5, srcNodes.subList(nbNodesRack * 4, nbNodesRack * 5));
    net.connect(1000, swSrcRack6, srcNodes.subList(nbNodesRack * 5, nbNodesRack * 6));
    net.connect(1000, swSrcRack7, srcNodes.subList(nbNodesRack * 6, nbNodesRack * 7));
    net.connect(1000, swSrcRack8, srcNodes.subList(nbNodesRack * 7, nbNodesRack * 8));
    net.connect(1000, swDstRack1, dstNodes.subList(0, nbNodesRack));
    net.connect(1000, swDstRack2, dstNodes.subList(nbNodesRack, nbNodesRack * 2));
    net.connect(1000, swDstRack3, dstNodes.subList(nbNodesRack * 2, nbNodesRack * 3));
    net.connect(1000, swDstRack4, dstNodes.subList(nbNodesRack * 3, nbNodesRack * 4));
    net.connect(40000, swMain, swSrcRack1, swSrcRack2, swSrcRack3, swSrcRack4, swSrcRack5, swSrcRack6, swSrcRack7, swSrcRack8, swDstRack1, swDstRack2, swDstRack3, swDstRack4);
    mo.attach(net);
    // net.generateDot(path + "topology.dot", false);
    // Set parameters
    DefaultParameters ps = new DefaultParameters();
    ps.setVerbosity(0);
    ps.setTimeLimit(60);
    // ps.setMaxEnd(600);
    ps.doOptimize(false);
    // Migrate all VMs to destination nodes
    List<SatConstraint> cstrs = new ArrayList<>();
    int vm_num = 0;
    for (int i = 0; i < nbDstNodes; i++) {
        cstrs.add(new Fence(vms.get(vm_num), Collections.singleton(dstNodes.get(i))));
        cstrs.add(new Fence(vms.get(vm_num + 1), Collections.singleton(dstNodes.get(i))));
        cstrs.add(new Fence(vms.get(nbVMs - 1 - vm_num), Collections.singleton(dstNodes.get(i))));
        cstrs.add(new Fence(vms.get(nbVMs - 2 - vm_num), Collections.singleton(dstNodes.get(i))));
        vm_num += 2;
    }
    // Shutdown source nodes
    cstrs.addAll(srcNodes.stream().map(Offline::new).collect(Collectors.toList()));
    // Set a custom objective
    DefaultChocoScheduler sc = new DefaultChocoScheduler(ps);
    Instance i = new Instance(mo, cstrs, new MinMTTRMig());
    ReconfigurationPlan p;
    try {
        p = sc.solve(i);
        Assert.assertNotNull(p);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // finally {
    return sc.getStatistics();
// }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Offline(org.btrplace.model.constraint.Offline) Mapping(org.btrplace.model.Mapping) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) SchedulerException(org.btrplace.scheduler.SchedulerException) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Network(org.btrplace.model.view.network.Network) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Fence(org.btrplace.model.constraint.Fence)

Example 2 with Fence

use of org.btrplace.model.constraint.Fence in project scheduler by btrplace.

the class BenchTest method instance.

public static Instance instance() {
    Model mo = new DefaultModel();
    VM v1 = mo.newVM();
    VM v2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, v1).run(n2, v2).off(n3);
    Set<VM> s = new HashSet<>();
    s.add(v1);
    s.add(v2);
    List<SatConstraint> cstrs = Arrays.asList(new Spread(s, true), new Fence(v1, n2), new Offline(n1));
    return new Instance(mo, cstrs, new MinMTTR());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) MinMTTR(org.btrplace.model.constraint.MinMTTR) Offline(org.btrplace.model.constraint.Offline) Spread(org.btrplace.model.constraint.Spread) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet)

Example 3 with Fence

use of org.btrplace.model.constraint.Fence in project scheduler by btrplace.

the class CAmongTest method testWithNoSolution.

/**
 * No solution because constraints force to spread the VMs among 2 groups.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution() 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();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2, vm3).ready(vm4, vm5);
    Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm5));
    Collection<Node> s = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s, s2));
    Among a = new Among(vms, pGrps);
    a.setContinuous(false);
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(new Fence(vm2, Collections.singleton(n3)));
    cstrs.add(new Fence(vm1, Collections.singleton(n1)));
    cstrs.add(a);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Mapping(org.btrplace.model.Mapping) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Collection(java.util.Collection) Among(org.btrplace.model.constraint.Among) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 4 with Fence

use of org.btrplace.model.constraint.Fence in project scheduler by btrplace.

the class CAmongTest method testWithGroupChange.

@Test
public void testWithGroupChange() 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();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2, vm3).ready(vm4, vm5);
    Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm5));
    Collection<Node> s1 = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Collection<Node>> pGrps = Arrays.asList(s1, s2);
    Among a = new Among(vms, pGrps);
    a.setContinuous(false);
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(new Fence(vm2, s2));
    cstrs.add(a);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
// System.out.println(p);
// Assert.assertEquals(a.isSatisfied(p.getResult()), SatConstraint.Sat.SATISFIED);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Mapping(org.btrplace.model.Mapping) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Collection(java.util.Collection) Among(org.btrplace.model.constraint.Among) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 5 with Fence

use of org.btrplace.model.constraint.Fence in project scheduler by btrplace.

the class CAmongTest method testContinuousWithNotAlreadySatisfied.

@Test
public void testContinuousWithNotAlreadySatisfied() 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();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2).run(n3, vm3).ready(vm4, vm5);
    Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm5));
    Collection<Node> s1 = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s1, s2));
    Among a = new Among(vms, pGrps);
    a.setContinuous(true);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(new Fence(vm2, Collections.singleton(n3)));
    cstrs.add(a);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Mapping(org.btrplace.model.Mapping) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Collection(java.util.Collection) Among(org.btrplace.model.constraint.Among) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

Fence (org.btrplace.model.constraint.Fence)30 Model (org.btrplace.model.Model)27 VM (org.btrplace.model.VM)27 SatConstraint (org.btrplace.model.constraint.SatConstraint)27 DefaultModel (org.btrplace.model.DefaultModel)26 Node (org.btrplace.model.Node)26 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)25 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)23 ArrayList (java.util.ArrayList)22 Test (org.testng.annotations.Test)22 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)19 Mapping (org.btrplace.model.Mapping)16 HashSet (java.util.HashSet)11 ShareableResource (org.btrplace.model.view.ShareableResource)10 Collection (java.util.Collection)7 Instance (org.btrplace.model.Instance)7 Offline (org.btrplace.model.constraint.Offline)7 Network (org.btrplace.model.view.network.Network)7 Switch (org.btrplace.model.view.network.Switch)6 SchedulerException (org.btrplace.scheduler.SchedulerException)6