use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class SpreadTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 4);
List<VM> vms = Util.newVMs(mo, 4);
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
map.addOnlineNode(ns.get(3));
map.addRunningVM(vms.get(0), ns.get(0));
map.addRunningVM(vms.get(1), ns.get(1));
Spread s = new Spread(map.getAllVMs());
ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(s.isSatisfied(p), true);
MigrateVM m1 = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 1, 2);
p.add(m1);
Assert.assertEquals(s.isSatisfied(p), false);
// No overlapping at moment 1
MigrateVM m2 = new MigrateVM(vms.get(1), ns.get(1), ns.get(2), 0, 1);
p.add(m2);
Assert.assertEquals(s.isSatisfied(p), true);
map.addRunningVM(vms.get(2), ns.get(1));
s = new Spread(map.getAllVMs());
p = new DefaultReconfigurationPlan(mo);
System.out.println(p.getOrigin() + "\n" + p.getResult());
Assert.assertEquals(s.isSatisfied(p), false);
p.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(2), 0, 5));
Assert.assertEquals(s.isSatisfied(p), true);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class ReconfigurationPlanFuzzer method get.
@Override
public ReconfigurationPlan get() {
Model mo = new DefaultModel();
ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
for (int i = 0; i < nbNodes; i++) {
Node n = mo.newNode();
addNode(n, p);
}
for (int i = 0; i < nbVMs; i++) {
addVM(mo.newVM(), p);
}
exts.forEach(d -> d.decorate(p));
return p;
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class SolutionStatisticsTest method test.
@Test
public void test() {
Metrics m = new Metrics();
ReconfigurationPlan p = new DefaultReconfigurationPlan(new DefaultModel());
SolutionStatistics st = new SolutionStatistics(m, p);
Assert.assertFalse(st.hasObjective());
st.setObjective(12);
Assert.assertEquals(st.getMetrics(), m);
Assert.assertEquals(st.getReconfigurationPlan(), p);
Assert.assertTrue(st.hasObjective());
Assert.assertEquals(st.objective(), 12);
System.out.println(st);
}
use of org.btrplace.plan.DefaultReconfigurationPlan 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);
}
Aggregations