ensure that we pick an idle elb vm in the same pod as the ip

This commit is contained in:
Chiradeep Vittal 2011-08-05 17:46:42 -07:00
parent ec7c9a2f7e
commit b4a6f2103a

View File

@ -429,7 +429,12 @@ public class ElasticLoadBalancerManagerImpl implements
private DomainRouterVO findELBVmWithCapacity(Network guestNetwork, IPAddressVO ipAddr) {
List<DomainRouterVO> unusedElbVms = _elbVmMapDao.listUnusedElbVms();
if (unusedElbVms.size() > 0) {
return unusedElbVms.get(new Random().nextInt(unusedElbVms.size()));
List<DomainRouterVO> candidateVms = new ArrayList<DomainRouterVO>();
for (DomainRouterVO candidateVm: unusedElbVms) {
if (candidateVm.getPodIdToDeployIn() == getPodIdForDirectIp(ipAddr))
candidateVms.add(candidateVm);
}
return candidateVms.size()==0?null:candidateVms.get(new Random().nextInt(candidateVms.size()));
}
return null;
}