Fixed the bug in AgentLB: consider only hosts of type=Routing when calculate average load

This commit is contained in:
alena 2011-09-08 14:33:28 -07:00
parent a118880836
commit 6e6b6ab2ab
3 changed files with 8 additions and 3 deletions

View File

@ -66,7 +66,7 @@ public class ClusterBasedAgentLoadBalancerPlanner implements AgentLoadBalancerPl
@Override
public List<HostVO> getHostsToRebalance(long msId, int avLoad) {
List<HostVO> allHosts = _hostDao.listByManagementServer(msId);
List<HostVO> allHosts = _hostDao.listRoutingHostsByManagementServer(msId);
if (allHosts.size() <= avLoad) {
s_logger.debug("Agent load = " + allHosts.size() + " for management server " + msId + " doesn't exceed average system agent load = " + avLoad + "; so it doesn't participate in agent rebalancing process");
@ -101,6 +101,7 @@ public class ClusterBasedAgentLoadBalancerPlanner implements AgentLoadBalancerPl
int hostsLeft = directHosts.size();
List<HostVO> hostsToReturn = new ArrayList<HostVO>();
s_logger.debug("Management server " + msId + " can give away " + hostsToGive + " as it currently owns " + allHosts.size() + " and the average agent load in the system is " + avLoad + "; finalyzing list of hosts to give away...");
for (Long cluster : hostToClusterMap.keySet()) {
List<HostVO> hostsInCluster = hostToClusterMap.get(cluster);
hostsLeft = hostsLeft - hostsInCluster.size();
@ -115,6 +116,7 @@ public class ClusterBasedAgentLoadBalancerPlanner implements AgentLoadBalancerPl
//get all hosts that are needed from the cluster
s_logger.debug("Taking " + hostsLeftToGive + " from cluster " + cluster);
for (int i=0; i < hostsLeftToGive; i++) {
s_logger.trace("Taking host id=" + hostsInCluster.get(i) + " from cluster " + cluster);
hostsToReturn.add(hostsInCluster.get(i));
}
@ -130,6 +132,7 @@ public class ClusterBasedAgentLoadBalancerPlanner implements AgentLoadBalancerPl
}
}
s_logger.debug("Management server " + msId + " is ready to give away " + hostsToReturn.size() + " hosts");
return hostsToReturn;
}

View File

@ -168,7 +168,7 @@ public interface HostDao extends GenericDao<HostVO, Long> {
List<HostVO> listAllSecondaryStorageHosts(long dataCenterId);
List<HostVO> listByManagementServer(long msId);
List<HostVO> listRoutingHostsByManagementServer(long msId);
List<HostVO> listSecondaryStorageVM(long dcId);

View File

@ -133,6 +133,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
MsStatusSearch = createSearchBuilder();
MsStatusSearch.and("ms", MsStatusSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
MsStatusSearch.and("type", MsStatusSearch.entity().getType(), SearchCriteria.Op.EQ);
MsStatusSearch.and("statuses", MsStatusSearch.entity().getStatus(), SearchCriteria.Op.NIN);
MsStatusSearch.done();
@ -995,9 +996,10 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
}
@Override
public List<HostVO> listByManagementServer(long msId) {
public List<HostVO> listRoutingHostsByManagementServer(long msId) {
SearchCriteria<HostVO> sc = MsStatusSearch.create();
sc.setParameters("ms", msId);
sc.setParameters("type", Type.Routing);
return listBy(sc);
}