@Test public void testDistributeLoad() { final String capacityConstraint = "create view constraint_capacity as " + "select * from virtual_machine " + "join physical_machine " + " on physical_machine.name = virtual_machine.controllable__physical_machine " + "group by physical_machine.name, physical_machine.cpu_capacity, physical_machine.memory_capacity " + "check sum(virtual_machine.cpu) <= physical_machine.cpu_capacity and " + " sum(virtual_machine.memory) <= physical_machine.memory_capacity"; final String spareCpu = "create view spare_cpu as " + "select physical_machine.cpu_capacity - sum(virtual_machine.cpu) as cpu_spare " + "from virtual_machine " + "join physical_machine " + " on physical_machine.name = virtual_machine.controllable__physical_machine " + "group by physical_machine.name, physical_machine.cpu_capacity"; final String distributeLoadCpu = "create view objective_load_cpu as select min(cpu_spare) from spare_cpu"; final LoadBalance lb = new LoadBalance(List.of(capacityConstraint, spareCpu, distributeLoadCpu)); addInventory(lb); final Result<? extends Record> result = lb.run(); final Set<String> setOfPhysicalMachines = result.stream() .map(e -> e.get("CONTROLLABLE__PHYSICAL_MACHINE", String.class)) .collect(Collectors.toSet()); System.out.println(result); assertEquals(NUM_PHYSICAL_MACHINES, setOfPhysicalMachines.size()); }
Result<? extends Record> run() { model.updateData(); return model.solve(VIRTUAL_MACHINES_TABLE); }
LoadBalance { Result<? extends Record> run() { model.updateData(); return model.solve(VIRTUAL_MACHINES_TABLE); } }
LoadBalance { Result<? extends Record> run() { model.updateData(); return model.solve(VIRTUAL_MACHINES_TABLE); } LoadBalance(final List<String> constraints); }
LoadBalance { Result<? extends Record> run() { model.updateData(); return model.solve(VIRTUAL_MACHINES_TABLE); } LoadBalance(final List<String> constraints);  }
LoadBalance { Result<? extends Record> run() { model.updateData(); return model.solve(VIRTUAL_MACHINES_TABLE); } LoadBalance(final List<String> constraints);   }