コード例 #1
0
        /// <summary>
        /// Parses the string NodeConfig into a list of IPEndPoints for configuration
        /// </summary>
        /// <returns>A list of IPEndPoints for config to use</returns>
        internal List <IPEndPoint> GetEndPointList()
        {
            try
            {
                var endpoints = AddrUtil.HashEndPointList(this.GetNodeConfig());

                lock (nodesLock)
                {
                    var nodesToRemove = new HashSet <IMemcachedNode>();
                    foreach (var node in this.nodes)
                    {
                        if (!endpoints.Contains(node.EndPoint))
                        {
                            nodesToRemove.Add(node);
                        }
                    }
                    foreach (var node in nodesToRemove)
                    {
                        this.nodes.Remove(node);
                    }

                    foreach (var point in endpoints)
                    {
                        if (this.nodes.FirstOrDefault(x => x.EndPoint.Equals(point)) == null)
                        {
                            this.nodes.Add(this.config.nodeFactory.CreateNode(point, this.config.SocketPool));
                        }
                    }
                }

                return(endpoints);
            }
            catch (Exception ex)
            {
                // Error getting the list of endpoints. Most likely this is due to the
                // client being used outside of EC2.
                log.Debug("Error getting endpoints list", ex);
                throw;
            }
        }
コード例 #2
0
        /// <summary>
        /// Parses the string NodeConfig into a list of IPEndPoints for configuration
        /// </summary>
        /// <returns>A list of IPEndPoints for config to use</returns>
        internal List<DnsEndPoint> GetEndPointList()
        {
            try
            {
                var endpoints = AddrUtil.HashEndPointList(GetNodeConfig());

                lock (_nodesLock)
                {
                    var nodesToRemove = new HashSet<IMemcachedNode>();
                    foreach (var node in _nodes)
                    {
                        if (!endpoints.Contains(node.EndPoint))
                            nodesToRemove.Add(node);
                    }
                    foreach (var node in nodesToRemove)
                    {
                        _nodes.Remove(node);
                    }

                    foreach (var point in endpoints)
                    {
                        if (_nodes.FirstOrDefault(x => x.EndPoint.Equals(point)) == null)
                        {
                            _nodes.Add(_config.NodeFactory.CreateNode(point, _config.SocketPool, _config.LoggerFactory));
                        }
                    }
                }

                return endpoints;
            }
            catch (Exception ex)
            {
                // Error getting the list of endpoints. Most likely this is due to the
                // client being used outside of EC2.
                _log.LogError(ex, "Error getting endpoints list");
                throw;
            }
        }