use of org.btrplace.model.Node in project scheduler by btrplace.
the class NamingServiceTest method testClone.
@Test(dependsOnMethods = { "testRegisterAndGets", "testResolution" })
public void testClone() {
NamingService<Node> ns = NamingService.newNodeNS();
Model mo = new DefaultModel();
Node n = mo.newNode();
NamingService<Node> ns2 = ns.copy();
Assert.assertTrue(ns2.register(n, "n0"));
Assert.assertNull(ns.resolve(n));
Assert.assertNull(ns.resolve("n0"));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class NamingServiceTest method testGetViews.
@Test
public void testGetViews() {
Model mo = new DefaultModel();
Assert.assertNull(NamingService.getVMNames(mo));
Assert.assertNull(NamingService.getNodeNames(mo));
NamingService<VM> vmNs = NamingService.newVMNS();
NamingService<Node> nodeNs = NamingService.newNodeNS();
mo.attach(vmNs);
mo.attach(nodeNs);
Assert.assertEquals(NamingService.getNodeNames(mo), nodeNs);
Assert.assertEquals(NamingService.getVMNames(mo), vmNs);
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class NamingServiceTest method testSubstitution.
@Test(dependsOnMethods = { "testRegisterAndGets" })
public void testSubstitution() {
NamingService<VM> ns = NamingService.newVMNS();
Model mo = new DefaultModel();
VM v = mo.newVM();
ns.register(v, "vm0");
VM v2 = mo.newVM();
ns.substituteVM(v, v2);
Assert.assertNull(ns.resolve(v));
Assert.assertEquals(ns.resolve(v2), "vm0");
Assert.assertEquals(ns.resolve("vm0"), v2);
NamingService<Node> ns2 = NamingService.newNodeNS();
ns2.register(mo.newNode(), "n0");
Assert.assertTrue(ns2.substituteVM(mo.newVM(), mo.newVM()));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class DefaultReconfigurationPlanTest method testToString.
@Test
public void testToString() {
Model mo = new DefaultModel();
VM v1 = mo.newVM();
VM v2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
mo.getMapping().addOnlineNode(n1);
mo.getMapping().addOnlineNode(n2);
mo.getMapping().addRunningVM(v1, n1);
mo.getMapping().addRunningVM(v2, n1);
ReconfigurationPlan p1 = new DefaultReconfigurationPlan(mo);
p1.add(new MigrateVM(v1, n1, n2, 1, 2));
p1.add(new MigrateVM(v2, n1, n2, 1, 2));
String s = p1.toString();
// 2 migrations
Assert.assertNotEquals(s.indexOf("migrate("), s.lastIndexOf("migrate("));
System.err.println(p1.toString());
System.err.flush();
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class BenchTest method instance.
public static Instance instance() {
Model mo = new DefaultModel();
VM v1 = mo.newVM();
VM v2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
mo.getMapping().on(n1, n2, n3).run(n1, v1).run(n2, v2).off(n3);
Set<VM> s = new HashSet<>();
s.add(v1);
s.add(v2);
List<SatConstraint> cstrs = Arrays.asList(new Spread(s, true), new Fence(v1, n2), new Offline(n1));
return new Instance(mo, cstrs, new MinMTTR());
}
Aggregations