From 36babbfcac0f2d3cab4c8b8eb3c1b2e9a58936ce Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Thu, 30 Aug 2012 17:43:10 -0700 Subject: [PATCH] CS-16213: agent LB - don't process Disconnect event from other management server in cluster, if the recipient is the future owner of the host. The disconnect will be handled during the rebalance host connection process itself. Reviewed-by: Kelven Yang --- .../manager/ClusteredAgentManagerImpl.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index 65ff8f0de6a..df763f38f7a 100755 --- a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -305,6 +305,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust } AgentAttache attache = findAttache(hostId); if (attache != null) { + if (_clusterMgr.isAgentRebalanceEnabled()) { + //don't process disconnect if the host is being rebalanced + HostTransferMapVO transferVO = _hostTransferDao.findById(hostId); + if (transferVO != null) { + if (transferVO.getFutureOwner() == _nodeId && transferVO.getState() == HostTransferState.TransferStarted) { + s_logger.debug("Not processing disconnect event as the host is being connected to " + _nodeId); + return true; + } + } + } handleDisconnect(attache, Event.AgentDisconnected, false, false); } @@ -936,9 +946,24 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust HostVO host = _hostDao.findById(hostId); try { if (s_logger.isDebugEnabled()) { - s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + " as a part of rebalance process"); + s_logger.debug("Disconnecting host " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification"); } - result = loadDirectlyConnectedHost(host, true); + + AgentAttache attache = findAttache(hostId); + if (attache != null) { + result = handleDisconnect(attache, Event.AgentDisconnected, false, false); + } + + if (result) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + " as a part of rebalance process"); + } + result = loadDirectlyConnectedHost(host, true); + } else { + s_logger.warn("Failed to disconnect " + host.getId() + "(" + host.getName() + + " as a part of rebalance process without notification"); + } + } catch (Exception ex) { s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + " as a part of rebalance process due to:", ex); result = false;