Skip to content

Commit e10020e

Browse files
committed
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
1 parent cf83700 commit e10020e

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,16 @@ private void scanDirectAgentToLoad() {
170170
long cutSeconds = (System.currentTimeMillis() >> 10) - (_pingInterval * 3);
171171
List<HostVO> hosts = _hostDao.findDirectAgentToLoad(cutSeconds, _loadSize);
172172
if (hosts != null && hosts.size() == _loadSize) {
173-
Long clusterId = hosts.get((int) (_loadSize - 1)).getClusterId();
174-
if (clusterId != null) {
175-
for (int i = (int) (_loadSize - 1); i > 0; i--) {
176-
if (hosts.get(i).getClusterId() == clusterId) {
177-
hosts.remove(i);
178-
} else {
179-
break;
173+
//if list contains more than one cluster, exclude the last cluster from the list
174+
if (hosts.size() > 1 && hosts.get(0).getClusterId().longValue() != hosts.get(hosts.size()-1).getClusterId().longValue()) {
175+
Long clusterId = hosts.get((int) (_loadSize - 1)).getClusterId();
176+
if (clusterId != null) {
177+
for (int i = (int) (_loadSize - 1); i > 0; i--) {
178+
if (hosts.get(i).getClusterId().longValue() == clusterId.longValue()) {
179+
hosts.remove(i);
180+
} else {
181+
break;
182+
}
180183
}
181184
}
182185
}
@@ -203,7 +206,7 @@ private void scanDirectAgentToLoad() {
203206
}
204207
loadDirectlyConnectedHost(host, false);
205208
} catch (Throwable e) {
206-
s_logger.debug(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to " + e.toString());
209+
s_logger.warn(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to ",e);
207210
}
208211
}
209212
}

0 commit comments

Comments
 (0)