From 9897e55db80dbfc8f035e7069b27121ce4d562df Mon Sep 17 00:00:00 2001 From: prachi Date: Wed, 23 Mar 2011 16:10:21 -0700 Subject: [PATCH] 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. --- .../allocator/impl/UserConcentratedAllocator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java index e92c1b2ad51..5960e25abd9 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java @@ -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 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(pod, podHostCandidates.get(podId)); } List 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(pod, podHostCandidates.get(podId)); }