/** * 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); }
/** * Releases PEs allocated to all the VMs. * * @pre $none * @post $none */ @Override public void deallocatePesForAllVms() { super.deallocatePesForAllVms(); getMipsMapRequested().clear(); setPesInUse(0); }
/** * Releases PEs allocated to a VM. * * @param vm the vm * @pre $none * @post $none */ public void deallocatePesForVm(Vm vm) { getVmScheduler().deallocatePesForVm(vm); }
/** * Creates a new VmScheduler. * * @param pelist the list of PEs of the host where the VmScheduler is associated to. * @pre peList != $null * @post $none */ public VmScheduler(List<? extends Pe> pelist) { setPeList(pelist); setPeMap(new HashMap<String, List<Pe>>()); setMipsMap(new HashMap<String, List<Double>>()); setAvailableMips(PeList.getTotalMips(getPeList())); setVmsMigratingIn(new ArrayList<String>()); setVmsMigratingOut(new ArrayList<String>()); }
/** * Releases PEs allocated to all the VMs of the host the VmScheduler is associated to. * After that, all PEs will be available to be used on demand for requesting VMs. * * @pre $none * @post $none */ public void deallocatePesForAllVms() { getMipsMap().clear(); setAvailableMips(PeList.getTotalMips(getPeList())); for (Pe pe : getPeList()) { pe.getPeProvisioner().deallocateMipsForAllVms(); } }
getVmScheduler().deallocatePesForVm(vm); getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips()); double totalAllocatedMips = getVmScheduler().getTotalAllocatedMipsForVm(vm); totalRequestedMips / vm.getMips() * 100); List<Pe> pes = getVmScheduler().getPesAllocatedForVM(vm); StringBuilder pesString = new StringBuilder(); for (Pe pe : pes) { + getNumberOfPes() + " * " + getVmScheduler().getPeCapacity() + ")." + pesString, CloudSim.clock());
/** * 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 total allocated MIPS for a VM along all its allocated PEs. * * @param vm the vm * @return the total allocated mips for the vm */ public double getTotalAllocatedMipsForVm(Vm vm) { double allocated = 0; List<Double> mipsMap = getAllocatedMipsForVm(vm); if (mipsMap != null) { for (double mips : mipsMap) { allocated += mips; } } return allocated; }
/** * 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())); }
/** * Returns PE capacity in MIPS. * * @return mips * @todo It considers that all PEs have the same capacity, * what has been shown doesn't be assured. The peList * received by the VmScheduler can be heterogeneous PEs. */ public double getPeCapacity() { if (getPeList() == null) { Log.printLine("Pe list is empty"); return 0; } return getPeList().get(0).getMips(); }
/** * Returns the MIPS share of each host's 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 getMipsMap().get(vm.getUid()); }
/** * Returns the maximum available MIPS among all the PEs of the host. * * @return max mips */ public double getMaxAvailableMips() { return getVmScheduler().getMaxAvailableMips(); }
/** * Gets the pes allocated for a vm. * * @param vm the vm * @return the pes allocated for the given vm */ public List<Pe> getPesAllocatedForVM(Vm vm) { return getPeMap().get(vm.getUid()); }
/** * Gets the total free MIPS available at the host. * * @return the free mips */ public double getAvailableMips() { return getVmScheduler().getAvailableMips(); }
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");
/** * 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); }
/** * Returns maximum available MIPS among all the host's PEs. * * @return max mips */ public double getMaxAvailableMips() { if (getPeList() == null) { Log.printLine("Pe list is empty"); return 0; } double max = 0.0; for (Pe pe : getPeList()) { double tmp = pe.getPeProvisioner().getAvailableMips(); if (tmp > max) { max = tmp; } } return max; }
/** * 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(); }
if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) { Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(), " failed by MIPS");