@Test public void getServersLoadAfterDeploymentPlan() { List<Vm> vms = new ArrayList<>(); vms.add(new Vm("vm1", "image", 2, 1024, 1, null, "")); vms.add(new Vm("vm2", "image", 1, 1024, 3, null, "")); vms.add(new Vm("vm3", "image", 1, 1024, 2, null, "")); List<Host> hosts = new ArrayList<>(); hosts.add(new HostFake("host1", 8, 8192, 8, 1, 1024, 1)); hosts.add(new HostFake("host2", 4, 4096, 4, 1, 1024, 1)); List<VmAssignmentToHost> vmAssignments = new ArrayList<>(); vmAssignments.add(new VmAssignmentToHost(vms.get(0), hosts.get(0))); vmAssignments.add(new VmAssignmentToHost(vms.get(1), hosts.get(1))); vmAssignments.add(new VmAssignmentToHost(vms.get(2), hosts.get(0))); DeploymentPlan deploymentPlan = new DeploymentPlan(vmAssignments); Map<String, ServerLoad> serversLoad = Scheduler.getServersLoadsAfterDeploymentPlanExecuted(deploymentPlan, hosts); assertEquals(0.5, serversLoad.get("host1").getCpuLoad(), 0.01); assertEquals(0.375, serversLoad.get("host1").getRamLoad(), 0.01); assertEquals(0.5, serversLoad.get("host1").getDiskLoad(), 0.01); assertEquals(0.5, serversLoad.get("host2").getCpuLoad(), 0.01); assertEquals(0.5, serversLoad.get("host2").getRamLoad(), 0.01); assertEquals(1, serversLoad.get("host2").getDiskLoad(), 0.01); }
public static Map<String, ServerLoad> getServersLoadsAfterDeploymentPlanExecuted(DeploymentPlan deploymentPlan, List<Host> hosts) { Map<String, ServerLoad> serversLoad = new HashMap<>(); for (Host host: hosts) { serversLoad.put(host.getHostname(), new ServerLoad(host.getServerLoad().getCpuLoad(), host.getServerLoad().getRamLoad(), host.getServerLoad().getDiskLoad())); } for (VmAssignmentToHost vmAssignmentToHost: deploymentPlan.getVmsAssignationsToHosts()) { Vm vmAssigned = vmAssignmentToHost.getVm(); Host deploymentHost = vmAssignmentToHost.getHost(); double newCpuLoad = serversLoad.get(deploymentHost.getHostname()).getCpuLoad() + (double) vmAssigned.getCpus()/deploymentHost.getTotalCpus(); double newRamLoad = serversLoad.get(deploymentHost.getHostname()).getRamLoad() + vmAssigned.getRamMb()/deploymentHost.getTotalMemoryMb(); double newDiskLoad = serversLoad.get(deploymentHost.getHostname()).getDiskLoad() + vmAssigned.getDiskGb()/deploymentHost.getTotalDiskGb(); serversLoad.put(deploymentHost.getHostname(), new ServerLoad(newCpuLoad, newRamLoad, newDiskLoad)); } return serversLoad; }
Scheduler { public static Map<String, ServerLoad> getServersLoadsAfterDeploymentPlanExecuted(DeploymentPlan deploymentPlan, List<Host> hosts) { Map<String, ServerLoad> serversLoad = new HashMap<>(); for (Host host: hosts) { serversLoad.put(host.getHostname(), new ServerLoad(host.getServerLoad().getCpuLoad(), host.getServerLoad().getRamLoad(), host.getServerLoad().getDiskLoad())); } for (VmAssignmentToHost vmAssignmentToHost: deploymentPlan.getVmsAssignationsToHosts()) { Vm vmAssigned = vmAssignmentToHost.getVm(); Host deploymentHost = vmAssignmentToHost.getHost(); double newCpuLoad = serversLoad.get(deploymentHost.getHostname()).getCpuLoad() + (double) vmAssigned.getCpus()/deploymentHost.getTotalCpus(); double newRamLoad = serversLoad.get(deploymentHost.getHostname()).getRamLoad() + vmAssigned.getRamMb()/deploymentHost.getTotalMemoryMb(); double newDiskLoad = serversLoad.get(deploymentHost.getHostname()).getDiskLoad() + vmAssigned.getDiskGb()/deploymentHost.getTotalDiskGb(); serversLoad.put(deploymentHost.getHostname(), new ServerLoad(newCpuLoad, newRamLoad, newDiskLoad)); } return serversLoad; } }
Scheduler { public static Map<String, ServerLoad> getServersLoadsAfterDeploymentPlanExecuted(DeploymentPlan deploymentPlan, List<Host> hosts) { Map<String, ServerLoad> serversLoad = new HashMap<>(); for (Host host: hosts) { serversLoad.put(host.getHostname(), new ServerLoad(host.getServerLoad().getCpuLoad(), host.getServerLoad().getRamLoad(), host.getServerLoad().getDiskLoad())); } for (VmAssignmentToHost vmAssignmentToHost: deploymentPlan.getVmsAssignationsToHosts()) { Vm vmAssigned = vmAssignmentToHost.getVm(); Host deploymentHost = vmAssignmentToHost.getHost(); double newCpuLoad = serversLoad.get(deploymentHost.getHostname()).getCpuLoad() + (double) vmAssigned.getCpus()/deploymentHost.getTotalCpus(); double newRamLoad = serversLoad.get(deploymentHost.getHostname()).getRamLoad() + vmAssigned.getRamMb()/deploymentHost.getTotalMemoryMb(); double newDiskLoad = serversLoad.get(deploymentHost.getHostname()).getDiskLoad() + vmAssigned.getDiskGb()/deploymentHost.getTotalDiskGb(); serversLoad.put(deploymentHost.getHostname(), new ServerLoad(newCpuLoad, newRamLoad, newDiskLoad)); } return serversLoad; } Scheduler(SchedAlgorithmNameEnum schedAlg, List<VmDeployed> vmsDeployed,
                     EnergyModeller energyModeller, PricingModeller pricingModeller); }
