@Test public void testMaintainResourceUsage() throws SchedulerException { Model mo = new DefaultModel(); VM vm1 = mo.newVM(); VM vm2 = mo.newVM(); Node n1 = mo.newNode(); mo.getMapping().on(n1).run(n1, vm1, vm2); ShareableResource rc = new ShareableResource("foo"); rc.setConsumption(vm1, 5); rc.setConsumption(vm2, 7); rc.setCapacity(n1, 25); mo.attach(rc); ChocoScheduler s = new DefaultChocoScheduler(); ReconfigurationPlan p = s.solve(mo, new ArrayList<>()); Assert.assertNotNull(p); Model res = p.getResult(); ShareableResource resRc = ShareableResource.get(res, rc.getResourceIdentifier()); Assert.assertEquals(resRc.getConsumption(vm1), 5); Assert.assertEquals(resRc.getConsumption(vm2), 7); }
public String getResourceIdentifier() { return rc.getResourceIdentifier(); }
CShareableResource implements ChocoView { public String getResourceIdentifier() { return rc.getResourceIdentifier(); } }
CShareableResource implements ChocoView { public String getResourceIdentifier() { return rc.getResourceIdentifier(); } CShareableResource(ShareableResource r); }
CShareableResource implements ChocoView { public String getResourceIdentifier() { return rc.getResourceIdentifier(); } CShareableResource(ShareableResource r); @Override boolean inject(Parameters ps, ReconfigurationProblem p); String getResourceIdentifier(); ShareableResource getSourceResource(); List<IntVar> getPhysicalUsage(); IntVar getPhysicalUsage(int nIdx); List<IntVar> getVirtualUsage(); int getVMAllocation(int vmIdx); int minVMAllocation(int vmIdx, int v); double getOverbookRatio(int nId); double capOverbookRatio(int nIdx, double d); @Override String getIdentifier(); @Override String toString(); @Override boolean beforeSolve(ReconfigurationProblem p); @Override boolean insertActions(ReconfigurationProblem r, Solution s, ReconfigurationPlan p); @Override Set<VM> getMisPlacedVMs(Instance i); boolean overloaded(Mapping m, Node n); @Override boolean cloneVM(VM vm, VM clone); @Override List<String> getDependencies(); static TObjectIntMap<VM> getWeights(ReconfigurationProblem rp, List<CShareableResource> rcs); }
CShareableResource implements ChocoView { public String getResourceIdentifier() { return rc.getResourceIdentifier(); } CShareableResource(ShareableResource r); @Override boolean inject(Parameters ps, ReconfigurationProblem p); String getResourceIdentifier(); ShareableResource getSourceResource(); List<IntVar> getPhysicalUsage(); IntVar getPhysicalUsage(int nIdx); List<IntVar> getVirtualUsage(); int getVMAllocation(int vmIdx); int minVMAllocation(int vmIdx, int v); double getOverbookRatio(int nId); double capOverbookRatio(int nIdx, double d); @Override String getIdentifier(); @Override String toString(); @Override boolean beforeSolve(ReconfigurationProblem p); @Override boolean insertActions(ReconfigurationProblem r, Solution s, ReconfigurationPlan p); @Override Set<VM> getMisPlacedVMs(Instance i); boolean overloaded(Mapping m, Node n); @Override boolean cloneVM(VM vm, VM clone); @Override List<String> getDependencies(); static TObjectIntMap<VM> getWeights(ReconfigurationProblem rp, List<CShareableResource> rcs); static final double UNCHECKED_RATIO; }