Example #1
0
 public Guard MakeGuard(
     PatternAgentInstanceContext context,
     MatchedEventMap matchedEventMap,
     Quitable quitable,
     EvalStateNodeNumber stateNodeId,
     Object guardState)
 {
     return(new TimerWithinGuard(ComputeTime(matchedEventMap, context), quitable));
 }
Example #2
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="deltaTime">the time deltaTime</param>
 /// <param name="beginState">start state</param>
 /// <param name="observerEventEvaluator">receiver for events</param>
 public TimerIntervalObserver(
     long deltaTime,
     MatchedEventMap beginState,
     ObserverEventEvaluator observerEventEvaluator)
 {
     this.deltaTime = deltaTime;
     BeginState = beginState;
     this.observerEventEvaluator = observerEventEvaluator;
     scheduleSlot = observerEventEvaluator.Context.AgentInstanceContext.ScheduleBucket.AllocateSlot();
 }
 public TimerScheduleSpec Compute(
     MatchedEventConvertor optionalConvertor,
     MatchedEventMap beginState,
     ExprEvaluatorContext exprEvaluatorContext,
     TimeZoneInfo timeZone,
     TimeAbacus timeAbacus)
 {
     EventBean[] eventsPerStream = optionalConvertor == null ? null : optionalConvertor.Invoke(beginState);
     return Compute(date, repetitions, timePeriod, eventsPerStream, exprEvaluatorContext, timeZone, timeAbacus);
 }
Example #4
0
 public TimerScheduleSpec Compute(
     MatchedEventConvertor optionalConvertor,
     MatchedEventMap beginState,
     ExprEvaluatorContext exprEvaluatorContext,
     TimeZoneInfo timeZone,
     TimeAbacus timeAbacus)
 {
     EventBean[] events = optionalConvertor == null ? null : optionalConvertor.Invoke(beginState);
     return Compute(parameter, events, exprEvaluatorContext);
 }
Example #5
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="scheduleSpec">- specification containing the crontab schedule</param>
 /// <param name="beginState">- start state</param>
 /// <param name="observerEventEvaluator">- receiver for events</param>
 public TimerAtObserver(
     ScheduleSpec scheduleSpec,
     MatchedEventMap beginState,
     ObserverEventEvaluator observerEventEvaluator)
 {
     _scheduleSpec           = scheduleSpec;
     _beginState             = beginState;
     _observerEventEvaluator = observerEventEvaluator;
     _scheduleSlot           = observerEventEvaluator.Context.PatternContext.ScheduleBucket.AllocateSlot();
 }
Example #6
0
 public static Object Evaluate(
     string objectName,
     MatchedEventMap beginState,
     ExprNode parameter,
     MatchedEventConvertor convertor,
     ExprEvaluatorContext exprEvaluatorContext)
 {
     EventBean[] eventsPerStream = convertor.Convert(beginState);
     return(Evaluate(objectName, parameter, eventsPerStream, exprEvaluatorContext));
 }
        public object GetFilterValue(
            MatchedEventMap matchedEvents,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            if (exprEvaluatorContext.ContextProperties == null) {
                return null;
            }

            return _getter.Get(exprEvaluatorContext.ContextProperties);
        }
Example #8
0
 public Guard MakeGuard(
     PatternAgentInstanceContext context,
     MatchedEventMap beginState,
     Quitable quitable,
     EvalStateNodeNumber stateNodeId,
     Object guardState)
 {
     return new TimerWithinOrMaxCountGuard(
         ComputeTime(beginState, context), ComputeNumCountTo(beginState, context), quitable);
 }
Example #9
0
 public EventObserver MakeObserver(
     PatternAgentInstanceContext context,
     MatchedEventMap beginState,
     ObserverEventEvaluator observerEventEvaluator,
     EvalStateNodeNumber stateNodeId,
     Object observerState,
     bool isFilterchildNonQuitting)
 {
     return(null);
 }
Example #10
0
        public bool Inspect(MatchedEventMap matchEvent)
        {
            counter++;
            if (counter > numCountTo) {
                quitable.GuardQuit();
                return false;
            }

            return true;
        }
Example #11
0
 public EventObserver MakeObserver(
     PatternAgentInstanceContext context,
     MatchedEventMap beginState,
     ObserverEventEvaluator observerEventEvaluator,
     EvalStateNodeNumber stateNodeId,
     Object observerState,
     bool isFilterChildNonQuitting)
 {
     return(new TimerAtObserver(ComputeSpec(beginState, context), beginState, observerEventEvaluator));
 }
Example #12
0
 public int ComputeNumCountTo(MatchedEventMap beginState, PatternAgentInstanceContext context)
 {
     Object numCountToVal = PatternExpressionUtil.Evaluate(
         "Timer-Within-Or-Max-Count guard", beginState, _numCountToExpr, _convertor, context.AgentInstanceContext);
     if (null == numCountToVal)
     {
         throw new EPException("Timer-within-or-max second parameter evaluated to a null-value");
     }
     return numCountToVal.AsInt();
 }
