You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/11/02 18:34:49 UTC
[3/6] git commit: HandleDisconnect - don't update the DB when the
disconnect event is happening as a part of MS Cluster notification
Reviewed-by: Frank Zhang
HandleDisconnect - don't update the DB when the disconnect event is happening as a part of MS Cluster notification
Reviewed-by: Frank Zhang
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/62607c9a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/62607c9a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/62607c9a
Branch: refs/heads/master
Commit: 62607c9a75337d75f471d97402256d00e406429e
Parents: 36babbf
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Fri Aug 31 14:22:38 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Fri Nov 2 09:59:37 2012 -0700
----------------------------------------------------------------------
.../com/cloud/agent/manager/AgentManagerImpl.java | 23 ++++++++------
.../agent/manager/ClusteredAgentManagerImpl.java | 10 +++---
2 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/62607c9a/server/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
index 62e8acb..892e405 100755
--- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -608,19 +608,19 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
ConnectionException ce = (ConnectionException)e;
if (ce.isSetupError()) {
s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage());
- handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected);
+ handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true);
throw ce;
} else {
s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + e.getMessage());
- handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested);
+ handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true);
return attache;
}
} else if (e instanceof HypervisorVersionChangedException) {
- handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested);
+ handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true);
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
} else {
s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage(), e);
- handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected);
+ handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true);
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
}
}
@@ -634,7 +634,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
// this is tricky part for secondary storage
// make it as disconnected, wait for secondary storage VM to be up
// return the attache instead of null, even it is disconnectede
- handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected);
+ handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true);
}
agentStatusTransitTo(host, Event.Ready, _nodeId);
@@ -836,7 +836,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
return _name;
}
- protected boolean handleDisconnectWithoutInvestigation(AgentAttache attache, Status.Event event) {
+ protected boolean handleDisconnectWithoutInvestigation(AgentAttache attache, Status.Event event, boolean transitState) {
long hostId = attache.getId();
s_logger.info("Host " + hostId + " is disconnecting with event " + event);
@@ -871,8 +871,11 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
s_logger.debug("Deregistering link for " + hostId + " with state " + nextStatus);
}
+ //remove the attache
removeAgent(attache, nextStatus);
- if (host != null) {
+
+ //update the DB
+ if (host != null && transitState) {
disconnectAgent(host, event, _nodeId);
}
@@ -942,7 +945,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
}
}
- handleDisconnectWithoutInvestigation(attache, event);
+ handleDisconnectWithoutInvestigation(attache, event, true);
host = _hostDao.findById(host.getId());
if (host.getStatus() == Status.Alert || host.getStatus() == Status.Down) {
_haMgr.scheduleRestartForVmsOnHost(host, true);
@@ -968,7 +971,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
if (_investigate == true) {
handleDisconnectWithInvestigation(_attache, _event);
} else {
- handleDisconnectWithoutInvestigation(_attache, _event);
+ handleDisconnectWithoutInvestigation(_attache, _event, true);
}
} catch (final Exception e) {
s_logger.error("Exception caught while handling disconnect: ", e);
@@ -1060,7 +1063,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
AgentAttache attache = null;
attache = findAttache(hostId);
if (attache != null) {
- handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected);
+ handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true);
}
return true;
} else if (event == Event.ShutdownRequested) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/62607c9a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index df763f3..78143fd 100755
--- a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -270,7 +270,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
@Override
- protected boolean handleDisconnectWithoutInvestigation(AgentAttache attache, Status.Event event) {
+ protected boolean handleDisconnectWithoutInvestigation(AgentAttache attache, Status.Event event, boolean transitState) {
return handleDisconnect(attache, event, false, true);
}
@@ -282,7 +282,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
protected boolean handleDisconnect(AgentAttache agent, Status.Event event, boolean investigate, boolean broadcast) {
boolean res;
if (!investigate) {
- res = super.handleDisconnectWithoutInvestigation(agent, event);
+ res = super.handleDisconnectWithoutInvestigation(agent, event, true);
} else {
res = super.handleDisconnectWithInvestigation(agent, event);
}
@@ -315,7 +315,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
}
}
- handleDisconnect(attache, Event.AgentDisconnected, false, false);
+ return super.handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, false);
}
return true;
@@ -1027,7 +1027,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
s_logger.debug("Management server " + _nodeId + " failed to rebalance agent " + hostId);
_hostTransferDao.completeAgentTransfer(hostId);
- handleDisconnectWithoutInvestigation(findAttache(hostId), Event.RebalanceFailed);
+ handleDisconnectWithoutInvestigation(findAttache(hostId), Event.RebalanceFailed, true);
} catch (Exception ex) {
s_logger.warn("Failed to reconnect host id=" + hostId + " as a part of failed rebalance task cleanup");
}
@@ -1044,7 +1044,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
synchronized (_agents) {
ClusteredDirectAgentAttache attache = (ClusteredDirectAgentAttache)_agents.get(hostId);
if (attache != null && attache.getQueueSize() == 0 && attache.getNonRecurringListenersSize() == 0) {
- handleDisconnectWithoutInvestigation(attache, Event.StartAgentRebalance);
+ handleDisconnectWithoutInvestigation(attache, Event.StartAgentRebalance, true);
ClusteredAgentAttache forwardAttache = (ClusteredAgentAttache)createAttache(hostId);
if (forwardAttache == null) {
s_logger.warn("Unable to create a forward attache for the host " + hostId + " as a part of rebalance process");