/** * Gets the VMs to migrate from under utilized host. * * @param host the host * @return the vms to migrate from under utilized host */ protected List<? extends Vm> getVmsToMigrateFromUnderUtilizedHost(PowerHost host) { List<Vm> vmsToMigrate = new LinkedList<Vm>(); for (Vm vm : host.getVmList()) { if (!vm.isInMigration()) { vmsToMigrate.add(vm); } } return vmsToMigrate; }
/** * Checks if PowerDatacenter is in migration. * * @return true, if PowerDatacenter is in migration; false otherwise */ protected boolean isInMigration() { boolean result = false; for (Vm vm : getVmList()) { if (vm.isInMigration()) { result = true; break; } } return result; }
/** * Gets the list of completed vms. * * @return the completed vms */ public List<Vm> getCompletedVms() { List<Vm> vmsToRemove = new ArrayList<Vm>(); for (Vm vm : getVmList()) { if (vm.isInMigration()) { continue; } if (vm.getCurrentRequestedTotalMips() == 0) { vmsToRemove.add(vm); } } return vmsToRemove; }
@Override public Vm getVmToMigrate(PowerHost host) { List<PowerVm> migratableVms = getMigratableVms(host); if (migratableVms.isEmpty()) { return null; } Vm vmToMigrate = null; double minMetric = Double.MAX_VALUE; for (Vm vm : migratableVms) { if (vm.isInMigration()) { continue; } double metric = vm.getRam(); if (metric < minMetric) { minMetric = metric; vmToMigrate = vm; } } return vmToMigrate; }
/** * Gets the CPU utilization of a host. * * @param host the host to be analyzed. * @since 1.0 */ protected static double getHostCpuUtilization(PowerHost host) { double cpuUtilization = host.getUtilizationOfCpuMips(); //Disconsider the resources of vms migrating out for (Vm vm : host.getVmList()) { if (vm.isInMigration()) { cpuUtilization -= host.getTotalAllocatedMipsForVm(vm); } } //Include resources of vms migrating in for (Vm vm : host.getVmsMigratingIn()) { if (vm.isInMigration()) { cpuUtilization += vm.getCurrentRequestedTotalMips(); } } return cpuUtilization; }
/** * Gets the RAM utilization of a host. * * @param host the host to be analyzed. * @since 1.0 */ protected static double getHostRamUtilization(PowerHost host) { double ramUtilization = host.getUtilizationOfRam(); //Disconsider the resources of vms migrating out for (Vm vm : host.getVmList()) { if (vm.isInMigration()) { ramUtilization -= vm.getRam(); } } //Include resources of vms migrating in for (Vm vm : host.getVmsMigratingIn()) { if (vm.isInMigration()) { ramUtilization += vm.getRam(); } } return ramUtilization; }
@Override public Vm getVmToMigrate(PowerHost host) { List<PowerVm> migratableVms = getMigratableVms(host); if (migratableVms.isEmpty()) { return null; } Vm vmToMigrate = null; double minMetric = Double.MAX_VALUE; for (Vm vm : migratableVms) { if (vm.isInMigration()) { continue; } double metric = vm.getTotalUtilizationOfCpuMips(CloudSim.clock()) / vm.getMips(); if (metric < minMetric) { minMetric = metric; vmToMigrate = vm; } } return vmToMigrate; }
@Override public boolean allocatePesForVm(Vm vm, List<Double> mipsShareRequested) { /* * @todo add the same to RAM and BW provisioners */ if (vm.isInMigration()) { if (!getVmsMigratingIn().contains(vm.getUid()) && !getVmsMigratingOut().contains(vm.getUid())) { getVmsMigratingOut().add(vm.getUid()); } } else { if (getVmsMigratingOut().contains(vm.getUid())) { getVmsMigratingOut().remove(vm.getUid()); } } boolean result = allocatePesForVm(vm.getUid(), mipsShareRequested); updatePeProvisioning(); return result; }
if (vm.isInMigration()) { continue;
if (vm.isInMigration()) { continue;
totalAllocatedMips, totalRequestedMips, (vm.isInMigration() && !getVmsMigratingIn().contains(vm))); if (vm.isInMigration()) { Log.formatLine( "%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is in migration",