Example #13
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="scheduleSpec">specification containing the crontab schedule</param>
 /// <param name="beginState">start state</param>
 /// <param name="observerEventEvaluator">receiver for events</param>
 public TimerAtObserver(
     ScheduleSpec scheduleSpec,
     MatchedEventMap beginState,
     ObserverEventEvaluator observerEventEvaluator)
 {
     this.scheduleSpec = scheduleSpec;
     this.beginState = beginState;
     this.observerEventEvaluator = observerEventEvaluator;
     this.scheduleSlot = observerEventEvaluator.Context.AgentInstanceContext.ScheduleBucket.AllocateSlot();
 }
Example #14
0
 public override bool Inspect(MatchedEventMap matchEvent)
 {
     _counter++;
     if (_counter > _numCountTo)
     {
         _quitable.GuardQuit();
         return(false);
     }
     return(true);
 }
Example #15
0
        public override object GetFilterValue(MatchedEventMap matchedEvents, AgentInstanceContext agentInstanceContext)
        {
            if (Lookupable.ReturnType == typeof(String))
            {
                return(new StringRange((String)_min.GetFilterValue(matchedEvents, agentInstanceContext), (String)_max.GetFilterValue(matchedEvents, agentInstanceContext)));
            }
            var begin = (double?)_min.GetFilterValue(matchedEvents, agentInstanceContext);
            var end   = (double?)_max.GetFilterValue(matchedEvents, agentInstanceContext);

            return(new DoubleRange(begin, end));
        }
Example #16
0
        public override Object GetFilterValue(MatchedEventMap matchedEvents, ExprEvaluatorContext evaluatorContext)
        {
            if (Lookupable.ReturnType == typeof(String))
            {
                return(new StringRange((String)_min.GetFilterValue(matchedEvents, evaluatorContext), (String)_max.GetFilterValue(matchedEvents, evaluatorContext)));
            }
            var begin = (double?)_min.GetFilterValue(matchedEvents, evaluatorContext);
            var end   = (double?)_max.GetFilterValue(matchedEvents, evaluatorContext);

            return(new DoubleRange(begin, end));
        }
Example #17
0
 /// <summary>
 /// Evaluate the pattern expression.
 /// </summary>
 /// <param name="objectName">pattern object name</param>
 /// <param name="beginState">pattern state</param>
 /// <param name="timePeriod">The time period.</param>
 /// <param name="convertor">to converting from pattern match to event-per-stream</param>
 /// <param name="exprEvaluatorContext">expression evaluation context</param>
 /// <returns>
 /// evaluation result
 /// </returns>
 /// <throws>EPException if the evaluation failed</throws>
 public static Object EvaluateTimePeriod(String objectName, MatchedEventMap beginState, ExprTimePeriod timePeriod, MatchedEventConvertor convertor, ExprEvaluatorContext exprEvaluatorContext)
 {
     EventBean[] eventsPerStream = convertor.Convert(beginState);
     try {
         return(timePeriod.EvaluateGetTimePeriod(new EvaluateParams(eventsPerStream, true, exprEvaluatorContext)));
     }
     catch (Exception ex)
     {
         throw HandleRuntimeException(ex, objectName);
     }
 }
 public TimerScheduleSpec Compute(MatchedEventConvertor convertor, MatchedEventMap beginState, ExprEvaluatorContext exprEvaluatorContext, TimeZoneInfo timeZone)
 {
     object param = PatternExpressionUtil.Evaluate(
         NAME_OBSERVER, beginState, _parameter, convertor, exprEvaluatorContext);
     var iso = (string) param;
     if (iso == null)
     {
         throw new ScheduleParameterException("Received null parameter value");
     }
     return TimerScheduleISO8601Parser.Parse(iso);
 }
Example #19
0
 public override FilterValueSetParam GetFilterValue(
     MatchedEventMap matchedEvents,
     ExprEvaluatorContext exprEvaluatorContext,
     StatementContextFilterEvalEnv filterEvalEnv)
 {
     var x = XEval.GetFilterValueDouble(matchedEvents, exprEvaluatorContext, filterEvalEnv);
     var y = YEval.GetFilterValueDouble(matchedEvents, exprEvaluatorContext, filterEvalEnv);
     var point = new XYPoint(x, y);
     var lookupable = this.lkupable.Make(matchedEvents, exprEvaluatorContext);
     return new FilterValueSetParamImpl(lookupable, FilterOperator, point);
 }
Example #20
0
 public bool Inspect(MatchedEventMap matchEvent)
 {
     counter++;
     if (counter > numCountTo)
     {
         quitable.GuardQuit();
         DeactivateTimer();
         return(false);
     }
     return(true);
 }
Example #21
0
        public static void PopulatePriorMatch(
            string optionalInitCondAsName,
            MatchedEventMap matchedEventMap,
            EventBean triggeringEvent)
        {
            var tag = matchedEventMap.Meta.GetTagFor(optionalInitCondAsName);
            if (tag == -1) {
                return;
            }

            matchedEventMap.Add(tag, triggeringEvent);
        }
