/// <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.");
        }
Beispiel #2
0
        /// <summary>
        /// Returns statistics about the servers.
        /// </summary>
        /// <returns></returns>
        public ServerStats Stats()
        {
            using (StatsOperation s = new StatsOperation(this.pool))
            {
                s.Execute();

                return(s.Results);
            }
        }
        /// <summary>
        /// Used to get the number of records of the cache
        /// </summary>
        /// <returns>Current number of records in the cache</returns>
        public int size()
        {
            StatsOperation op = operationsFactory.newStatsOperation();

            transport = transportFactory.getTransport();
            try
            {
            }
            finally
            {
                transportFactory.releaseTransport(transport);
            }
            return(int.Parse(op.executeOperation(this.transport)[ServerStatistics.CURRENT_NR_OF_ENTRIES]));
        }
Beispiel #4
0
        public void executeOperationTest()
        {
            TCPTransport trans = new TCPTransport(System.Net.IPAddress.Loopback, 11222);
            Codec        codec = new Codec();

            byte[] cacheName  = null;
            int    topologyId = 0;

            Flag[]         flags     = null;
            StatsOperation target    = new StatsOperation(codec, cacheName, topologyId, flags);
            Transport      transport = trans;
            string         expected  = "";
            Dictionary <string, string> actual;

            actual = target.executeOperation(transport);
            Assert.AreEqual(expected, actual[ServerStatistics.CURRENT_NR_OF_ENTRIES]);
        }
        /// <summary>
        /// Used to retreive statistical information about the remote cache
        /// </summary>
        /// <returns>Server Statistics</returns>
        public ServerStatistics stats()
        {
            StatsOperation op = operationsFactory.newStatsOperation();

            transport = transportFactory.getTransport();
            try
            {
            }
            finally
            {
                transportFactory.releaseTransport(transport);
            }
            Dictionary <String, String> statsMap = (Dictionary <String, String>)op.executeOperation(this.transport);
            ServerStatistics            stats    = new ServerStatistics();

            for (int i = 0; i < statsMap.Count; i++)
            {
                stats.addStats(statsMap.ElementAt(i).Key, statsMap.ElementAt(i).Value);
            }
            return(stats);
        }