Bug 9117: allocator performance improvements

Change is to add a pod to 'avoids' set when the Pod Allocator finds that the pod does not have enough CPU/RAM capacity.

Due to this, when the allocator is called again in that deploy VM thread, it will not consider that same pod again.
Thus the capacity calculation for that pod would happen just once and then it would be avoided in every next call to the Allocator.
This commit is contained in:
prachi 2011-03-23 16:10:21 -07:00
parent f840c968d9
commit 9897e55db8
1 changed files with 10 additions and 0 deletions

View File

@ -96,6 +96,10 @@ public class UserConcentratedAllocator implements PodAllocator {
for (HostPodVO pod: podsInZone) {
long podId = pod.getId();
if (!avoids.contains(podId)) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Checking Pod: " + podId);
}
if (template != null && !templateAvailableInPod(template.getId(), pod.getDataCenterId(), podId)) {
continue;
}
@ -108,7 +112,9 @@ public class UserConcentratedAllocator implements PodAllocator {
if (!enoughCapacity) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Not enough RAM available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")");
s_logger.debug("Adding Pod to avoid list (zone: " + zoneId + ", pod: " + podId + ")");
}
avoids.add(podId);
continue;
}
@ -117,7 +123,9 @@ public class UserConcentratedAllocator implements PodAllocator {
if (!enoughCapacity) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Not enough cpu available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")");
s_logger.debug("Adding Pod to avoid list (zone: " + zoneId + ", pod: " + podId + ")");
}
avoids.add(podId);
continue;
}
@ -127,11 +135,13 @@ public class UserConcentratedAllocator implements PodAllocator {
// If the pod has VMs or volumes in it, return this pod
List<UserVmVO> vmsInPod = _vmDao.listByAccountAndPod(accountId, pod.getId());
if (!vmsInPod.isEmpty()) {
s_logger.debug("Returning pod since it has VMs for this account, podid: "+pod.getId() +" ,name: " + pod.getName() + " in zone " + zone.getName());
return new Pair<HostPodVO, Long>(pod, podHostCandidates.get(podId));
}
List<VolumeVO> volumesInPod = _volumeDao.findByAccountAndPod(accountId, pod.getId());
if (!volumesInPod.isEmpty()) {
s_logger.debug("Returning pod since it has Volumes for this account, podid: "+pod.getId() +" ,name: " + pod.getName() + " in zone " + zone.getName());
return new Pair<HostPodVO, Long>(pod, podHostCandidates.get(podId));
}