/** * Returns the maximum available MIPS among all the PEs of the host. * * @return max mips */ public double getMaxAvailableMips() { return getVmScheduler().getMaxAvailableMips(); }
/** * Releases PEs allocated to a VM. * * @param vm the vm * @pre $none * @post $none */ public void deallocatePesForVm(Vm vm) { getVmScheduler().deallocatePesForVm(vm); }
/** * Gets the total allocated MIPS for a VM along all its PEs. * * @param vm the vm * @return the allocated mips for vm */ public double getTotalAllocatedMipsForVm(Vm vm) { return getVmScheduler().getTotalAllocatedMipsForVm(vm); }
/** * Allocates PEs for a VM. * * @param vm the vm * @param mipsShare the list of MIPS share to be allocated to the VM * @return $true if this policy allows a new VM in the host, $false otherwise * @pre $none * @post $none */ public boolean allocatePesForVm(Vm vm, List<Double> mipsShare) { return getVmScheduler().allocatePesForVm(vm, mipsShare); }
/** * Gets the MIPS share of each Pe that is allocated to a given VM. * * @param vm the vm * @return an array containing the amount of MIPS of each pe that is available to the VM * @pre $none * @post $none */ public List<Double> getAllocatedMipsForVm(Vm vm) { return getVmScheduler().getAllocatedMipsForVm(vm); }
/** * Gets the total free MIPS available at the host. * * @return the free mips */ public double getAvailableMips() { return getVmScheduler().getAvailableMips(); }
/** * Removes a migrating in vm. * * @param vm the vm */ public void removeMigratingInVm(Vm vm) { vmDeallocate(vm); getVmsMigratingIn().remove(vm); getVmList().remove(vm); getVmScheduler().getVmsMigratingIn().remove(vm.getUid()); vm.setInMigration(false); }
/** * Requests updating of cloudlets' processing in VMs running in this host. * * @param currentTime the current time * @return expected time of completion of the next cloudlet in all VMs in this host or * {@link Double#MAX_VALUE} if there is no future events expected in this host * @pre currentTime >= 0.0 * @post $none * @todo there is an inconsistency between the return value of this method * and the individual call of {@link Vm#updateVmProcessing(double, java.util.List), * and consequently the {@link CloudletScheduler#updateVmProcessing(double, java.util.List)}. * The current method returns {@link Double#MAX_VALUE} while the other ones * return 0. It has to be checked if there is a reason for this * difference.} */ public double updateVmsProcessing(double currentTime) { double smallerTime = Double.MAX_VALUE; for (Vm vm : getVmList()) { double time = vm.updateVmProcessing( currentTime, getVmScheduler().getAllocatedMipsForVm(vm)); if (time > 0.0 && time < smallerTime) { smallerTime = time; } } return smallerTime; }
/** * Deallocate all resources of all VMs. */ protected void vmDeallocateAll() { getRamProvisioner().deallocateRamForAllVms(); getBwProvisioner().deallocateBwForAllVms(); getVmScheduler().deallocatePesForAllVms(); }
/** * 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()); } }
/** * Checks if the host is suitable for vm. If it has enough resources * to attend the VM. * * @param vm the vm * @return true, if is suitable for vm */ public boolean isSuitableForVm(Vm vm) { return (getVmScheduler().getPeCapacity() >= vm.getCurrentRequestedMaxMips() && getVmScheduler().getAvailableMips() >= vm.getCurrentRequestedTotalMips() && getRamProvisioner().isSuitableForVm(vm, vm.getCurrentRequestedRam()) && getBwProvisioner() .isSuitableForVm(vm, vm.getCurrentRequestedBw())); }
/** * Creates the given VM within the NetworkDatacenter. * It can be directly accessed by Datacenter Broker which manages allocation of Cloudlets. * * @param vm * @return true if the VW was created successfully, false otherwise */ public boolean processVmCreateNetwork(Vm vm) { boolean result = getVmAllocationPolicy().allocateHostForVm(vm); if (result) { VmToSwitchid.put(vm.getId(), ((NetworkHost) vm.getHost()).sw.getId()); VmtoHostlist.put(vm.getId(), vm.getHost().getId()); System.out.println(vm.getId() + " VM is created on " + vm.getHost().getId()); getVmList().add(vm); vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(vm).getVmScheduler() .getAllocatedMipsForVm(vm)); } return result; }
/** * Deallocate all resources of a VM. * * @param vm the VM */ protected void vmDeallocate(Vm vm) { getRamProvisioner().deallocateRamForVm(vm); getBwProvisioner().deallocateBwForVm(vm); getVmScheduler().deallocatePesForVm(vm); setStorage(getStorage() + vm.getSize()); }
getVmScheduler().getVmsMigratingIn().add(vm.getUid()); if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) { Log.printLine("[VmScheduler.addMigratingInVm] Allocation of VM #" + vm.getId() + " to Host #" + getId() + " failed by MIPS");
vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(vm).getVmScheduler() .getAllocatedMipsForVm(vm));
if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) { Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(), " failed by MIPS");