From bc1574709d8bc05da3306d755377afb01fa6dce8 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 0ff3d666856..226cbfa19fa 100755 --- a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -301,6 +301,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); } @@ -932,9 +942,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;