/** * Gets the current requested total mips. * * @return the current requested total mips */ public double getCurrentRequestedTotalMips() { double totalRequestedMips = 0; for (double mips : getCurrentRequestedMips()) { totalRequestedMips += mips; } return totalRequestedMips; }
/** * Gets the current requested max mips among all virtual PEs. * * @return the current requested max mips */ public double getCurrentRequestedMaxMips() { double maxMips = 0; for (double mips : getCurrentRequestedMips()) { if (mips > maxMips) { maxMips = mips; } } return maxMips; }
/** * Reallocate migrating in vms. Gets the VM in the migrating in queue * and allocate them on the host. */ public void reallocateMigratingInVms() { for (Vm vm : getVmsMigratingIn()) { if (!getVmList().contains(vm)) { getVmList().add(vm); } if (!getVmScheduler().getVmsMigratingIn().contains(vm.getUid())) { getVmScheduler().getVmsMigratingIn().add(vm.getUid()); } getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam()); getBwProvisioner().allocateBwForVm(vm, vm.getCurrentRequestedBw()); getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips()); setStorage(getStorage() - vm.getSize()); } }
/** * 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; }
if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) { Log.printLine("[VmScheduler.addMigratingInVm] Allocation of VM #" + vm.getId() + " to Host #" + getId() + " failed by MIPS");
getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips());
if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) { Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(), " failed by MIPS");