Commit f51d7050 authored by Anton Beloglazov's avatar Anton Beloglazov

Fixed Issue 37: Recalculating MIPS in findHostForVm()

parent 303b0297
......@@ -218,7 +218,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl
continue;
}
if (host.isSuitableForVm(vm)) {
if (host.getUtilizationOfCpuMips() != 0 && isHostOverUtilizedAfterAllocation(host, vm)) {
if (getUtilizationOfCpuMips(host) != 0 && isHostOverUtilizedAfterAllocation(host, vm)) {
continue;
}
......@@ -556,17 +556,29 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl
*/
protected double getMaxUtilizationAfterAllocation(PowerHost host, Vm vm) {
double requestedTotalMips = vm.getCurrentRequestedTotalMips();
double hostUtilizationMips = host.getUtilizationOfCpuMips();
double hostUtilizationMips = getUtilizationOfCpuMips(host);
double hostPotentialUtilizationMips = hostUtilizationMips + requestedTotalMips;
double pePotentialUtilization = hostPotentialUtilizationMips / host.getTotalMips();
return pePotentialUtilization;
}
/**
* Gets the utilization of the CPU in MIPS for the current potentially allocated VMs.
*
* @param host the host
*
* @return the utilization of the CPU in MIPS
*/
protected double getUtilizationOfCpuMips(PowerHost host) {
double hostUtilizationMips = 0;
for (Vm vm2 : host.getVmList()) {
if (host.getVmsMigratingIn().contains(vm2)) {
// calculate additional potential CPU usage of a migrating in VM
hostUtilizationMips += host.getTotalAllocatedMipsForVm(vm2) * 0.9 / 0.1;
}
hostUtilizationMips += host.getTotalAllocatedMipsForVm(vm2);
}
double hostPotentialUtilizationMips = hostUtilizationMips + requestedTotalMips;
double pePotentialUtilization = hostPotentialUtilizationMips / host.getTotalMips();
return pePotentialUtilization;
return hostUtilizationMips;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment