示例#1
0
        public Task RemoveFromClusterAsync(NodeConnectionInfo node)
        {
            if (_currentTopology.Contains(node.Name) == false)
            {
                throw new InvalidOperationException("Node " + node + " was not found in the cluster");
            }

            if (string.Equals(node.Name, Name, StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("You cannot remove the current node from the cluster, step down this node and then remove it from the new leader");
            }

            var requestedTopology = new Topology(
                _currentTopology.TopologyId,
                _currentTopology.AllVotingNodes.Where(x => string.Equals(x.Name, node.Name, StringComparison.OrdinalIgnoreCase) == false),
                _currentTopology.NonVotingNodes.Where(x => string.Equals(x.Name, node.Name, StringComparison.OrdinalIgnoreCase) == false),
                _currentTopology.PromotableNodes.Where(x => string.Equals(x.Name, node.Name, StringComparison.OrdinalIgnoreCase) == false)
                );

            if (_log.IsInfoEnabled)
            {
                _log.Info("RemoveFromClusterAsync, requestedTopology: {0}", requestedTopology);
            }
            return(ModifyTopology(requestedTopology));
        }