use of org.btrplace.model.constraint.Online in project scheduler by btrplace.
the class OnlineSplitterTest method simpleTest.
@Test
public void simpleTest() {
OnlineSplitter splitter = new OnlineSplitter();
List<Instance> instances = new ArrayList<>();
Model m0 = new DefaultModel();
Node n = m0.newNode();
m0.getMapping().addOnlineNode(n);
m0.getMapping().addOnlineNode(m0.newNode(1));
Model m1 = new DefaultModel();
m1.getMapping().addOnlineNode(m1.newNode(2));
m1.getMapping().addOnlineNode(m1.newNode(3));
instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR()));
instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR()));
Set<Node> all = new HashSet<>(m0.getMapping().getAllNodes());
all.addAll(m1.getMapping().getAllNodes());
TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
// Only nodes in m0
Online oSimple = new Online(n);
Assert.assertTrue(splitter.split(oSimple, null, instances, new TIntIntHashMap(), nodeIndex));
Assert.assertTrue(instances.get(0).getSatConstraints().contains(oSimple));
Assert.assertFalse(instances.get(1).getSatConstraints().contains(oSimple));
}
use of org.btrplace.model.constraint.Online in project scheduler by btrplace.
the class OnlineConverterTest method testViables.
@Test
public void testViables() throws JSONConverterException {
Model mo = new DefaultModel();
ConstraintsConverter conv = new ConstraintsConverter();
conv.register(new OnlineConverter());
Online d = new Online(mo.newNode());
Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(d)), d);
System.out.println(conv.toJSON(d));
}
use of org.btrplace.model.constraint.Online in project scheduler by btrplace.
the class CMaxOnlineTest method testSimpleContinuousCase.
@Test
public void testSimpleContinuousCase() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
model.getMapping().addOnlineNode(n1);
model.getMapping().addOfflineNode(n2);
MaxOnline maxOnline = new MaxOnline(model.getMapping().getAllNodes(), 1, true);
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(maxOnline);
constraints.add(new Online(n2));
ChocoScheduler cra = new DefaultChocoScheduler();
// cra.setTimeLimit(5);
cra.setMaxEnd(4);
cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
ReconfigurationPlan plan = cra.solve(model, constraints);
Assert.assertNotNull(plan);
Assert.assertTrue(maxOnline.isSatisfied(plan));
}
use of org.btrplace.model.constraint.Online in project scheduler by btrplace.
the class CMaxOnlineTest method testContinuousRestrictionSimpleCase.
@Test
public void testContinuousRestrictionSimpleCase() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
VM vm1 = model.newVM();
VM vm3 = model.newVM();
VM vm4 = model.newVM();
ShareableResource resources = new ShareableResource("cpu", 4, 1);
resources.setCapacity(n1, 8);
resources.setConsumption(vm4, 2);
Mapping map = model.getMapping().on(n1, n3).off(n2).run(n1, vm1, vm4).run(n3, vm3);
MappingUtils.fill(map, model.getMapping());
model.attach(resources);
MaxOnline maxon = new MaxOnline(map.getAllNodes(), 2, true);
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(maxon);
constraints.add(new Online(n2));
ChocoScheduler cra = new DefaultChocoScheduler();
// cra.setTimeLimit(3);
cra.setMaxEnd(3);
cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
ReconfigurationPlan plan = cra.solve(model, constraints);
Assert.assertNotNull(plan);
Assert.assertTrue(maxon.isSatisfied(plan));
}
use of org.btrplace.model.constraint.Online in project scheduler by btrplace.
the class DefaultChocoSchedulerTest method testNonHomogeneousIncrease.
/**
* Issue #14
*
* @throws org.btrplace.scheduler.SchedulerException
*/
@Test
public void testNonHomogeneousIncrease() throws SchedulerException {
ShareableResource cpu = new ShareableResource("cpu");
ShareableResource mem = new ShareableResource("mem");
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
cpu.setCapacity(n1, 10);
mem.setCapacity(n1, 10);
cpu.setCapacity(n2, 10);
mem.setCapacity(n2, 10);
cpu.setConsumption(vm1, 5);
mem.setConsumption(vm1, 4);
cpu.setConsumption(vm2, 3);
mem.setConsumption(vm2, 8);
cpu.setConsumption(vm3, 5);
cpu.setConsumption(vm3, 4);
cpu.setConsumption(vm4, 4);
cpu.setConsumption(vm4, 5);
// vm1 requires more cpu resources, but fewer mem resources
Preserve pCPU = new Preserve(vm1, "cpu", 7);
Preserve pMem = new Preserve(vm1, "mem", 2);
mo.getMapping().on(n1, n2).run(n1, vm1).run(n2, vm3, vm4).ready(vm2);
mo.attach(cpu);
mo.attach(mem);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.setMaxEnd(5);
ReconfigurationPlan p = cra.solve(mo, Arrays.asList(pCPU, pMem, new Online(n1), new Running(vm2), new Ready(vm3)));
Assert.assertNotNull(p);
}
Aggregations