/** * 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; }
/** * 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); }
/** * 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; }
@Override public double updateVmsProcessing(double currentTime) { double smallerTime = Double.MAX_VALUE; // insert in each vm packet recieved recvpackets(); for (Vm vm : super.getVmList()) { double time = ((NetworkVm) vm).updateVmProcessing(currentTime, getVmScheduler() .getAllocatedMipsForVm(vm)); if (time > 0.0 && time < smallerTime) { smallerTime = time; } } // send the packets to other hosts/VMs sendpackets(); return smallerTime; }
vm.updateVmProcessing(CloudSim.clock(), getVmScheduler().getAllocatedMipsForVm(vm));
/** * 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; }