/** * 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; }
/** * 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; }
/** * 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; }
getVmsToDatacentersMap().put(vmId, datacenterId); getVmsCreatedList().add(VmList.getById(getVmList(), vmId)); Log.printLine(CloudSim.clock()+": "+getName()+ ": VM #"+vmId+" has been created in " + getDatacenterCharacteristicsList().get(datacenterId).getResourceName() + ", Host #" + VmList.getById(getVmsCreatedList(), vmId).getHost().getId()); } else { Log.printLine(CloudSim.clock()+": "+getName()+ ": Creation of VM #"+vmId+" failed in "+ getDatacenterCharacteristicsList().get(datacenterId).getResourceName());
getVmList().add(vm); updateVmsProcessing(CloudSim.clock()); vm.getHost().updateVmsProcessing(CloudSim.clock());
Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": VM #", vmId, " has been created in Datacenter #", datacenterId, ", Host #", VmList.getById(getVmsCreatedList(), vmId).getHost().getId()); } else { Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Creation of VM #", vmId,
Vm vm = (Vm) migrate.get("vm"); PowerHost targetHost = (PowerHost) migrate.get("host"); PowerHost oldHost = (PowerHost) vm.getHost();
Log.formatLine( "%.2f: [Host #" + getId() + "] Total allocated MIPS for VM #" + vm.getId() + " (Host #" + vm.getHost().getId() + ") is %.2f, was requested %.2f out of total %.2f (%.2f%%)", CloudSim.clock(),
Vm vm = (Vm) migrate.get("vm"); PowerHost targetHost = (PowerHost) migrate.get("host"); PowerHost oldHost = (PowerHost) vm.getHost();