use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CGatherTest method testContinuousWithRelocationOfVMs.
/**
* We try to relocate co-located VMs in continuous mode. Not allowed
*
* @throws org.btrplace.scheduler.SchedulerException
*/
@Test
public void testContinuousWithRelocationOfVMs() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2).run(n2, vm1, vm2);
Gather g = new Gather(map.getAllVMs());
g.setContinuous(true);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Running.newRunning(map.getAllVMs()));
cstrs.add(g);
cstrs.add(new Fence(vm1, Collections.singleton(n1)));
cstrs.add(new Fence(vm2, Collections.singleton(n1)));
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, cstrs);
Assert.assertNull(plan);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CSplitTest method testContinuous.
// @Test
@Test(enabled = false)
public void testContinuous() 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();
VM vm7 = mo.newVM();
VM vm8 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
Node n4 = mo.newNode();
Node n5 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm2).run(n3, vm3, vm4, vm5).run(n5, vm6, vm7, vm8);
Collection<VM> g1 = Arrays.asList(vm1, vm2);
Collection<VM> g2 = Arrays.asList(vm3, vm4, vm5);
Collection<VM> g3 = Arrays.asList(vm6, vm7);
Collection<Collection<VM>> grps = Arrays.asList(g1, g2, g3);
Split s = new Split(grps);
s.setContinuous(true);
ChocoScheduler cra = new DefaultChocoScheduler();
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(s);
// go away before the other arrive.
for (VM v : map.getRunningVMs(n1)) {
cstrs.add(new Fence(v, Collections.singleton(n3)));
}
// cra.setTimeLimit(2);
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
Assert.assertTrue(p.getSize() > 0);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CSpreadTest method testContinuous.
@Test
public void testContinuous() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2);
List<SatConstraint> cstr = new ArrayList<>();
ChocoScheduler cra = new DefaultChocoScheduler();
cstr.add(new Spread(mo.getMapping().getAllVMs(), true));
cstr.addAll(Online.newOnline(mo.getMapping().getAllNodes()));
cstr.add(new Fence(vm1, Collections.singleton(n2)));
ReconfigurationPlan p = cra.solve(mo, cstr);
Assert.assertNotNull(p);
System.err.println(p);
Mapping res = p.getResult().getMapping();
Assert.assertEquals(2, p.getSize());
Assert.assertNotSame(res.getVMLocation(vm1), res.getVMLocation(vm2));
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CSpreadTest method testSeparateWithContinuous.
/**
* 2 VMs are already hosted on a same node, check
* if separation is working in continuous mode
*/
@Test
public void testSeparateWithContinuous() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
mo.getMapping().on(n1, n2).run(n1, vm1, vm2);
List<SatConstraint> cstr = new ArrayList<>();
ChocoScheduler cra = new DefaultChocoScheduler();
Spread s = new Spread(mo.getMapping().getAllVMs());
s.setContinuous(true);
cstr.add(s);
cstr.addAll(Online.newOnline(mo.getMapping().getAllNodes()));
cstr.add(new Fence(vm1, Collections.singleton(n2)));
ReconfigurationPlan p = cra.solve(mo, cstr);
Assert.assertNull(p);
}
use of org.btrplace.model.constraint.SatConstraint 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));
}
Aggregations