Exemple #1
0
        protected override IMutateOperationResult PerformMutate(MutationMode mode, string key, ulong defaultValue, ulong delta, uint expires, ref ulong cas)
        {
            var hashedKey = this.KeyTransformer.Transform(key);
            var node      = this.Pool.Locate(hashedKey);
            var result    = MutateOperationResultFactory.Create();

            if (node != null)
            {
                var command       = this.Pool.OperationFactory.Mutate(mode, hashedKey, defaultValue, delta, expires, cas);
                var commandResult = ExecuteWithRedirect(node, command);

                if (this.PerformanceMonitor != null)
                {
                    this.PerformanceMonitor.Mutate(mode, 1, commandResult.Success);
                }

                result.Cas = cas = command.CasValue;

                if (commandResult.Success)
                {
                    result.Value = command.Result;
                    result.Pass();
                }
                else
                {
                    result.Value = defaultValue;
                    result.Fail("Mutate operation failed, see InnerException or StatusCode for details.");
                }

                return(result);
            }

            if (this.PerformanceMonitor != null)
            {
                this.PerformanceMonitor.Mutate(mode, 1, false);
            }

            result.Value = defaultValue;
            result.Fail(ClientErrors.FAILURE_NODE_NOT_FOUND);
            return(result);
        }
Exemple #2
0
		protected virtual IMutateOperationResult PerformMutate(MutationMode mode, string key, ulong defaultValue, ulong delta, uint expires, ref ulong cas)
		{
			var hashedKey = this.keyTransformer.Transform(key);
			var node = this.pool.Locate(hashedKey);
			var result = MutateOperationResultFactory.Create();

			if (node != null)
			{
				var command = this.pool.OperationFactory.Mutate(mode, hashedKey, defaultValue, delta, expires, cas);
				var commandResult = node.Execute(command);

				result.Cas = cas = command.CasValue;
				result.StatusCode = command.StatusCode;

				if (commandResult.Success)
				{
					if (this.performanceMonitor != null) this.performanceMonitor.Mutate(mode, 1, commandResult.Success);
					result.Value = command.Result;
					result.Pass();
					return result;
				}
				else
				{
					if (this.performanceMonitor != null) this.performanceMonitor.Mutate(mode, 1, false);
					result.InnerResult = commandResult;
					result.Fail("Mutate operation failed, see InnerResult or StatusCode for more details");
				}

			}

			if (this.performanceMonitor != null) this.performanceMonitor.Mutate(mode, 1, false);

			// TODO not sure about the return value when the command fails
			result.Fail("Unable to locate node");
			return result;
		}