示例#1
0
		protected virtual IConcatOperationResult PerformConcatenate(ConcatenationMode mode, string key, ref ulong cas, ArraySegment<byte> data)
		{
			var hashedKey = this.keyTransformer.Transform(key);
			var node = this.pool.Locate(hashedKey);
			var result = ConcatOperationResultFactory.Create();

			if (node != null)
			{
				var command = this.pool.OperationFactory.Concat(mode, hashedKey, cas, data);
				var commandResult = node.Execute(command);

				if (commandResult.Success)
				{
					result.Cas = cas = command.CasValue;
					result.StatusCode = command.StatusCode;
					if (this.performanceMonitor != null) this.performanceMonitor.Concatenate(mode, 1, true);
					result.Pass();
				}
				else
				{
					result.InnerResult = commandResult;
					result.Fail("Concat operation failed, see InnerResult or StatusCode for details");
				}

				return result;
			}

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

			result.Fail("Unable to locate node");
			return result;
		}
示例#2
0
        protected override IConcatOperationResult PerformConcatenate(ConcatenationMode mode, string key, ref ulong cas, ArraySegment <byte> data)
        {
            var hashedKey = this.KeyTransformer.Transform(key);
            var node      = this.Pool.Locate(hashedKey);
            var result    = ConcatOperationResultFactory.Create();

            if (node != null)
            {
                var command       = this.Pool.OperationFactory.Concat(mode, hashedKey, cas, data);
                var commandResult = this.ExecuteWithRedirect(node, command);

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

                if (!commandResult.Success)
                {
                    result.InnerResult = commandResult;
                    result.Fail("Concat operation failed, see InnerResult or StatusCode for more information");
                    return(result);
                }

                if (this.PerformanceMonitor != null)
                {
                    this.PerformanceMonitor.Concatenate(mode, 1, true);
                }

                result.Pass();
                return(result);
            }

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

            result.Fail(ClientErrors.FAILURE_NODE_NOT_FOUND);
            return(result);
        }