コード例 #1
0
        /// <summary>
        /// Finds the version of Memcached the Elasticache setup is running on
        /// </summary>
        /// <returns>Version of memcahced running on nodes</returns>
        internal Version GetNodeVersion()
        {
            if (NodeVersion != null)
            {
                return(NodeVersion);
            }

            #if DEBUG // For LocalSimulationTester
            if (!string.IsNullOrEmpty(_node.ToString()) && _node.ToString().Equals("TestingAWSInternal"))
            {
                NodeVersion = new Version("1.4.14");
                return(NodeVersion);
            }
            #endif

            IStatsOperation statCommand = new StatsOperation(null);
            /* var statResult = */ _node.Execute(statCommand);

            if (statCommand.Result != null && statCommand.Result.TryGetValue("version", out var version))
            {
                NodeVersion = new Version(version);
                return(NodeVersion);
            }

            _log.LogError("Could not call stats on Node endpoint");
            throw new CommandNotSupportedException("The node does not have a version in stats.");
        }