@Test public void isBetterPlanReturnsTrueWhenSameStdDevCpuSameStdDevRamAndLessStdDevDiskLoad() { List<Vm> vms = new ArrayList<>(); vms.add(new Vm("vm1", "image", 2, 1024, 2, null, "")); vms.add(new Vm("vm2", "image", 2, 1024, 1, null, "")); List<Host> hosts = new ArrayList<>(); hosts.add(new HostFake("host1", 4, 4096, 4, 2, 1024, 2)); hosts.add(new HostFake("host2", 4, 4096, 4, 2, 1024, 1)); List<VmAssignmentToHost> assignmentsPlan1 = new ArrayList<>(); assignmentsPlan1.add(new VmAssignmentToHost(vms.get(0), hosts.get(0))); assignmentsPlan1.add(new VmAssignmentToHost(vms.get(1), hosts.get(1))); DeploymentPlan deploymentPlan1 = new DeploymentPlan(assignmentsPlan1); List<VmAssignmentToHost> assignmentsPlan2 = new ArrayList<>(); assignmentsPlan2.add(new VmAssignmentToHost(vms.get(0), hosts.get(1))); assignmentsPlan2.add(new VmAssignmentToHost(vms.get(1), hosts.get(0))); DeploymentPlan deploymentPlan2 = new DeploymentPlan(assignmentsPlan2); List<DeploymentPlan> deploymentPlans = new ArrayList<>(); deploymentPlans.add(deploymentPlan1); deploymentPlans.add(deploymentPlan2); assertEquals(deploymentPlan2, scheduler.chooseBestDeploymentPlan(deploymentPlans, hosts, "testId")); }
@Override public DeploymentPlan chooseBestDeploymentPlan(List<DeploymentPlan> deploymentPlans, List<Host> hosts, String deploymentId) { DeploymentPlan bestDeploymentPlan = null; for (DeploymentPlan deploymentPlan: deploymentPlans) { Collection<ServerLoad> serversLoad = Scheduler.getServersLoadsAfterDeploymentPlanExecuted(deploymentPlan, hosts).values(); VMMLogger.logServersLoadsAfterDeploymentPlan(deploymentPlan, countIdleServers(serversLoad), Scheduler.calculateStDevCpuLoad(serversLoad), Scheduler.calculateStDevMemLoad(serversLoad), Scheduler.calculateStDevDiskLoad(serversLoad), deploymentId); if (bestDeploymentPlan == null || isBetterDeploymentPlan(deploymentPlan, bestDeploymentPlan, hosts)) { bestDeploymentPlan = deploymentPlan; } } return bestDeploymentPlan; }
SchedAlgDistribution implements SchedAlgorithm { @Override public DeploymentPlan chooseBestDeploymentPlan(List<DeploymentPlan> deploymentPlans, List<Host> hosts, String deploymentId) { DeploymentPlan bestDeploymentPlan = null; for (DeploymentPlan deploymentPlan: deploymentPlans) { Collection<ServerLoad> serversLoad = Scheduler.getServersLoadsAfterDeploymentPlanExecuted(deploymentPlan, hosts).values(); VMMLogger.logServersLoadsAfterDeploymentPlan(deploymentPlan, countIdleServers(serversLoad), Scheduler.calculateStDevCpuLoad(serversLoad), Scheduler.calculateStDevMemLoad(serversLoad), Scheduler.calculateStDevDiskLoad(serversLoad), deploymentId); if (bestDeploymentPlan == null || isBetterDeploymentPlan(deploymentPlan, bestDeploymentPlan, hosts)) { bestDeploymentPlan = deploymentPlan; } } return bestDeploymentPlan; } }
SchedAlgDistribution implements SchedAlgorithm { @Override public DeploymentPlan chooseBestDeploymentPlan(List<DeploymentPlan> deploymentPlans, List<Host> hosts, String deploymentId) { DeploymentPlan bestDeploymentPlan = null; for (DeploymentPlan deploymentPlan: deploymentPlans) { Collection<ServerLoad> serversLoad = Scheduler.getServersLoadsAfterDeploymentPlanExecuted(deploymentPlan, hosts).values(); VMMLogger.logServersLoadsAfterDeploymentPlan(deploymentPlan, countIdleServers(serversLoad), Scheduler.calculateStDevCpuLoad(serversLoad), Scheduler.calculateStDevMemLoad(serversLoad), Scheduler.calculateStDevDiskLoad(serversLoad), deploymentId); if (bestDeploymentPlan == null || isBetterDeploymentPlan(deploymentPlan, bestDeploymentPlan, hosts)) { bestDeploymentPlan = deploymentPlan; } } return bestDeploymentPlan; } SchedAlgDistribution(); }
SchedAlgDistribution implements SchedAlgorithm { @Override public DeploymentPlan chooseBestDeploymentPlan(List<DeploymentPlan> deploymentPlans, List<Host> hosts, String deploymentId) { DeploymentPlan bestDeploymentPlan = null; for (DeploymentPlan deploymentPlan: deploymentPlans) { Collection<ServerLoad> serversLoad = Scheduler.getServersLoadsAfterDeploymentPlanExecuted(deploymentPlan, hosts).values(); VMMLogger.logServersLoadsAfterDeploymentPlan(deploymentPlan, countIdleServers(serversLoad), Scheduler.calculateStDevCpuLoad(serversLoad), Scheduler.calculateStDevMemLoad(serversLoad), Scheduler.calculateStDevDiskLoad(serversLoad), deploymentId); if (bestDeploymentPlan == null || isBetterDeploymentPlan(deploymentPlan, bestDeploymentPlan, hosts)) { bestDeploymentPlan = deploymentPlan; } } return bestDeploymentPlan; } SchedAlgDistribution(); @Override DeploymentPlan chooseBestDeploymentPlan(List<DeploymentPlan> deploymentPlans, List<Host> hosts,
            String deploymentId); @Override SchedAlgorithmNameEnum getNameEnum(); }
SchedAlgDistribution implements SchedAlgorithm { @Override public DeploymentPlan chooseBestDeploymentPlan(List<DeploymentPlan> deploymentPlans, List<Host> hosts, String deploymentId) { DeploymentPlan bestDeploymentPlan = null; for (DeploymentPlan deploymentPlan: deploymentPlans) { Collection<ServerLoad> serversLoad = Scheduler.getServersLoadsAfterDeploymentPlanExecuted(deploymentPlan, hosts).values(); VMMLogger.logServersLoadsAfterDeploymentPlan(deploymentPlan, countIdleServers(serversLoad), Scheduler.calculateStDevCpuLoad(serversLoad), Scheduler.calculateStDevMemLoad(serversLoad), Scheduler.calculateStDevDiskLoad(serversLoad), deploymentId); if (bestDeploymentPlan == null || isBetterDeploymentPlan(deploymentPlan, bestDeploymentPlan, hosts)) { bestDeploymentPlan = deploymentPlan; } } return bestDeploymentPlan; } SchedAlgDistribution(); @Override DeploymentPlan chooseBestDeploymentPlan(List<DeploymentPlan> deploymentPlans, List<Host> hosts,
            String deploymentId); @Override SchedAlgorithmNameEnum getNameEnum();  }