Amazon.ElastiCacheCluster/DiscoveryNode.cs
/// <summary>
/// Gets the Node configuration from "config get cluster" if it's new or "get AmazonElastiCache:cluster" if it's older than
/// 1.4.14
/// </summary>
/// <returns>A string in the format "hostname1|ip1|port1 hostname2|ip2|port2 ..."</returns>
Gets the Node configuration from "config get cluster" if it's new or "get AmazonElastiCache:cluster" if it's older than
1.4.14
Gets the Node configuration from " config get cluster " if it ' s new or " get AmazonElastiCache : cluster " if it ' s older than 1 . 4 . 14
internal string GetNodeConfig()
        {
            var tries = this.tries;
            var nodeVersion = this.GetNodeVersion();
            var older = new Version("1.4.14");
            var waiting = true;
            string message = "";
            string[] items = null;
            IGetOperation command = nodeVersion.CompareTo(older) < 0 ?
                                        command = new GetOperation("AmazonElastiCache:cluster") :
                                        command = new ConfigGetOperation("cluster");
            while (waiting && tries > 0)
            {
                tries--;
                try
                {
                    lock (nodesLock)
                    {
                        foreach (var node in this.nodes.ToArray())
                        {
                            try
                            {
                                var result = node.Execute(command);
                                if (result.Success)
                                {
                                    var configCommand = command as IConfigOperation;
                                    items = Encoding.UTF8.GetString(configCommand.ConfigResult.Data.Array, configCommand.ConfigResult.Data.Offset, configCommand.ConfigResult.Data.Count).Split('\n');
                                    waiting = false;
                                    break;
                                }
                                else
                                {
                                    message = result.Message;
                                }
                            }
                            catch (Exception ex)
                            {
                                message = ex.Message;
                            }
                        }
                    }
                    if (waiting)
                        System.Threading.Thread.Sleep(this.delay);
                }
                catch (Exception ex)
                {
                    message = ex.Message;
                    System.Threading.Thread.Sleep(this.delay);
                }
            }
            if (waiting)
            {
                throw new TimeoutException(String.Format("Could not get config of version " + this.NodeVersion.ToString() + ". Tries: {0} Delay: {1}. " + message, this.tries, this.delay));
            }
            lock (clusterLock)
            {
                if (this.ClusterVersion < Convert.ToInt32(items[0]))
                    this.ClusterVersion = Convert.ToInt32(items[0]);
            }
            return items[1];
        }
internal string GetNodeConfig ( ) { var tries = this . tries ; var nodeVersion = this . GetNodeVersion ( ) ; var older = new Version ( " " ) ; var waiting = true ; string message = " " ; string [ ] items = null ; IGetOperation command = nodeVersion . CompareTo ( older ) < 0 ? command = new GetOperation ( " " ) : command = new ConfigGetOperation ( " " ) ; while ( waiting && tries > 0 ) { tries -- ; try { lock ( nodesLock ) { foreach ( var node in this . nodes . ToArray ( ) ) { try { var result = node . Execute ( command ) ; if ( result . Success ) { var configCommand = command as IConfigOperation ; items = Encoding . UTF8 . GetString ( configCommand . ConfigResult . Data . Array , configCommand . ConfigResult . Data . Offset , configCommand . ConfigResult . Data . Count ) . Split ( ' \n ' ) ; waiting = false ; break ; } else { message = result . Message ; } } catch ( Exception ex ) { message = ex . Message ; } } } if ( waiting ) System . Threading . Thread . Sleep ( this . delay ) ; } catch ( Exception ex ) { message = ex . Message ; System . Threading . Thread . Sleep ( this . delay ) ; } } if ( waiting ) { throw new TimeoutException ( String . Format ( " " + this . NodeVersion . ToString ( ) + " " + message , this . tries , this . delay ) ) ; } lock ( clusterLock ) { if ( this . ClusterVersion < Convert . ToInt32 ( items [ 0 ] ) ) this . ClusterVersion = Convert . ToInt32 ( items [ 0 ] ) ; } return items [ 1 ] ; }
Gets the Node configuration from "config get cluster" if it's new or "get AmazonElastiCache:cluster" if it's older than
1.4.14
Gets the Node configuration from " config get cluster " if it ' s new or " get AmazonElastiCache : cluster " if it ' s older than 1 . 4 . 14
// This avoids timing out from requesting the config from the endpoint
A string in the format "hostname1|ip1|port1 hostname2|ip2|port2 ..."
A string in the format " hostname1|ip1|port1 hostname2|ip2|port2 ... "