Example #22
0
 public TimerScheduleObserver(
     TimerScheduleSpec spec,
     MatchedEventMap beginState,
     ObserverEventEvaluator observerEventEvaluator,
     bool isFilterChildNonQuitting)
 {
     _beginState             = beginState;
     _observerEventEvaluator = observerEventEvaluator;
     _scheduleSlot           = observerEventEvaluator.Context.PatternContext.ScheduleBucket.AllocateSlot();
     _spec = spec;
     _isFilterChildNonQuitting = isFilterChildNonQuitting;
 }
 public void ObserverEvaluateTrue(MatchedEventMap matchEvent, bool quitted)
 {
     if (InstrumentationHelper.ENABLED)
     {
         InstrumentationHelper.Get().QPatternObserverEvaluateTrue(_evalObserverNode, matchEvent);
     }
     ParentEvaluator.EvaluateTrue(matchEvent, this, quitted);
     if (InstrumentationHelper.ENABLED)
     {
         InstrumentationHelper.Get().APatternObserverEvaluateTrue();
     }
 }
Example #24
0
 public void EvaluateTrue(
     MatchedEventMap matchEvent,
     EvalStateNode fromNode,
     bool isQuitted,
     EventBean optionalTriggeringEvent)
 {
     log.Warn(
         "Event/request processing: Uncontrolled pattern matching of \"every\" operator - infinite loop when using EVERY operator on expression(s) containing a not operator, for statement '" +
         statementName +
         "'");
     IsEvaluatedTrue = true;
 }
Example #25
0
        public double? GetFilterValue(
            MatchedEventMap matchedEvents,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            if (exprEvaluatorContext.ContextProperties == null) {
                return null;
            }

            var @object = _getter.Get(exprEvaluatorContext.ContextProperties);

            return @object?.AsDouble();
        }
Example #26
0
 public TimerScheduleObserver(
     TimerScheduleSpec spec,
     MatchedEventMap beginState,
     ObserverEventEvaluator observerEventEvaluator,
     bool isFilterChildNonQuitting)
 {
     this.beginState = beginState;
     this.observerEventEvaluator = observerEventEvaluator;
     scheduleSlot = observerEventEvaluator.Context.AgentInstanceContext.ScheduleBucket.AllocateSlot();
     this.spec = spec;
     this.isFilterChildNonQuitting = isFilterChildNonQuitting;
 }
Example #27
0
 public override void Start(MatchedEventMap beginState)
 {
     if (InstrumentationHelper.ENABLED)
     {
         InstrumentationHelper.Get().QPatternRootStart(beginState);
     }
     _topStateNode = RootSingleChildNode.NewState(this, null, 0L);
     _topStateNode.Start(beginState);
     if (InstrumentationHelper.ENABLED)
     {
         InstrumentationHelper.Get().APatternRootStart();
     }
 }
Example #28
0
 public override void Start(MatchedEventMap beginState)
 {
     Instrument.With(
         i => i.QPatternFollowedByStart(EvalFollowedByNode, beginState),
         i => i.APatternFollowedByStart(),
         () =>
     {
         EvalNode child           = EvalFollowedByNode.ChildNodes[0];
         EvalStateNode childState = child.NewState(this, null, 0L);
         Nodes.Put(childState, 0);
         childState.Start(beginState);
     });
 }
 public override void Start(MatchedEventMap beginState)
 {
     if (InstrumentationHelper.ENABLED)
     {
         InstrumentationHelper.Get().QPatternObserverStart(_evalObserverNode, beginState);
     }
     _eventObserver = _evalObserverNode.FactoryNode.ObserverFactory.MakeObserver(_evalObserverNode.Context, beginState, this, null, null, ParentEvaluator.IsFilterChildNonQuitting);
     _eventObserver.StartObserve();
     if (InstrumentationHelper.ENABLED)
     {
         InstrumentationHelper.Get().APatternObserverStart();
     }
 }
Example #30
0
        /// <summary>
        /// Returns the values for the filter, using the supplied result events to ask filter parameters
        /// for the value to filter for.
        /// </summary>
        /// <param name="matchedEvents">contains the result events to use for determining filter values</param>
        /// <param name="addendum">context addendum</param>
        /// <param name="exprEvaluatorContext">context</param>
        /// <param name="filterEvalEnv">env</param>
        /// <returns>filter values, or null when negated</returns>
        public FilterValueSetParam[][] GetValueSet(
            MatchedEventMap matchedEvents,
            FilterValueSetParam[][] addendum,
            ExprEvaluatorContext exprEvaluatorContext,
            StatementContextFilterEvalEnv filterEvalEnv)
        {
            var valueList = Plan.EvaluateValueSet(matchedEvents, exprEvaluatorContext, filterEvalEnv);
            if (addendum != null) {
                valueList = FilterAddendumUtil.MultiplyAddendum(addendum, valueList);
            }

            return valueList;
        }