CLOUDSTACK-5391:

check for host cpu capability while stop starting a vm on the same host. Also changed the FirstFitAllocator to use the same method.
This commit is contained in:
Nitin Mehta 2013-12-05 15:37:01 -08:00
parent 98ee087d31
commit ed1f3d9ed6
2 changed files with 6 additions and 8 deletions

View File

@ -286,8 +286,6 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
continue; continue;
} }
boolean numCpusGood = host.getCpus().intValue() >= offering.getCpu();
boolean cpuFreqGood = host.getSpeed().intValue() >= offering.getSpeed();
int cpu_requested = offering.getCpu() * offering.getSpeed(); int cpu_requested = offering.getCpu() * offering.getSpeed();
long ram_requested = offering.getRamSize() * 1024L * 1024L; long ram_requested = offering.getRamSize() * 1024L * 1024L;
Cluster cluster = _clusterDao.findById(host.getClusterId()); Cluster cluster = _clusterDao.findById(host.getClusterId());
@ -296,19 +294,18 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
Float cpuOvercommitRatio = Float.parseFloat(clusterDetailsCpuOvercommit.getValue()); Float cpuOvercommitRatio = Float.parseFloat(clusterDetailsCpuOvercommit.getValue());
Float memoryOvercommitRatio = Float.parseFloat(clusterDetailsRamOvercommmt.getValue()); Float memoryOvercommitRatio = Float.parseFloat(clusterDetailsRamOvercommmt.getValue());
boolean hostHasCapacity = boolean hostHasCpuCapability = _capacityMgr.checkIfHostHasCpuCapability(host.getId(), offering.getCpu(), offering.getSpeed());
_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, false, cpuOvercommitRatio, memoryOvercommitRatio, boolean hostHasCapacity = _capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, false, cpuOvercommitRatio, memoryOvercommitRatio,
considerReservedCapacity); considerReservedCapacity);
if (numCpusGood && cpuFreqGood && hostHasCapacity) { if (hostHasCpuCapability && hostHasCapacity) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Found a suitable host, adding to list: " + host.getId()); s_logger.debug("Found a suitable host, adding to list: " + host.getId());
} }
suitableHosts.add(host); suitableHosts.add(host);
} else { } else {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Not using host " + host.getId() + "; numCpusGood: " + numCpusGood + "; cpuFreqGood: " + cpuFreqGood + ", host has capacity?" + s_logger.debug("Not using host " + host.getId() + "; host has cpu capability? " + hostHasCpuCapability + ", host has capacity?" + hostHasCapacity);
hostHasCapacity);
} }
avoid.addHost(host.getId()); avoid.addHost(host.getId());
} }

View File

@ -361,7 +361,8 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id, "memoryOvercommitRatio"); ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id, "memoryOvercommitRatio");
Float cpuOvercommitRatio = Float.parseFloat(cluster_detail_cpu.getValue()); Float cpuOvercommitRatio = Float.parseFloat(cluster_detail_cpu.getValue());
Float memoryOvercommitRatio = Float.parseFloat(cluster_detail_ram.getValue()); Float memoryOvercommitRatio = Float.parseFloat(cluster_detail_ram.getValue());
if (_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true, cpuOvercommitRatio, memoryOvercommitRatio, true)) { if (_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true, cpuOvercommitRatio, memoryOvercommitRatio, true)
&& _capacityMgr.checkIfHostHasCpuCapability(host.getId(), offering.getCpu(), offering.getSpeed())) {
s_logger.debug("The last host of this VM is UP and has enough capacity"); s_logger.debug("The last host of this VM is UP and has enough capacity");
s_logger.debug("Now checking for suitable pools under zone: " + host.getDataCenterId() + ", pod: " + host.getPodId() + ", cluster: " + s_logger.debug("Now checking for suitable pools under zone: " + host.getDataCenterId() + ", pod: " + host.getPodId() + ", cluster: " +
host.getClusterId()); host.getClusterId());