Schedule HA is a part of handleDisconnect, not removeAgent

Reviewed-by: Alex Huang
This commit is contained in:
Alena Prokharchyk 2012-01-31 10:23:58 -08:00
parent ae31f362db
commit 57cc61396d
2 changed files with 12 additions and 14 deletions

View File

@ -921,7 +921,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
}
}
public void removeAgent(AgentAttache attache, Status nextState, Event event, Boolean investigate) {
public void removeAgent(AgentAttache attache, Status nextState) {
if (attache == null) {
return;
}
@ -946,13 +946,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
removed.disconnect(nextState);
}
HostVO host = _hostDao.findById(hostId);
if (event != null && investigate != null) {
if (!event.equals(Event.PrepareUnmanaged) && !event.equals(Event.HypervisorVersionChanged) && (host.getStatus() == Status.Alert || host.getStatus() == Status.Down)) {
_haMgr.scheduleRestartForVmsOnHost(host, investigate);
}
}
for (Pair<Integer, Listener> monitor : _hostMonitors) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Sending Disconnect to listener: " + monitor.second().getClass().getName());
@ -1012,7 +1005,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
HostVO host = _hostDao.findById(hostId);
if (host == null) {
s_logger.warn("Can't find host with " + hostId);
removeAgent(attache, Status.Removed, event, investigate);
removeAgent(attache, Status.Removed);
return true;
}
@ -1022,7 +1015,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
s_logger.debug("Host " + hostId + " is already " + currentState);
}
if (currentState != Status.PrepareForMaintenance) {
removeAgent(attache, currentState, event, investigate);
removeAgent(attache, currentState);
}
return true;
}
@ -1110,8 +1103,13 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Deregistering link for " + hostId + " with state " + nextState);
}
removeAgent(attache, nextState);
_hostDao.disconnect(host, event, _nodeId);
removeAgent(attache, nextState, event, investigate);
if (!event.equals(Event.PrepareUnmanaged) && !event.equals(Event.HypervisorVersionChanged) && (host.getStatus() == Status.Alert || host.getStatus() == Status.Down)) {
_haMgr.scheduleRestartForVmsOnHost(host, investigate);
}
return true;
}

View File

@ -169,7 +169,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
if (s_logger.isInfoEnabled()) {
s_logger.info(host + " is detected down, but we have a forward attache running, disconnect this one before launching the host");
}
removeAgent(agentattache, Status.Disconnected, null, null);
removeAgent(agentattache, Status.Disconnected);
} else {
continue;
}
@ -709,12 +709,12 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
@Override
public void removeAgent(AgentAttache attache, Status nextState, Event event, Boolean investigate) {
public void removeAgent(AgentAttache attache, Status nextState) {
if (attache == null) {
return;
}
super.removeAgent(attache, nextState, event, investigate);
super.removeAgent(attache, nextState);
}
@Override