Search in sources :

Example 1 with Deadline

use of org.btrplace.model.constraint.migration.Deadline in project scheduler by btrplace.

the class DeadlineConverterTest method testViables.

@Test
public void testViables() throws JSONConverterException {
    Model mo = new DefaultModel();
    ConstraintsConverter conv = new ConstraintsConverter();
    conv.register(new DeadlineConverter());
    Deadline d = new Deadline(mo.newVM(), "+00:00:15");
    Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(d)), d);
    System.out.println(conv.toJSON(d));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) ConstraintsConverter(org.btrplace.json.model.constraint.ConstraintsConverter) Deadline(org.btrplace.model.constraint.migration.Deadline) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 2 with Deadline

use of org.btrplace.model.constraint.migration.Deadline in project scheduler by btrplace.

the class AdvancedMigScheduling method run.

@Override
public void run() {
    Model mo = makeModel();
    // Create, define, and attach CPU and Mem resource decorators for nodes and VMs
    int memSrc = 8;
    int cpuSrc = 4;
    int memDst = 16;
    int cpuDst = 8;
    ShareableResource rcMem = new ShareableResource("mem", 0, 8);
    ShareableResource rcCPU = new ShareableResource("cpu", 0, 4);
    // VMs resources consumption
    // Nodes resources capacity
    rcMem.setCapacity(srcNode1, memSrc).setCapacity(srcNode2, memSrc).setCapacity(srcNode3, memSrc).setCapacity(srcNode4, memSrc).setCapacity(dstNode1, memDst).setCapacity(dstNode2, memDst);
    rcCPU.setCapacity(srcNode1, cpuSrc).setCapacity(srcNode2, cpuSrc).setCapacity(srcNode3, cpuSrc).setCapacity(srcNode4, cpuSrc).setCapacity(dstNode1, cpuDst).setCapacity(dstNode2, cpuDst);
    mo.attach(rcMem);
    mo.attach(rcCPU);
    // Set VM attributes 'hot dirty page size', 'hot dirty page duration', and 'cold dirty pages rate'
    // to simulate a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
    int vmHds = 56;
    int vmHdd = 2;
    double vmCdr = 22.6;
    // vm0 is an 'idle' VM (with no special memory activity) but still consumes 2 GiB of memory
    mo.getAttributes().put(vm0, "memUsed", 2000);
    // vm1 is an 'idle' VM (with no special memory activity) but still consumes 4 GiB of memory
    mo.getAttributes().put(vm1, "memUsed", 3000);
    // vm2 consumes 4 GiB memory and has a memory intensive workload
    mo.getAttributes().put(vm2, "memUsed", 4000);
    mo.getAttributes().put(vm2, "hotDirtySize", vmHds);
    mo.getAttributes().put(vm2, "hotDirtyDuration", vmHdd);
    mo.getAttributes().put(vm2, "coldDirtyRate", vmCdr);
    // vm3 consumes 6 GiB memory and has a memory intensive workload
    mo.getAttributes().put(vm3, "memUsed", 5000);
    mo.getAttributes().put(vm3, "hotDirtySize", vmHds);
    mo.getAttributes().put(vm3, "hotDirtyDuration", vmHdd);
    mo.getAttributes().put(vm3, "coldDirtyRate", vmCdr);
    // Attach a network view
    Network net = new Network();
    mo.attach(net);
    Switch swMain = net.newSwitch(30000);
    net.connect(10000, swMain, srcNode1, srcNode2, srcNode3, srcNode4);
    // The destination nodes have twice the bandwidth of source nodes
    net.connect(20000, swMain, dstNode1, dstNode2);
    // Create constraints
    List<SatConstraint> cstrs = new ArrayList<>();
    // We want to boot the destination nodes
    cstrs.addAll(Online.newOnline(dstNode1, dstNode2));
    // We want to shutdown the source nodes
    cstrs.addAll(Offline.newOffline(srcNode1, srcNode2, srcNode3, srcNode4));
    // Try to solve as is, and show the computed plan
    solve(mo, cstrs);
    /**
     ******* Add some migrations scheduling constraints ********
     */
    // We want vm0 and vm1 migrations to terminate at the same time
    cstrs.add(new Sync(vm0, vm1));
    // We want to serialize the migrations of vm1, vm2, and vm3
    cstrs.add(new Serialize(new HashSet<>(Arrays.asList(vm1, vm2, vm3))));
    // We want vm0 migration terminate before vm2 start to migrate
    cstrs.add(new Precedence(vm1, vm2));
    // We want vm3 migration terminate before 10s
    cstrs.add(new Deadline(vm3, "+0:0:10"));
    // Try to solve, and show the computed plan
    solve(mo, cstrs);
}
Also used : Serialize(org.btrplace.model.constraint.migration.Serialize) SatConstraint(org.btrplace.model.constraint.SatConstraint) Deadline(org.btrplace.model.constraint.migration.Deadline) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) Switch(org.btrplace.model.view.network.Switch) Network(org.btrplace.model.view.network.Network) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Sync(org.btrplace.model.constraint.migration.Sync) Precedence(org.btrplace.model.constraint.migration.Precedence) HashSet(java.util.HashSet)

