/// <summary>
        /// Reads cache entry processor and related data from stream, executes it and returns the result.
        /// </summary>
        /// <param name="inOutStream">Stream.</param>
        /// <param name="grid">Grid.</param>
        /// <returns>CacheEntryProcessor result.</returns>
        private CacheEntryProcessorResultHolder ReadAndRunCacheEntryProcessor(IPortableStream inOutStream,
                                                                              Ignite grid)
        {
            var marsh = grid.Marshaller;

            var key     = marsh.Unmarshal <object>(inOutStream);
            var val     = marsh.Unmarshal <object>(inOutStream);
            var isLocal = inOutStream.ReadBool();

            var holder = isLocal
                ? _handleRegistry.Get <CacheEntryProcessorHolder>(inOutStream.ReadLong(), true)
                : marsh.Unmarshal <CacheEntryProcessorHolder>(inOutStream);

            return(holder.Process(key, val, val != null, grid));
        }
Example #2
0
        /// <summary>
        /// Read dictionary returned by GET_ALL operation.
        /// </summary>
        /// <param name="reader">Reader.</param>
        /// <returns>Dictionary.</returns>
        private static IDictionary <TK, TV> ReadGetAllDictionary(PortableReaderImpl reader)
        {
            IPortableStream stream = reader.Stream;

            if (stream.ReadBool())
            {
                int size = stream.ReadInt();

                IDictionary <TK, TV> res = new Dictionary <TK, TV>(size);

                for (int i = 0; i < size; i++)
                {
                    TK key = reader.ReadObject <TK>();
                    TV val = reader.ReadObject <TV>();

                    res[key] = val;
                }

                return(res);
            }
            return(null);
        }
Example #3
0
        /// <summary>
        /// Reads results of InvokeAll operation.
        /// </summary>
        /// <typeparam name="T">The type of the result.</typeparam>
        /// <param name="inStream">Stream.</param>
        /// <returns>Results of InvokeAll operation.</returns>
        private IDictionary <TK, ICacheEntryProcessorResult <T> > ReadInvokeAllResults <T>(IPortableStream inStream)
        {
            var count = inStream.ReadInt();

            if (count == -1)
            {
                return(null);
            }

            var results = new Dictionary <TK, ICacheEntryProcessorResult <T> >(count);

            for (var i = 0; i < count; i++)
            {
                var key = Unmarshal <TK>(inStream);

                var hasError = inStream.ReadBool();

                results[key] = hasError
                    ? new CacheEntryProcessorResult <T>(ReadException(inStream))
                    : new CacheEntryProcessorResult <T>(Unmarshal <T>(inStream));
            }

            return(results);
        }