Fix wrong usage of SearchCriteria2 in AgentMonitor

This commit is contained in:
frank 2011-11-23 11:05:39 -08:00
parent cdd94c1b9a
commit 275a5ffa3c
1 changed files with 3 additions and 2 deletions

View File

@ -141,10 +141,11 @@ public class AgentMonitor extends Thread implements Listener {
try {
List<Long> behindAgents = findAgentsBehindOnPing();
for (Long agentId : behindAgents) {
SearchCriteriaService<HostVO, ResourceState> sc = SearchCriteria2.create(HostVO.class, ResourceState.class);
SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
sc.selectField(sc.getEntity().getResourceState());
sc.addAnd(sc.getEntity().getId(), Op.EQ, agentId);
ResourceState resourceState = sc.find();
HostVO h = sc.find();
ResourceState resourceState = h.getResourceState();
if (resourceState == ResourceState.Disabled || resourceState == ResourceState.Maintenance || resourceState == ResourceState.Unmanaged || resourceState == ResourceState.ErrorInMaintenance) {
/* Host is in non-operation state, so no investigation and direct put agent to Disconnected */
status_Logger.debug("Ping timeout but host " + agentId + " is in resource state of " + resourceState + ", so no investigation");