コード例 #1
0
        private Object[] ObtainValues(EventBean[] eventsPerStream, InternalEventRouterEntry entry, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QUpdateIStreamApplyAssignments(entry);
            }

            Object[] values = new Object[entry.Assignments.Length];
            for (int i = 0; i < entry.Assignments.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QUpdateIStreamApplyAssignmentItem(i);
                }
                Object value = entry.Assignments[i].Evaluate(new EvaluateParams(eventsPerStream, true, exprEvaluatorContext));
                if ((value != null) && (entry.Wideners[i] != null))
                {
                    value = entry.Wideners[i].Invoke(value);
                }
                values[i] = value;
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AUpdateIStreamApplyAssignmentItem(value);
                }
            }
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AUpdateIStreamApplyAssignments(values);
            }
            return(values);
        }
コード例 #2
0
        private void Apply(EventBean theEvent, EventBean[] eventsPerStream, InternalEventRouterEntry entry, ExprEvaluatorContext exprEvaluatorContext)
        {
            // evaluate
            Object[] values;
            if (entry.HasSubselect)
            {
                using (entry.AgentInstanceLock.AcquireWriteLock()) {
                    values = ObtainValues(eventsPerStream, entry, exprEvaluatorContext);
                }
            }
            else
            {
                values = ObtainValues(eventsPerStream, entry, exprEvaluatorContext);
            }

            // apply
            entry.Writer.Write(values, theEvent);
        }
コード例 #3
0
        /// <summary>
        /// Pre-proces the event.
        /// </summary>
        /// <param name="theEvent">to pre-process</param>
        /// <param name="exprEvaluatorContext">expression evaluation context</param>
        /// <returns>
        /// processed event
        /// </returns>
        public EventBean Process(EventBean theEvent, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (_empty)
            {
                return(theEvent);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QUpdateIStream(_entries);
            }

            EventBean oldEvent        = theEvent;
            bool      haveCloned      = false;
            var       eventsPerStream = new EventBean[1];

            eventsPerStream[0] = theEvent;
            InternalEventRouterEntry lastEntry = null;

            for (int i = 0; i < _entries.Length; i++)
            {
                InternalEventRouterEntry entry = _entries[i];
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QUpdateIStreamApply(i, entry);
                }

                ExprEvaluator whereClause = entry.OptionalWhereClause;
                if (whereClause != null)
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QUpdateIStreamApplyWhere();
                    }

                    var result = whereClause.Evaluate(new EvaluateParams(eventsPerStream, true, exprEvaluatorContext));
                    if ((result == null) || (false.Equals(result)))
                    {
                        if (InstrumentationHelper.ENABLED)
                        {
                            InstrumentationHelper.Get().AUpdateIStreamApplyWhere((bool?)result);
                        }
                        if (InstrumentationHelper.ENABLED)
                        {
                            InstrumentationHelper.Get().AUpdateIStreamApply(null, false);
                        }

                        continue;
                    }
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AUpdateIStreamApplyWhere(true);
                    }
                }

                if (entry.IsDrop)
                {
                    return(null);
                }

                // before applying the changes, indicate to last-entries output view
                if (lastEntry != null)
                {
                    InternalRoutePreprocessView view = lastEntry.OutputView;
                    if (view.IsIndicate)
                    {
                        EventBean copied = _copyMethod.Copy(theEvent);
                        view.Indicate(copied, oldEvent);
                        oldEvent = copied;
                    }
                    else
                    {
                        if (_entries[i].OutputView.IsIndicate)
                        {
                            oldEvent = _copyMethod.Copy(theEvent);
                        }
                    }
                }

                // copy event for the first Update that applies
                if (!haveCloned)
                {
                    EventBean copiedEvent = _copyMethod.Copy(theEvent);
                    if (copiedEvent == null)
                    {
                        Log.Warn("Event of type " + theEvent.EventType.Name + " could not be copied");
                        if (InstrumentationHelper.ENABLED)
                        {
                            InstrumentationHelper.Get().AUpdateIStreamApply(null, false);
                        }
                        return(null);
                    }
                    haveCloned         = true;
                    eventsPerStream[0] = copiedEvent;
                    theEvent           = copiedEvent;
                }

                Apply(theEvent, eventsPerStream, entry, exprEvaluatorContext);
                lastEntry = entry;
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AUpdateIStreamApply(theEvent, true);
                }
            }

            if (lastEntry != null)
            {
                InternalRoutePreprocessView view = lastEntry.OutputView;
                if (view.IsIndicate)
                {
                    view.Indicate(theEvent, oldEvent);
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AUpdateIStream(theEvent, haveCloned);
            }
            return(theEvent);
        }