コード例 #1
0
        private IOperationResult ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation op)
        {
            IOperationResult result = startNode.Execute(op);

            if (!result.Success)
            {
                IOperationWithState state = op as IOperationWithState;
                if (state == null)
                {
                    return(result);
                }
                if (state.State != OperationState.InvalidVBucket)
                {
                    return(result);
                }
                foreach (IMemcachedNode node in base.Pool.GetWorkingNodes())
                {
                    result = node.Execute(op);
                    if (result.Success)
                    {
                        return(result);
                    }
                    if (state.State != OperationState.InvalidVBucket)
                    {
                        return(result);
                    }
                }
            }
            return(result);
        }
コード例 #2
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.");
        }
コード例 #3
0
        private bool ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation op)
        {
            if (startNode.Execute(op))
            {
                return(true);
            }

            var iows = op as IOperationWithState;

            // different op factory, we do not know how to retry
            if (iows == null)
            {
                return(false);
            }

#if HAS_FORWARD_MAP
            // node responded with invalid vbucket
            // this should happen only when a node is in a transitioning state
            if (iows.State == OpState.InvalidVBucket)
            {
                // check if we have a forward-locator
                // (whihc supposedly reflects the state of the cluster when all vbuckets have been migrated succesfully)
                IMemcachedNodeLocator fl = this.nsPool.ForwardLocator;
                if (fl != null)
                {
                    var nextNode = fl.Locate(op.Key);
                    if (nextNode != null)
                    {
                        // the node accepted the requesta
                        if (nextNode.Execute(op))
                        {
                            return(true);
                        }
                    }
                }
            }
#endif
            // still invalid vbucket, try all nodes in sequence
            if (iows.State == OperationState.InvalidVBucket)
            {
                var nodes = this.Pool.GetWorkingNodes();

                foreach (var node in nodes)
                {
                    if (node.Execute(op))
                    {
                        return(true);
                    }

                    // the node accepted our request so quit
                    if (iows.State != OperationState.InvalidVBucket)
                    {
                        break;
                    }
                }
            }

            return(false);
        }
コード例 #4
0
        private bool ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation op)
        {
            if (startNode.Execute(op)) return true;

            var iows = op as IOperationWithState;

            // different op factory, we do not know how to retry
            if (iows == null)
                return false;

            #if HAS_FORWARD_MAP
            // node responded with invalid vbucket
            // this should happen only when a node is in a transitioning state
            if (iows.State == OpState.InvalidVBucket)
            {
                // check if we have a forward-locator
                // (whihc supposedly reflects the state of the cluster when all vbuckets have been migrated succesfully)
                IMemcachedNodeLocator fl = this.nsPool.ForwardLocator;
                if (fl != null)
                {
                    var nextNode = fl.Locate(op.Key);
                    if (nextNode != null)
                    {
                        // the node accepted the requesta
                        if (nextNode.Execute(op)) return true;
                    }
                }
            }
            #endif
            // still invalid vbucket, try all nodes in sequence
            if (iows.State == OperationState.InvalidVBucket)
            {
                var nodes = this.Pool.GetWorkingNodes();

                foreach (var node in nodes)
                {
                    if (node.Execute(op))
                        return true;

                    // the node accepted our request so quit
                    if (iows.State != OperationState.InvalidVBucket)
                        break;
                }
            }

            return false;
        }