/** * Gets the power after allocation. * * @param host the host. * @param vm the virtual machine. * @return the power usage after allocation of the virtual machine. */ protected double getPowerAfterAllocation(PowerHost host, Vm vm) { List<Double> allocatedMipsForVm = null; PowerHost allocatedHost = (PowerHost) vm.getHost(); if (allocatedHost != null) { allocatedMipsForVm = allocatedHost.getAllocatedMipsForVm(vm); } if (!host.allocatePesForVm(vm, vm.getCurrentRequestedMips())) { return -1; } double power = host.getPower(); host.deallocatePesForVm(vm); if (allocatedHost != null && allocatedMipsForVm != null) { vm.getHost().allocatePesForVm(vm, allocatedMipsForVm); } return power; }
/** * Gets the max utilization among the PEs of a given VM placed at a given host. * @param host The host where the VM is placed * @param vm The VM to get the max PEs utilization * @return The max utilization among the PEs of the VM */ protected double getMaxUtilizationAfterAllocation(NetworkHost host, Vm vm) { List<Double> allocatedMipsForVm = null; NetworkHost allocatedHost = (NetworkHost) vm.getHost(); if (allocatedHost != null) { allocatedMipsForVm = vm.getHost().getAllocatedMipsForVm(vm); } if (!host.allocatePesForVm(vm, vm.getCurrentRequestedMips())) { return -1; } double maxUtilization = host.getMaxUtilizationAmongVmsPes(vm); host.deallocatePesForVm(vm); if (allocatedHost != null && allocatedMipsForVm != null) { vm.getHost().allocatePesForVm(vm, allocatedMipsForVm); } return maxUtilization; }
/** * Gets the maximum utilization after allocation. * * @param host the host. * @param vm the virtual machine. * @return the maximum utilization after allocation of the virtual machine. */ protected double getMaxUtilizationAfterAllocation(PowerHost host, Vm vm) { List<Double> allocatedMipsForVm = null; PowerHost allocatedHost = (PowerHost) vm.getHost(); if (allocatedHost != null) { allocatedMipsForVm = vm.getHost().getAllocatedMipsForVm(vm); } if (!host.allocatePesForVm(vm, vm.getCurrentRequestedMips())) { return -1; } double maxUtilization = host.getMaxUtilizationAmongVmsPes(vm); host.deallocatePesForVm(vm); if (allocatedHost != null && allocatedMipsForVm != null) { vm.getHost().allocatePesForVm(vm, allocatedMipsForVm); } return maxUtilization; }