@@ -71,7 +71,7 @@ public class AgentMonitor extends Thread implements Listener {
7171 private ConnectionConcierge _concierge ;
7272 @ Inject ClusterDao _clusterDao ;
7373 @ Inject ResourceManager _resourceMgr ;
74-
74+
7575 // private ConnectionConcierge _concierge;
7676 private Map <Long , Long > _pingMap ;
7777
@@ -104,7 +104,7 @@ public AgentMonitor(long msId, HostDao hostDao, VMInstanceDao vmDao, DataCenterD
104104
105105 /**
106106 * Check if the agent is behind on ping
107- *
107+ *
108108 * @param agentId
109109 * agent or host id.
110110 * @return null if the agent is not kept here. true if behind; false if not.
@@ -144,21 +144,29 @@ public void run() {
144144 SearchCriteriaService <HostVO , HostVO > sc = SearchCriteria2 .create (HostVO .class );
145145 sc .addAnd (sc .getEntity ().getId (), Op .EQ , agentId );
146146 HostVO h = sc .find ();
147- ResourceState resourceState = h .getResourceState ();
148- if (resourceState == ResourceState .Disabled || resourceState == ResourceState .Maintenance || resourceState == ResourceState .ErrorInMaintenance ) {
149- /* Host is in non-operation state, so no investigation and direct put agent to Disconnected */
150- status_Logger .debug ("Ping timeout but host " + agentId + " is in resource state of " + resourceState + ", so no investigation" );
151- _agentMgr .disconnectWithoutInvestigation (agentId , Event .ShutdownRequested );
152- } else {
153- status_Logger .debug ("Ping timeout for host " + agentId + ", do invstigation" );
154- _agentMgr .disconnectWithInvestigation (agentId , Event .PingTimeout );
147+ if (h != null ) {
148+ ResourceState resourceState = h .getResourceState ();
149+ if (resourceState == ResourceState .Disabled || resourceState == ResourceState .Maintenance
150+ || resourceState == ResourceState .ErrorInMaintenance ) {
151+ /*
152+ * Host is in non-operation state, so no
153+ * investigation and direct put agent to
154+ * Disconnected
155+ */
156+ status_Logger .debug ("Ping timeout but host " + agentId + " is in resource state of "
157+ + resourceState + ", so no investigation" );
158+ _agentMgr .disconnectWithoutInvestigation (agentId , Event .ShutdownRequested );
159+ } else {
160+ status_Logger .debug ("Ping timeout for host " + agentId + ", do invstigation" );
161+ _agentMgr .disconnectWithInvestigation (agentId , Event .PingTimeout );
162+ }
155163 }
156164 }
157165
158166 SearchCriteriaService <HostVO , HostVO > sc = SearchCriteria2 .create (HostVO .class );
159167 sc .addAnd (sc .getEntity ().getResourceState (), Op .IN , ResourceState .PrepareForMaintenance , ResourceState .ErrorInMaintenance );
160168 List <HostVO > hosts = sc .list ();
161-
169+
162170 for (HostVO host : hosts ) {
163171 long hostId = host .getId ();
164172 DataCenterVO dcVO = _dcDao .findById (host .getDataCenterId ());
@@ -170,7 +178,7 @@ public void run() {
170178 List <VMInstanceVO > vosMigrating = _vmDao .listVmsMigratingFromHost (hostId );
171179 if (vos .isEmpty () && vosMigrating .isEmpty ()) {
172180 _alertMgr .sendAlert (AlertManager .ALERT_TYPE_HOST , host .getDataCenterId (), host .getPodId (), "Migration Complete for host " + hostDesc , "Host [" + hostDesc + "] is ready for maintenance" );
173- _resourceMgr .resourceStateTransitTo (host , ResourceState .Event .InternalEnterMaintenance , _msId );
181+ _resourceMgr .resourceStateTransitTo (host , ResourceState .Event .InternalEnterMaintenance , _msId );
174182 }
175183 }
176184 }
0 commit comments