Last active
December 19, 2015 01:19
-
-
Save tudang/5874954 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testOverbook() throws SolverException { | |
Model model = new DefaultModel(); | |
ShareableResource cpu = new ShareableResource("cpu", 8, 1); | |
model.attach(cpu); | |
int NODE = 256; | |
for (int i = 0; i < NODE; i++) { | |
model.getMapping().addOnlineNode(model.newNode()); | |
} | |
Collection<VM> vms = new ArrayList<>(); | |
for (int i = 0; i < 32*NODE; i++) { | |
VM e = model.newVM(); | |
vms.add(e); | |
model.getMapping().addReadyVM(e); | |
} | |
Running run = new Running(vms); | |
Overbook overbook = new Overbook(model.getNodes(), "cpu", 4); | |
Collection<SatConstraint> VMconstraints = new ArrayList<>(); | |
VMconstraints.add(overbook); | |
VMconstraints.add(run); | |
ChocoReconfigurationAlgorithm cra = new DefaultChocoReconfigurationAlgorithm(); | |
ReconfigurationPlan plan = cra.solve(model, VMconstraints); | |
Assert.assertNotNull(plan); | |
Mapping mapping = plan.getResult().getMapping(); | |
Set<Node> onlineNodes = mapping.getOnlineNodes(); | |
Set<VM> runningVMs = mapping.getRunningVMs(); | |
ShareableResource sr = (ShareableResource) model.getView("ShareableResource.cpu"); | |
double capacity = sr.sumCapacities(onlineNodes, true) * overbook.getRatio(); | |
double used = sr.sumConsumptions(runningVMs, true); | |
System.out.printf("%f %f %f", capacity, used, used / capacity * 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment