Exemplo n.º 1
0
        /// <summary>
        /// Writes the continuous query.
        /// </summary>
        /// <param name="ctx">Request context.</param>
        /// <param name="continuousQuery">Query.</param>
        private void WriteContinuousQuery(ClientRequestContext ctx, ContinuousQueryClient <TK, TV> continuousQuery)
        {
            var w = ctx.Writer;

            w.WriteInt(continuousQuery.BufferSize);
            w.WriteLong((long)continuousQuery.TimeInterval.TotalMilliseconds);
            w.WriteBoolean(false); // Include expired.

            if (continuousQuery.Filter == null)
            {
                w.WriteObject <object>(null);
            }
            else
            {
                var javaFilter = continuousQuery.Filter as PlatformJavaObjectFactoryProxy;

                if (javaFilter != null)
                {
                    w.WriteObject(javaFilter.GetRawProxy());
                    w.WriteByte(FilterPlatformJava);
                }
                else
                {
                    var filterHolder = new ContinuousQueryFilterHolder(continuousQuery.Filter, _keepBinary);

                    w.WriteObject(filterHolder);
                    w.WriteByte(FilterPlatformDotnet);
                }
            }

            ctx.Socket.ExpectNotifications();
        }
Exemplo n.º 2
0
        private long ContinuousQueryFilterCreate(void *target, long memPtr)
        {
            return(SafeCall(() =>
            {
                // 1. Unmarshal filter holder.
                IPortableStream stream = IgniteManager.Memory.Get(memPtr).Stream();

                var reader = _ignite.Marshaller.StartUnmarshal(stream);

                ContinuousQueryFilterHolder filterHolder = reader.ReadObject <ContinuousQueryFilterHolder>();

                // 2. Create real filter from it's holder.
                Type filterWrapperTyp = typeof(ContinuousQueryFilter <,>)
                                        .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);

                Type filterTyp = typeof(ICacheEntryEventFilter <,>)
                                 .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);

                var filter = (IContinuousQueryFilter)filterWrapperTyp
                             .GetConstructor(new[] { filterTyp, typeof(bool) })
                             .Invoke(new[] { filterHolder.Filter, filterHolder.KeepPortable });

                // 3. Inject grid.
                filter.Inject(_ignite);

                // 4. Allocate GC handle.
                return filter.Allocate();
            }));
        }