Beispiel #1
0
        /** <inheritDoc /> */
        public Task <TRes> InvokeAsync <TArg, TRes>(TK key, ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            IgniteArgumentCheck.NotNull(key, "key");
            IgniteArgumentCheck.NotNull(processor, "processor");

            StartTx();

            var holder = new CacheEntryProcessorHolder(processor, arg,
                                                       (e, a) => processor.Process((IMutableCacheEntry <TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));

            return(DoOutOpAsync(CacheOp.InvokeAsync, writer =>
            {
                writer.Write(key);
                writer.Write(holder);
            },
                                r =>
            {
                if (r == null)
                {
                    return default(TRes);
                }

                var hasError = r.ReadBoolean();

                if (hasError)
                {
                    throw ReadException(r);
                }

                return r.ReadObject <TRes>();
            }));
        }
Beispiel #2
0
        /** <inheritDoc /> */
        public TR Invoke <TR, TA>(TK key, ICacheEntryProcessor <TK, TV, TA, TR> processor, TA arg)
        {
            var result = _cache.Invoke(key, processor, arg);

            SetLastAsyncOp(CacheOp.Invoke);

            return(result);
        }
Beispiel #3
0
        /** <inheritDoc /> */
        public IDictionary <TK, ICacheEntryProcessorResult <TR> > InvokeAll <TR, TA>(IEnumerable <TK> keys,
                                                                                     ICacheEntryProcessor <TK, TV, TA, TR> processor, TA arg)
        {
            var result = _cache.InvokeAll(keys, processor, arg);

            SetLastAsyncOp(CacheOp.InvokeAll);

            return(result);
        }
Beispiel #4
0
        /** <inheritdoc /> */
        public TRes Invoke <TArg, TRes>(TK key, ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            IgniteArgumentCheck.NotNull(processor, "processor");

            var holder = new CacheEntryProcessorHolder(processor, arg,
                                                       (e, a) => processor.Process((IMutableCacheEntry <TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));

            return(DoOutInOp((int)CacheOp.Invoke, writer =>
            {
                writer.Write(key);
                writer.Write(holder);
            },
                             input => GetResultOrThrow <TRes>(Unmarshal <object>(input))));
        }
Beispiel #5
0
        /** <inheritdoc /> */
        public TRes Invoke <TArg, TRes>(TK key, ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            IgniteArgumentCheck.NotNull(processor, "processor");

            var holder = new CacheEntryProcessorHolder(processor, arg,
                                                       (e, a) => processor.Process((IMutableCacheEntry <TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));

            return(DoOutInOpX((int)CacheOp.Invoke,
                              writer =>
            {
                writer.Write(key);
                writer.Write(holder);
            },
                              (input, res) => res == True ? Unmarshal <TRes>(input) : default(TRes),
                              ReadException));
        }
Beispiel #6
0
        /** <inheritDoc /> */
        public Task <TRes> InvokeAsync <TArg, TRes>(TK key, ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            AsyncInstance.Invoke(key, processor, arg);

            return(AsyncInstance.GetTask(CacheOp.Invoke, r =>
            {
                if (r == null)
                {
                    return default(TRes);
                }

                var hasError = r.ReadBoolean();

                if (hasError)
                {
                    throw ReadException(r.Stream);
                }

                return r.ReadObject <TRes>();
            }));
        }
Beispiel #7
0
 /** <inheritDoc /> */
 public TRes Invoke <TArg, TRes>(TK key, ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
 {
     return(_cache.InvokeAsync(key, processor, arg).GetResult());
 }
Beispiel #8
0
        /** <inheritDoc /> */
        public Task <ICollection <ICacheEntryProcessorResult <TK, TRes> > > InvokeAllAsync <TArg, TRes>(IEnumerable <TK> keys,
                                                                                                        ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");
            IgniteArgumentCheck.NotNull(processor, "processor");

            StartTx();

            var holder = new CacheEntryProcessorHolder(processor, arg,
                                                       (e, a) => processor.Process((IMutableCacheEntry <TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));

            return(DoOutOpAsync(CacheOp.InvokeAllAsync,
                                writer =>
            {
                writer.WriteEnumerable(keys);
                writer.Write(holder);
            },
                                input => ReadInvokeAllResults <TRes>(input)));
        }
Beispiel #9
0
        /** <inheritdoc /> */
        public ICollection <ICacheEntryProcessorResult <TK, TRes> > InvokeAll <TArg, TRes>(IEnumerable <TK> keys,
                                                                                           ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");
            IgniteArgumentCheck.NotNull(processor, "processor");

            StartTx();

            var holder = new CacheEntryProcessorHolder(processor, arg,
                                                       (e, a) => processor.Process((IMutableCacheEntry <TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));

            return(DoOutInOpX((int)CacheOp.InvokeAll,
                              writer =>
            {
                writer.WriteEnumerable(keys);
                writer.Write(holder);
            },
                              (input, res) => res == True
                    ? ReadInvokeAllResults <TRes>(Marshaller.StartUnmarshal(input, IsKeepBinary))
                    : null, _readException));
        }
Beispiel #10
0
 /** <inheritDoc /> */
 public IDictionary <TK, ICacheEntryProcessorResult <TRes> > InvokeAll <TArg, TRes>(IEnumerable <TK> keys,
                                                                                    ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
 {
     return(GetResult(_cache.InvokeAllAsync(keys, processor, arg)));
 }
Beispiel #11
0
        /** <inheritDoc /> */
        public Task <IDictionary <TK, ICacheEntryProcessorResult <TRes> > > InvokeAllAsync <TArg, TRes>(IEnumerable <TK> keys,
                                                                                                        ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            AsyncInstance.InvokeAll(keys, processor, arg);

            return(AsyncInstance.GetTask(CacheOp.InvokeAll, reader => ReadInvokeAllResults <TRes>(reader.Stream)));
        }
        /** <inheritDoc /> */
        public TR Invoke <TR, TA>(TK key, ICacheEntryProcessor <TK, TV, TA, TR> processor, TA arg)
        {
            _cache.Invoke(key, processor, arg);

            return(GetResult <TR>());
        }
Beispiel #13
0
 /** <inheritDoc /> */
 public Task <TRes> InvokeAsync <TArg, TRes>(TK key, ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
 {
     return(_cache.InvokeAsync(key, processor, arg));
 }
Beispiel #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamTransformer{K, V, A, R}"/> class.
        /// </summary>
        /// <param name="proc">Entry processor.</param>
        public StreamTransformer(ICacheEntryProcessor <TK, TV, TArg, TRes> proc)
        {
            IgniteArgumentCheck.NotNull(proc, "proc");

            _proc = proc;
        }
 public Task <ICollection <ICacheEntryProcessorResult <int, TRes> > > InvokeAllAsync <TArg, TRes>(IEnumerable <int> keys, ICacheEntryProcessor <int, int, TArg, TRes> processor, TArg arg)
 {
     throw new NotImplementedException();
 }
 public Task <TRes> InvokeAsync <TArg, TRes>(int key, ICacheEntryProcessor <int, int, TArg, TRes> processor, TArg arg)
 {
     throw new NotImplementedException();
 }
 public IDictionary <int, ICacheEntryProcessorResult <TRes> > InvokeAll <TArg, TRes>(IEnumerable <int> keys, ICacheEntryProcessor <int, int, TArg, TRes> processor, TArg arg)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 /** <inheritDoc /> */
 public Task <ICollection <ICacheEntryProcessorResult <TK, TRes> > > InvokeAllAsync <TArg, TRes>(IEnumerable <TK> keys, ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
 {
     return(_cache.InvokeAllAsync(keys, processor, arg));
 }
Beispiel #19
0
        /** <inheritdoc /> */
        public IDictionary <TK, ICacheEntryProcessorResult <TRes> > InvokeAll <TArg, TRes>(IEnumerable <TK> keys,
                                                                                           ICacheEntryProcessor <TK, TV, TArg, TRes> processor, TArg arg)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            IgniteArgumentCheck.NotNull(processor, "processor");

            var holder = new CacheEntryProcessorHolder(processor, arg,
                                                       (e, a) => processor.Process((IMutableCacheEntry <TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));

            return(DoOutInOp((int)CacheOp.InvokeAll,
                             writer =>
            {
                WriteEnumerable(writer, keys);
                writer.Write(holder);
            },
                             input => ReadInvokeAllResults <TRes>(input)));
        }