use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class DefaultTestCampaign method test.
@Override
public TestCaseResult test(TestCase tc) {
VerifierResult res = oracle.verify(tc);
DefaultChocoScheduler sched = new DefaultChocoScheduler(params);
try {
ReconfigurationPlan plan = sched.solve(tc.instance());
checkConsistency(plan, tc);
} catch (RuntimeException e) {
// A runtime exception is a CRASH. Should not happen
return new TestCaseResult(tc, e, res);
}
return new TestCaseResult(tc, sched.getStatistics(), res);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class FixedSizePartitioningTest method basicTesting.
@Test
public void basicTesting() {
FixedSizePartitioning f = new FixedSizePartitioning(1000);
f.setWorkersCount(5);
Assert.assertEquals(f.getWorkersCount(), 5);
Assert.assertEquals(f.getSize(), 1000);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.setInstanceSolver(f);
Assert.assertEquals(cra.getInstanceSolver(), f);
f.setSize(300);
Assert.assertEquals(f.getSize(), 300);
Assert.assertEquals(f.randomPickUp(), false);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class StaticPartitioningTest method testParallelSolve.
@Test
public void testParallelSolve() throws SchedulerException {
SynchronizedElementBuilder eb = new SynchronizedElementBuilder(new DefaultElementBuilder());
Model origin = new DefaultModel(eb);
Node n1 = origin.newNode();
Node n2 = origin.newNode();
VM vm1 = origin.newVM();
VM vm2 = origin.newVM();
/*
* 2 nodes among 2 instances, 2 VMs to boot on the nodes
*/
origin.getMapping().addOnlineNode(n1);
origin.getMapping().addOfflineNode(n2);
origin.getMapping().addReadyVM(vm1);
origin.getMapping().addReadyVM(vm2);
Model s1 = new SubModel(origin, eb, Collections.singletonList(n1), Collections.singleton(vm1));
Model s2 = new SubModel(origin, eb, Collections.singletonList(n2), Collections.singleton(vm2));
Instance i0 = new Instance(origin, new MinMTTR());
final Instance i1 = new Instance(s1, Running.newRunning(Collections.singletonList(vm1)), new MinMTTR());
final Instance i2 = new Instance(s2, new MinMTTR());
i2.getSatConstraints().add(new Running(vm2));
StaticPartitioning st = new StaticPartitioning() {
@Override
public List<Instance> split(Parameters ps, Instance i) throws SchedulerException {
return Arrays.asList(i1, i2);
}
};
Parameters p = new DefaultChocoScheduler();
ReconfigurationPlan plan = st.solve(p, i0);
Assert.assertNotNull(plan);
Model dst = plan.getResult();
Assert.assertEquals(dst.getMapping().getOnlineNodes().size(), 2);
Assert.assertEquals(dst.getMapping().getRunningVMs().size(), 2);
// Now, there is no solution for i2. the resulting plan should be null
i2.getSatConstraints().addAll(Offline.newOffline(Collections.singletonList(n2)));
plan = st.solve(p, i0);
Assert.assertNull(plan);
Assert.assertEquals(st.getStatistics().getSolutions().size(), 0);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CNetworkTest method defaultTest.
/**
* Test the instantiation and the creation of the variables.
*
* @throws org.btrplace.scheduler.SchedulerException if an error occurs during the solving process (it should not)
*/
@Test
public void defaultTest() throws SchedulerException {
// New default model
Model mo = new DefaultModel();
Mapping ma = mo.getMapping();
// Create and boot 1 source and 1 destination node
Node srcNode = mo.newNode(), dstNode = mo.newNode();
ma.addOnlineNode(srcNode);
ma.addOnlineNode(dstNode);
// Attach a network view
Network net = new Network();
mo.attach(net);
// Connect the nodes through a main non-blocking switch using 1 Gbit/s links
Switch swMain = net.newSwitch();
int bw = 1000;
net.connect(bw, swMain, srcNode, dstNode);
// Create and host 1 running VM on the source node
VM vm = mo.newVM();
ma.addRunningVM(vm, srcNode);
// The VM consumes 6 GiB memory and has a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
int memUsed = 6000, hotDirtySize = 46, hotDirtyDuration = 2;
double coldDirtyRate = 23.6;
// 6 GiB
mo.getAttributes().put(vm, "memUsed", memUsed);
// 46 MiB
mo.getAttributes().put(vm, "hotDirtySize", hotDirtySize);
// 2 sec.
mo.getAttributes().put(vm, "hotDirtyDuration", hotDirtyDuration);
// 23.6 MiB/sec.
mo.getAttributes().put(vm, "coldDirtyRate", coldDirtyRate);
// Add constraints
List<SatConstraint> cstrs = new ArrayList<>();
// We force the migration to go on the destination node
cstrs.add(new Fence(vm, Collections.singleton(dstNode)));
// Try to solve using the custom Min MTTR objective for migration scheduling
ReconfigurationPlan p = new DefaultChocoScheduler().solve(mo, cstrs, new MinMTTRMig());
Assert.assertNotNull(p);
// The switch is non-blocking
Assert.assertEquals(swMain.getCapacity(), Integer.MAX_VALUE);
// Check the migration path and bandwidth
MigrateVM mig = (MigrateVM) p.getActions().stream().filter(s -> s instanceof MigrateVM).findFirst().get();
Assert.assertTrue(net.getRouting().getPath(mig.getSourceNode(), mig.getDestinationNode()).containsAll(net.getLinks()));
Assert.assertEquals(net.getRouting().getMaxBW(mig.getSourceNode(), mig.getDestinationNode()), bw);
Assert.assertEquals(mig.getBandwidth(), bw);
// Check the migration duration computation
double bandwidth_octet = mig.getBandwidth() / 9, durationMin, durationColdPages, durationHotPages, durationTotal;
durationMin = memUsed / bandwidth_octet;
durationColdPages = ((hotDirtySize + ((durationMin - hotDirtyDuration) * coldDirtyRate)) / (bandwidth_octet - coldDirtyRate));
durationHotPages = ((hotDirtySize / bandwidth_octet) * ((hotDirtySize / hotDirtyDuration) / (bandwidth_octet - (hotDirtySize / hotDirtyDuration))));
durationTotal = durationMin + durationColdPages + durationHotPages;
Assert.assertEquals((mig.getEnd() - mig.getStart()), (int) Math.round(durationTotal));
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CNetworkTest method testWithSwitchCapacity.
@Test
public void testWithSwitchCapacity() {
Model mo = new DefaultModel();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
VM v = mo.newVM();
mo.getMapping().on(n1, n2).run(n1, v);
ShareableResource mem = new ShareableResource("mem", 10000, 5000);
Network net = new Network();
mo.attach(net);
mo.attach(mem);
mo.getAttributes().put(v, "memUsed", 10000);
Switch sw = net.newSwitch(1000);
net.connect(2000, sw, n1, n2);
ChocoScheduler s = new DefaultChocoScheduler();
ReconfigurationPlan p = s.solve(mo, Collections.singletonList(new Fence(v, n2)));
Assert.assertNotNull(p);
}
Aggregations