use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class FixedNodeSetsPartitioningTest method testSplitWithUnsplittableConstraint.
@Test(expectedExceptions = { SchedulerException.class })
public void testSplitWithUnsplittableConstraint() throws SchedulerException {
Instance orig = makeInstance();
orig.getSatConstraints().add(new MaxOnline(orig.getModel().getMapping().getAllNodes(), 5));
List<Collection<Node>> parts = splitIn(orig.getModel().getMapping().getAllNodes(), 3);
FixedNodeSetsPartitioning f = new FixedNodeSetsPartitioning(parts);
f.split(new DefaultParameters(), orig);
}
use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class AmongSplitterTest method testSplittable.
@Test
public void testSplittable() throws SchedulerException {
List<VM> vms = Arrays.asList(vm1, vm2, vm3);
Collection<Collection<Node>> parts = new ArrayList<>();
parts.add(Arrays.asList(n1, n2));
parts.add(Collections.singletonList(n3));
parts.add(Collections.singletonList(n4));
Among single = new Among(vms, parts);
/*
N1 v1 v2
N2 v3
---
N3 v4
--
N4 v5
*/
FixedNodeSetsPartitioning partitionner = new FixedNodeSetsPartitioning(parts);
partitionner.setPartitions(parts);
List<Instance> instances = partitionner.split(new DefaultParameters(), new Instance(mo, Collections.emptyList(), new MinMTTR()));
TIntIntHashMap vmIndex = Instances.makeVMIndex(instances);
TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
splitter.split(single, new Instance(mo, new MinMTTR()), instances, vmIndex, nodeIndex);
Among a = (Among) instances.get(0).getSatConstraints().iterator().next();
Assert.assertEquals(a.getGroupsOfNodes().size(), 1);
Assert.assertEquals(a.getInvolvedNodes(), Arrays.asList(n1, n2));
for (Instance i : instances) {
System.out.println(i.getSatConstraints());
}
}
use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class SingleRunnerStatisticsTest method testInstantiate.
@Test
public void testInstantiate() {
Parameters ps = new DefaultParameters();
Model mo = new DefaultModel();
long st = System.currentTimeMillis();
List<SatConstraint> cstrs = new ArrayList<>();
Instance i = new Instance(mo, cstrs, new MinMTTR());
SingleRunnerStatistics stats = new SingleRunnerStatistics(ps, i, st);
Assert.assertEquals(stats.getStart(), st);
Assert.assertEquals(stats.getCoreBuildDuration(), -1);
Assert.assertEquals(stats.getSpecializationDuration(), -1);
Assert.assertEquals(stats.getInstance(), i);
Assert.assertEquals(stats.getNbManagedVMs(), -1);
Assert.assertEquals(stats.getParameters(), ps);
Assert.assertEquals(stats.getSolutions().size(), 0);
Assert.assertEquals(stats.completed(), false);
Assert.assertEquals(stats.getMetrics(), null);
stats.setCoreBuildDuration(12);
stats.setSpecialisationDuration(17);
stats.setNbManagedVMs(18);
stats.setCompleted(true);
Assert.assertEquals(stats.getCoreBuildDuration(), 12);
Assert.assertEquals(stats.getSpecializationDuration(), 17);
Assert.assertEquals(stats.getNbManagedVMs(), 18);
Assert.assertEquals(stats.completed(), true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
SolutionStatistics sol = new SolutionStatistics(new Metrics(), plan);
stats.addSolution(sol);
Assert.assertEquals(stats.getSolutions().size(), 1);
Assert.assertEquals(stats.getSolutions().get(0), sol);
}
use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class BootVMTest method testBasics.
/**
* Just boot a VM on a node.
*/
@Test
public void testBasics() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
final VM vm1 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addReadyVM(vm1);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(org.btrplace.plan.event.BootVM.class, new ConstantActionDuration<>(5));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), map.getAllVMs(), new HashSet<>(), new HashSet<>()).build();
rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
BootVM m = (BootVM) rp.getVMActions().get(0);
Assert.assertEquals(vm1, m.getVM());
Assert.assertNull(m.getCSlice());
Assert.assertTrue(m.getDuration().isInstantiatedTo(5));
Assert.assertTrue(m.getState().isInstantiatedTo(1));
Assert.assertFalse(m.getDSlice().getHoster().isInstantiated());
Assert.assertFalse(m.getDSlice().getStart().isInstantiated());
Assert.assertFalse(m.getDSlice().getEnd().isInstantiated());
new CMinMTTR().inject(ps, rp);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
org.btrplace.plan.event.BootVM a = (org.btrplace.plan.event.BootVM) p.getActions().iterator().next();
Node dest = rp.getNode(m.getDSlice().getHoster().getValue());
Assert.assertEquals(vm1, a.getVM());
Assert.assertEquals(dest, a.getDestinationNode());
Assert.assertEquals(5, a.getEnd() - a.getStart());
}
use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class ForgeVMTest method testWithoutTemplate.
@Test(expectedExceptions = { SchedulerException.class })
public void testWithoutTemplate() throws SchedulerException {
Model mo = new DefaultModel();
final VM vm1 = mo.newVM();
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(org.btrplace.plan.event.ForgeVM.class, new ConstantActionDuration<>(7));
new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
}
Aggregations