Example 3 with Deadline

use of org.btrplace.model.constraint.migration.Deadline in project scheduler by btrplace.

the class CDeadlineTest method testKo.

@Test
public void testKo() throws SchedulerException {
    // New default model
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    // Create and boot 2 source nodes and 1 destination node
    Node srcNode1 = mo.newNode();
    Node srcNode2 = mo.newNode();
    Node dstNode = mo.newNode();
    ma.addOnlineNode(srcNode1);
    ma.addOnlineNode(srcNode2);
    ma.addOnlineNode(dstNode);
    // Attach a network view
    Network net = new Network();
    mo.attach(net);
    // Connect the nodes through a main non-blocking switch with 1 Gbit/s links
    Switch swMain = net.newSwitch();
    net.connect(1000, swMain, srcNode1, srcNode2);
    net.connect(1000, swMain, dstNode);
    // Create and host 1 VM per source node
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    ma.addRunningVM(vm1, srcNode1);
    ma.addRunningVM(vm2, srcNode2);
    // Attach CPU and Mem resource views and assign nodes capacity and VMs consumption
    int mem_vm = 8;
    int cpu_vm = 4;
    int mem_src = 8;
    int cpu_src = 4;
    int mem_dst = 16;
    int cpu_dst = 8;
    ShareableResource rcMem = new ShareableResource("mem", 0, 0);
    ShareableResource rcCPU = new ShareableResource("cpu", 0, 0);
    mo.attach(rcMem);
    mo.attach(rcCPU);
    // VMs
    rcMem.setConsumption(vm1, mem_vm).setConsumption(vm2, mem_vm);
    rcCPU.setConsumption(vm1, cpu_vm).setConsumption(vm2, cpu_vm);
    // Nodes
    rcMem.setCapacity(srcNode1, mem_src).setCapacity(srcNode2, mem_src).setCapacity(dstNode, mem_dst);
    rcCPU.setCapacity(srcNode1, cpu_src).setCapacity(srcNode2, cpu_src).setCapacity(dstNode, cpu_dst);
    // Set VM attributes 'memory used', 'hot dirty page size', 'hot dirty page duration' and 'cold dirty pages rate'
    int vm_mu = 6000;
    int vm_mds = 46;
    int vm_mdd = 2;
    double vm_cdr = 23.6;
    // vm1 is an 'idle' VM (with no special memory activity) but still consumes 6 GiB of memory
    mo.getAttributes().put(vm1, "memUsed", vm_mu);
    // vm2 consumes 6 GiB memory and has a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
    // VM with a workload
    mo.getAttributes().put(vm2, "memUsed", vm_mu);
    mo.getAttributes().put(vm2, "hotDirtySize", vm_mds);
    mo.getAttributes().put(vm2, "hotDirtyDuration", vm_mdd);
    mo.getAttributes().put(vm2, "coldDirtyRate", vm_cdr);
    // Create constraints
    List<SatConstraint> cstrs = new ArrayList<>();
    // Placement constraints, we want to shutdown the source nodes to force the migration to destination nodes
    cstrs.add(new Offline(srcNode1));
    cstrs.add(new Offline(srcNode2));
    // SET A TOO SHORT DEADLINE FOR THE MIGRATION OF VM2
    // 30s
    Deadline dead = new Deadline(vm2, "+00:00:30");
    cstrs.add(dead);
    // Try to solve it using the Min Max Time To Repair Migration scheduling oriented objective
    ReconfigurationPlan p = new DefaultChocoScheduler().solve(mo, cstrs, new MinMTTRMig());
    Assert.assertNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) Deadline(org.btrplace.model.constraint.migration.Deadline) 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) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 4 with Deadline

use of org.btrplace.model.constraint.migration.Deadline in project scheduler by btrplace.

the class CDeadlineTest method testOk.

