From 5134b44ff5ea3c3b542371870c9fdb76120f7b70 Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 29 Jun 2011 11:24:48 -0700 Subject: [PATCH] bug 10496: fixed various problems in scanDirectAgentToLoad code (1) case when loadSize=clusterSize wasn't working 2) Long value comparison was done incorrectly) status 10496: resolved fixed --- .../manager/ClusteredAgentManagerImpl.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index dbc8477546e..5d5eb862cba 100644 --- a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -170,13 +170,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust long cutSeconds = (System.currentTimeMillis() >> 10) - (_pingInterval * 3); List hosts = _hostDao.findDirectAgentToLoad(cutSeconds, _loadSize); if (hosts != null && hosts.size() == _loadSize) { - Long clusterId = hosts.get((int) (_loadSize - 1)).getClusterId(); - if (clusterId != null) { - for (int i = (int) (_loadSize - 1); i > 0; i--) { - if (hosts.get(i).getClusterId() == clusterId) { - hosts.remove(i); - } else { - break; + //if list contains more than one cluster, exclude the last cluster from the list + if (hosts.size() > 1 && hosts.get(0).getClusterId().longValue() != hosts.get(hosts.size()-1).getClusterId().longValue()) { + Long clusterId = hosts.get((int) (_loadSize - 1)).getClusterId(); + if (clusterId != null) { + for (int i = (int) (_loadSize - 1); i > 0; i--) { + if (hosts.get(i).getClusterId().longValue() == clusterId.longValue()) { + hosts.remove(i); + } else { + break; + } } } } @@ -203,7 +206,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust } loadDirectlyConnectedHost(host, false); } catch (Throwable e) { - s_logger.debug(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to " + e.toString()); + s_logger.warn(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to ",e); } } }