Beispiel #1
0
        private ContextControllerConditionNonHA ActivateTermination(
            EventBean triggeringEvent,
            object[] parentPartitionKeys,
            object partitionKey,
            IntSeqKey conditionPath,
            string optionalInitCondAsName)
        {
            ContextControllerConditionCallback callback = new ProxyContextControllerConditionCallback(
                (
                    conditionPathArg,
                    originEndpoint,
                    optionalTriggeringEvent,
                    optionalTriggeringPattern,
                    optionalTriggeringEventPattern,
                    optionalPatternForInclusiveEval) => {
                    var parentPath = conditionPathArg.RemoveFromEnd();
                    var getterKey = factory.GetGetterKey(partitionKey);
                    var removed = keyedSvc.KeyRemove(parentPath, getterKey);
                    if (removed == null) {
                        return;
                    }

                    // remember the terminating event, we don't want it to initiate a new partition
                    lastTerminatingEvent = optionalTriggeringEvent != null
                        ? optionalTriggeringEvent
                        : optionalTriggeringEventPattern;
                    realization.ContextPartitionTerminate(
                        conditionPathArg.RemoveFromEnd(),
                        removed.SubpathOrCPId,
                        this,
                        null,
                        false,
                        null);
                    removed.TerminationCondition.Deactivate();
                });

            var partitionKeys = CollectionUtil.AddValue(parentPartitionKeys, partitionKey);
            var terminationCondition = ContextControllerConditionFactory.GetEndpoint(
                conditionPath,
                partitionKeys,
                factory.keyedSpec.OptionalTermination,
                callback,
                this,
                false);

            ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider = null;
            if (optionalInitCondAsName != null) {
                endConditionMatchEventProvider = new ProxyContextControllerEndConditionMatchEventProvider {
                    ProcPopulateEndConditionFromTrigger = (
                        map,
                        triggeringEventArg) => {
                        ContextControllerKeyedUtil.PopulatePriorMatch(optionalInitCondAsName, map, triggeringEventArg);
                    }
                };
            }

            terminationCondition.Activate(triggeringEvent, endConditionMatchEventProvider);

            return terminationCondition;
        }
Beispiel #2
0
 public bool Activate(
     EventBean optionalTriggeringEvent,
     ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider,
     IDictionary<string, object> optionalTriggeringPattern)
 {
     return false;
 }
Beispiel #3
0
        public bool Activate(
            EventBean optionalTriggeringEvent,
            ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider)
        {
            AgentInstanceContext agentInstanceContext = controller.Realization.AgentInstanceContextCreate;

            FilterHandleCallback filterCallback = new ProxyFilterHandleCallback() {
                ProcMatchFound = (
                    theEvent,
                    allStmtMatches) => FilterMatchFound(theEvent),
                ProcIsSubselect = () => false,
            };

            FilterValueSetParam[][] addendum = ContextManagerUtil.ComputeAddendumNonStmt(
                partitionKeys,
                filter.FilterSpecActivatable,
                controller.Realization);
            filterHandle = new EPStatementHandleCallbackFilter(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                filterCallback);
            FilterValueSetParam[][] filterValueSet = filter.FilterSpecActivatable.GetValueSet(
                null,
                addendum,
                agentInstanceContext,
                agentInstanceContext.StatementContextFilterEvalEnv);
            agentInstanceContext.FilterService.Add(
                filter.FilterSpecActivatable.FilterForEventType,
                filterValueSet,
                filterHandle);
            long filtersVersion = agentInstanceContext.FilterService.FiltersVersion;
            agentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion =
                filtersVersion;

            bool match = false;
            if (optionalTriggeringEvent != null) {
                match = AgentInstanceUtil.EvaluateFilterForStatement(
                    optionalTriggeringEvent,
                    agentInstanceContext,
                    filterHandle);
            }

            return match;
        }
        public bool Activate(
            EventBean optionalTriggeringEvent,
            ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider,
            IDictionary<string, object> optionalTriggeringPattern)
        {
            patternStopCallback?.Stop();

            var agentInstanceContext = controller.Realization.AgentInstanceContextCreate;
            Func<FilterSpecActivatable, FilterValueSetParam[][]> contextAddendumFunction = filter =>
                ContextManagerUtil.ComputeAddendumNonStmt(partitionKeys, filter, controller.Realization);
            var patternAgentInstanceContext = new PatternAgentInstanceContext(
                pattern.PatternContext,
                agentInstanceContext,
                false,
                contextAddendumFunction);
            var rootNode = EvalNodeUtil.MakeRootNodeFromFactory(pattern.Pattern, patternAgentInstanceContext);

            var matchedEventMap = new MatchedEventMapImpl(pattern.PatternContext.MatchedEventMapMeta);
            if (optionalTriggeringEvent != null) {
                endConditionMatchEventProvider?.PopulateEndConditionFromTrigger(
                    matchedEventMap,
                    optionalTriggeringEvent);
            }

            if (optionalTriggeringPattern != null) {
                endConditionMatchEventProvider?.PopulateEndConditionFromTrigger(matchedEventMap, optionalTriggeringPattern);
            }
            
            // capture any callbacks that may occur right after start
            var callback = new ConditionPatternMatchCallback(this);
            patternStopCallback = rootNode.Start(callback, pattern.PatternContext, matchedEventMap, false);
            callback.forwardCalls = true;

            if (callback.IsInvoked) {
                MatchFound(Collections.GetEmptyMap<string, object>(), optionalTriggeringEvent);
            }

            return false;
        }