@Test
public void testOk() throws SchedulerException {
    // New default model
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    // Create and boot 2 source nodes and 1 destination node
    Node srcNode1 = mo.newNode();
    Node srcNode2 = mo.newNode();
    Node dstNode = mo.newNode();
    ma.addOnlineNode(srcNode1);
    ma.addOnlineNode(srcNode2);
    ma.addOnlineNode(dstNode);
    // Attach a network view
    Network net = new Network();
    mo.attach(net);
    // Connect the nodes through a main non-blocking switch
    // The destination node have twice the bandwidth of source nodes
    Switch swMain = net.newSwitch();
    net.connect(1000, swMain, srcNode1, srcNode2);
    net.connect(2000, swMain, dstNode);
    // Create and host 1 VM per source node
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    ma.addRunningVM(vm1, srcNode1);
    ma.addRunningVM(vm2, srcNode2);
    // Attach CPU and Mem resource views and assign nodes capacity and VMs consumption
    int mem_vm = 8;
    int cpu_vm = 4;
    int mem_src = 8;
    int cpu_src = 4;
    int mem_dst = 16;
    int cpu_dst = 8;
    ShareableResource rcMem = new ShareableResource("mem", 0, 0);
    ShareableResource rcCPU = new ShareableResource("cpu", 0, 0);
    mo.attach(rcMem);
    mo.attach(rcCPU);
    // VMs
    rcMem.setConsumption(vm1, mem_vm).setConsumption(vm2, mem_vm);
    rcCPU.setConsumption(vm1, cpu_vm).setConsumption(vm2, cpu_vm);
    // Nodes
    rcMem.setCapacity(srcNode1, mem_src).setCapacity(srcNode2, mem_src).setCapacity(dstNode, mem_dst);
    rcCPU.setCapacity(srcNode1, cpu_src).setCapacity(srcNode2, cpu_src).setCapacity(dstNode, cpu_dst);
    // Set VM attributes 'memory used', 'hot dirty page size', 'hot dirty page duration' and 'cold dirty pages rate'
    int vm_mu = 6000;
    int vm_mds = 46;
    int vm_mdd = 2;
    double vm_cdr = 23.6;
    // vm1 is an 'idle' VM (with no special memory activity) but still consumes 6 GiB of memory
    mo.getAttributes().put(vm1, "memUsed", vm_mu);
    // vm2 consumes 6 GiB memory and has a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
    // VM with a workload
    mo.getAttributes().put(vm2, "memUsed", vm_mu);
    mo.getAttributes().put(vm2, "hotDirtySize", vm_mds);
    mo.getAttributes().put(vm2, "hotDirtyDuration", vm_mdd);
    mo.getAttributes().put(vm2, "coldDirtyRate", vm_cdr);
    // Create constraints
    List<SatConstraint> cstrs = new ArrayList<>();
    // Placement constraints, we want to shutdown the source nodes to force the migration to destination nodes
    cstrs.add(new Offline(srcNode1));
    cstrs.add(new Offline(srcNode2));
    // SET A RELATIVE DEADLINE FOR THE MIGRATION OF VM2
    // 90s
    Deadline dead = new Deadline(vm2, "+00:01:30");
    cstrs.add(dead);
    // Solve it using the Min Max Time To Repair Migration scheduling oriented objective
    ReconfigurationPlan p = new DefaultChocoScheduler().solve(mo, cstrs, new MinMTTRMig());
    // It works because 30s is enough to fully migrate vm2
    Assert.assertNotNull(p);
    // Check if the deadline is respected
    Action mig1 = p.getActions().stream().filter(s -> s instanceof MigrateVM && ((MigrateVM) s).getVM().equals(vm1)).findAny().get();
    Assert.assertTrue(mig1.getEnd() <= 90);
    // TODO: use methods on DeadlineChecker to verify that the action terminates at time ?
    Assert.assertTrue(dead.isSatisfied(p));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Action(org.btrplace.plan.event.Action) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) Deadline(org.btrplace.model.constraint.migration.Deadline) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Offline(org.btrplace.model.constraint.Offline) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

DefaultModel (org.btrplace.model.DefaultModel)4 Model (org.btrplace.model.Model)4 Deadline (org.btrplace.model.constraint.migration.Deadline)4 ArrayList (java.util.ArrayList)3 SatConstraint (org.btrplace.model.constraint.SatConstraint)3 ShareableResource (org.btrplace.model.view.ShareableResource)3 Network (org.btrplace.model.view.network.Network)3 Switch (org.btrplace.model.view.network.Switch)3 Test (org.testng.annotations.Test)3 Mapping (org.btrplace.model.Mapping)2 Node (org.btrplace.model.Node)2 VM (org.btrplace.model.VM)2 Offline (org.btrplace.model.constraint.Offline)2 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)2 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)2 MigrateVM (org.btrplace.plan.event.MigrateVM)2 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)2 HashSet (java.util.HashSet)1 ConstraintsConverter (org.btrplace.json.model.constraint.ConstraintsConverter)1 Precedence (org.btrplace.model.constraint.migration.Precedence)1