Amazon.ElastiCacheCluster/DiscoveryNode.cs
/// <summary>
/// Tries to resolve the endpoint ip, used if the connection fails
/// </summary>
/// <returns>The resolved endpoint as an ip and port</returns>
Tries to resolve the endpoint ip, used if the connection fails
Tries to resolve the endpoint ip used if the connection fails
internal IPEndPoint ResolveEndPoint()
        {
            IPHostEntry entry = null;
            var waiting = true;
            var tryCount = this.tries;
            string message = "";
            while (tryCount > 0 && waiting)
            {
                try
                {
                    tryCount--;
                    entry = Dns.GetHostEntry(hostname);
                    if (entry.AddressList.Length > 0)
                    {
                        waiting = false;
                    }
                }
                catch (Exception ex)
                {
                    message = ex.Message;
                    System.Threading.Thread.Sleep(this.delay);
                }
            }
            if (waiting || entry == null)
            {
                log.Error("Could not resolve hostname to ip");
                throw new TimeoutException(String.Format("Could not resolve hostname to Ip after trying the specified amount: {0}. " + message, this.tries));
            }
            log.DebugFormat("Resolved configuration endpoint {0} to {1}.", hostname, entry.AddressList[0]);
            lock (endpointLock)
            {
                this.EndPoint = new IPEndPoint(entry.AddressList[0], port);
            }
            lock (nodesLock)
            {
                if (this.Node != null)
                {
                    try
                    {
                        this.Node.Dispose();
                    }
                    catch { }
                }
                this.Node = this.config.nodeFactory.CreateNode(this.EndPoint, this.config.SocketPool);
                this.nodes.Clear();
                this.nodes.Add(this.Node);
            }
            return this.EndPoint;
        }
internal IPEndPoint ResolveEndPoint ( ) { IPHostEntry entry = null ; var waiting = true ; var tryCount = this . tries ; string message = " " ; while ( tryCount > 0 && waiting ) { try { tryCount -- ; entry = Dns . GetHostEntry ( hostname ) ; if ( entry . AddressList . Length > 0 ) { waiting = false ; } } catch ( Exception ex ) { message = ex . Message ; System . Threading . Thread . Sleep ( this . delay ) ; } } if ( waiting || entry == null ) { log . Error ( " " ) ; throw new TimeoutException ( String . Format ( " " + message , this . tries ) ) ; } log . DebugFormat ( " " , hostname , entry . AddressList [ 0 ] ) ; lock ( endpointLock ) { this . EndPoint = new IPEndPoint ( entry . AddressList [ 0 ] , port ) ; } lock ( nodesLock ) { if ( this . Node != null ) { try { this . Node . Dispose ( ) ; } catch { } } this . Node = this . config . nodeFactory . CreateNode ( this . EndPoint , this . config . SocketPool ) ; this . nodes . Clear ( ) ; this . nodes . Add ( this . Node ) ; } return this . EndPoint ; }
Tries to resolve the endpoint ip, used if the connection fails
Tries to resolve the endpoint ip used if the connection fails
The resolved endpoint as an ip and port
The resolved endpoint as an ip and port