Beispiel #5
0
        public bool Activate(
            EventBean optionalTriggeringEvent,
            ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider)
        {
            ScheduleHandleCallback scheduleCallback = new ProxyScheduleHandleCallback {
                ProcScheduledTrigger = () => {
                    var inProcAgentInstanceContext = controller.Realization.AgentInstanceContextCreate;
                    inProcAgentInstanceContext.InstrumentationProvider.QContextScheduledEval(
                        inProcAgentInstanceContext.StatementContext.ContextRuntimeDescriptor);

                    scheduleHandle = null; // terminates automatically unless scheduled again
                    inProcAgentInstanceContext.AuditProvider.ScheduleFire(
                        inProcAgentInstanceContext,
                        ScheduleObjectType.context,
                        NAME_AUDITPROVIDER_SCHEDULE);
                    callback.RangeNotification(conditionPath, this, null, null, null, null);

                    inProcAgentInstanceContext.InstrumentationProvider.AContextScheduledEval();
                }
            };
            var agentInstanceContext = controller.Realization.AgentInstanceContextCreate;
            scheduleHandle = new EPStatementHandleCallbackSchedule(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                scheduleCallback);
            long nextScheduledTime = ScheduleComputeHelper.ComputeDeltaNextOccurance(
                Schedule,
                agentInstanceContext.TimeProvider.Time,
                agentInstanceContext.ImportServiceRuntime.TimeZone,
                agentInstanceContext.ImportServiceRuntime.TimeAbacus);
            agentInstanceContext.AuditProvider.ScheduleAdd(
                nextScheduledTime,
                agentInstanceContext,
                scheduleHandle,
                ScheduleObjectType.context,
                NAME_AUDITPROVIDER_SCHEDULE);
            agentInstanceContext.SchedulingService.Add(nextScheduledTime, scheduleHandle, scheduleSlot);
            return false;
        }
        public bool Activate(
            EventBean optionalTriggeringEvent,
            ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider,
            IDictionary<string, object> optionalTriggeringPattern)
        {
            ScheduleHandleCallback scheduleCallback = new ProxyScheduleHandleCallback() {
                ProcScheduledTrigger = () => {
                    AgentInstanceContext agentInstanceContextX = controller.Realization.AgentInstanceContextCreate;
                    agentInstanceContextX.InstrumentationProvider.QContextScheduledEval(
                        agentInstanceContextX.StatementContext.ContextRuntimeDescriptor);

                    scheduleHandle = null; // terminates automatically unless scheduled again
                    agentInstanceContextX.AuditProvider.ScheduleFire(
                        agentInstanceContextX,
                        ScheduleObjectType.context,
                        NAME_AUDITPROVIDER_SCHEDULE);
                    callback.RangeNotification(conditionPath, this, null, null, null, null);

                    agentInstanceContextX.InstrumentationProvider.AContextScheduledEval();
                },
            };
            AgentInstanceContext agentInstanceContext = controller.Realization.AgentInstanceContextCreate;
            scheduleHandle = new EPStatementHandleCallbackSchedule(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                scheduleCallback);
            long timeDelta = timePeriod.TimePeriodCompute.DeltaUseRuntimeTime(
                null,
                agentInstanceContext,
                agentInstanceContext.TimeProvider);
            agentInstanceContext.AuditProvider.ScheduleAdd(
                timeDelta,
                agentInstanceContext,
                scheduleHandle,
                ScheduleObjectType.context,
                NAME_AUDITPROVIDER_SCHEDULE);
            agentInstanceContext.SchedulingService.Add(timeDelta, scheduleHandle, scheduleSlot);
            return false;
        }
Beispiel #7
0
        public bool Activate(
            EventBean optionalTriggeringEvent,
            ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider,
            IDictionary<string, object> optionalTriggeringPattern)
        {
            var agentInstanceContext = controller.Realization.AgentInstanceContextCreate;

            FilterHandleCallback filterCallback = new ProxyFilterHandleCallback() {
                ProcMatchFound = (
                    theEvent,
                    allStmtMatches) => FilterMatchFound(theEvent),
                ProcIsSubselect = () => false,
            };

            filterHandle = new EPStatementHandleCallbackFilter(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                filterCallback);
            var filterValueSet = ComputeFilterValues(agentInstanceContext);
            if (filterValueSet != null) {
                agentInstanceContext.FilterService.Add(
                    filter.FilterSpecActivatable.FilterForEventType,
                    filterValueSet,
                    filterHandle);
                var filtersVersion = agentInstanceContext.FilterService.FiltersVersion;
                agentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion;
            }

            var match = false;
            if (optionalTriggeringEvent != null) {
                match = AgentInstanceUtil.EvaluateFilterForStatement(
                    optionalTriggeringEvent,
                    agentInstanceContext,
                    filterHandle);
            }

            return match;
        }
Beispiel #8
0
 public bool Activate(
     EventBean optionalTriggeringEvent,
     ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider)
 {
     return false;
 }