Scheduler { public static Map<String, ServerLoad> getServersLoadsAfterDeploymentPlanExecuted(DeploymentPlan deploymentPlan, List<Host> hosts) { Map<String, ServerLoad> serversLoad = new HashMap<>(); for (Host host: hosts) { serversLoad.put(host.getHostname(), new ServerLoad(host.getServerLoad().getCpuLoad(), host.getServerLoad().getRamLoad(), host.getServerLoad().getDiskLoad())); } for (VmAssignmentToHost vmAssignmentToHost: deploymentPlan.getVmsAssignationsToHosts()) { Vm vmAssigned = vmAssignmentToHost.getVm(); Host deploymentHost = vmAssignmentToHost.getHost(); double newCpuLoad = serversLoad.get(deploymentHost.getHostname()).getCpuLoad() + (double) vmAssigned.getCpus()/deploymentHost.getTotalCpus(); double newRamLoad = serversLoad.get(deploymentHost.getHostname()).getRamLoad() + vmAssigned.getRamMb()/deploymentHost.getTotalMemoryMb(); double newDiskLoad = serversLoad.get(deploymentHost.getHostname()).getDiskLoad() + vmAssigned.getDiskGb()/deploymentHost.getTotalDiskGb(); serversLoad.put(deploymentHost.getHostname(), new ServerLoad(newCpuLoad, newRamLoad, newDiskLoad)); } return serversLoad; } Scheduler(SchedAlgorithmNameEnum schedAlg, List<VmDeployed> vmsDeployed,
                     EnergyModeller energyModeller, PricingModeller pricingModeller); synchronized void setSchedAlgorithm(SchedAlgorithmNameEnum schedAlg); static double calculateStDevCpuLoad(Collection<ServerLoad> serversLoad); static double calculateStDevMemLoad(Collection<ServerLoad> serversLoad); static double calculateStDevDiskLoad(Collection<ServerLoad> serversLoad); static double getTotalUnusedCpuPerc(Collection<ServerLoad> serverLoads); static double getTotalUnusedMemPerc(Collection<ServerLoad> serverLoads); static double getTotalUnusedDiskPerc(Collection<ServerLoad> serverLoads); static Map<String, ServerLoad> getServersLoadsAfterDeploymentPlanExecuted(DeploymentPlan deploymentPlan,
            List<Host> hosts); DeploymentPlan chooseBestDeploymentPlan(List<Vm> vms, List<Host> hosts); }
Scheduler { public static Map<String, ServerLoad> getServersLoadsAfterDeploymentPlanExecuted(DeploymentPlan deploymentPlan, List<Host> hosts) { Map<String, ServerLoad> serversLoad = new HashMap<>(); for (Host host: hosts) { serversLoad.put(host.getHostname(), new ServerLoad(host.getServerLoad().getCpuLoad(), host.getServerLoad().getRamLoad(), host.getServerLoad().getDiskLoad())); } for (VmAssignmentToHost vmAssignmentToHost: deploymentPlan.getVmsAssignationsToHosts()) { Vm vmAssigned = vmAssignmentToHost.getVm(); Host deploymentHost = vmAssignmentToHost.getHost(); double newCpuLoad = serversLoad.get(deploymentHost.getHostname()).getCpuLoad() + (double) vmAssigned.getCpus()/deploymentHost.getTotalCpus(); double newRamLoad = serversLoad.get(deploymentHost.getHostname()).getRamLoad() + vmAssigned.getRamMb()/deploymentHost.getTotalMemoryMb(); double newDiskLoad = serversLoad.get(deploymentHost.getHostname()).getDiskLoad() + vmAssigned.getDiskGb()/deploymentHost.getTotalDiskGb(); serversLoad.put(deploymentHost.getHostname(), new ServerLoad(newCpuLoad, newRamLoad, newDiskLoad)); } return serversLoad; } Scheduler(SchedAlgorithmNameEnum schedAlg, List<VmDeployed> vmsDeployed,
                     EnergyModeller energyModeller, PricingModeller pricingModeller); synchronized void setSchedAlgorithm(SchedAlgorithmNameEnum schedAlg); static double calculateStDevCpuLoad(Collection<ServerLoad> serversLoad); static double calculateStDevMemLoad(Collection<ServerLoad> serversLoad); static double calculateStDevDiskLoad(Collection<ServerLoad> serversLoad); static double getTotalUnusedCpuPerc(Collection<ServerLoad> serverLoads); static double getTotalUnusedMemPerc(Collection<ServerLoad> serverLoads); static double getTotalUnusedDiskPerc(Collection<ServerLoad> serverLoads); static Map<String, ServerLoad> getServersLoadsAfterDeploymentPlanExecuted(DeploymentPlan deploymentPlan,
            List<Host> hosts); DeploymentPlan chooseBestDeploymentPlan(List<Vm> vms, List<Host> hosts);  }