예제 #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.WriteObjectDetached(key);
                writer.WriteObjectDetached(holder);
            },
                                r =>
            {
                if (r == null)
                {
                    return default(TRes);
                }

                var hasError = r.ReadBoolean();

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

                return r.ReadObject <TRes>();
            }));
        }
예제 #2
0
        /** <inheritdoc /> */
        public IDictionary <TK, ICacheEntryProcessorResult <TR> > InvokeAll <TR, TA>(IEnumerable <TK> keys,
                                                                                     ICacheEntryProcessor <TK, TV, TA, TR> processor, TA arg)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            IgniteArgumentCheck.NotNull(processor, "processor");

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

            return(DoOutInOp((int)CacheOp.InvokeAll, writer =>
            {
                WriteEnumerable(writer, keys);
                writer.Write(holder);
            },
                             input =>
            {
                if (IsAsync)
                {
                    _invokeAllConverter.Value = (Func <PortableReaderImpl, IDictionary <TK, ICacheEntryProcessorResult <TR> > >)
                                                    (reader => ReadInvokeAllResults <TR>(reader.Stream));
                }

                return ReadInvokeAllResults <TR>(input);
            }));
        }
예제 #3
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))));
        }
예제 #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(DoOutInOpX((int)CacheOp.Invoke,
                              writer =>
            {
                writer.Write(key);
                writer.Write(holder);
            },
                              (input, res) => res == True ? Unmarshal <TRes>(input) : default(TRes),
                              ReadException));
        }
예제 #5
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)));
        }
예제 #6
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(DoOutInOpX((int)CacheOp.InvokeAll,
                              writer =>
            {
                WriteEnumerable(writer, keys);
                writer.Write(holder);
            },
                              (input, res) => res == True ? ReadInvokeAllResults <TRes>(Marshaller.StartUnmarshal(input, IsKeepBinary)): null, ReadException));
        }
예제 #7
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)));
        }