private void ScheduleCallback()
        {
            isCallbackScheduled = true;

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
                ProcScheduledTrigger = () => {
                    agentInstanceContext.InstrumentationProvider.QOutputRateConditionScheduledEval();
                    agentInstanceContext.AuditProvider.ScheduleFire(
                        agentInstanceContext,
                        ScheduleObjectType.outputratelimiting,
                        NAME_AUDITPROVIDER_SCHEDULE);
                    isCallbackScheduled = false;
                    outputCallback.Invoke(true, true);
                    ResetBuiltinProperties();
                    agentInstanceContext.InstrumentationProvider.AOutputRateConditionScheduledEval();
                }
            };
            scheduleHandle = new EPStatementHandleCallbackSchedule(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                callback);
            agentInstanceContext.AuditProvider.ScheduleAdd(
                0,
                agentInstanceContext,
                scheduleHandle,
                ScheduleObjectType.outputratelimiting,
                NAME_AUDITPROVIDER_SCHEDULE);
            agentInstanceContext.StatementContext.SchedulingService.Add(0, scheduleHandle, scheduleSlot);

            // execute assignments
            ExecuteThenAssignments();
        }
Beispiel #2
0
        public TimeAccumViewRStream(
            TimeAccumViewFactory timeBatchViewFactory,
            AgentInstanceViewFactoryChainContext agentInstanceContext,
            TimePeriodProvide timePeriodProvide)
        {
            _agentInstanceContext = agentInstanceContext.AgentInstanceContext;
            _factory = timeBatchViewFactory;
            _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
            _timePeriodProvide = timePeriodProvide;

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback() {
                ProcScheduledTrigger = () => {
                    agentInstanceContext.AuditProvider.ScheduleFire(
                        agentInstanceContext.AgentInstanceContext,
                        ScheduleObjectType.view,
                        _factory.ViewName);
                    agentInstanceContext.InstrumentationProvider.QViewScheduledEval(_factory);
                    SendRemoveStream();
                    agentInstanceContext.InstrumentationProvider.AViewScheduledEval();
                },
            };
            _handle = new EPStatementHandleCallbackSchedule(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                callback);
        }
Beispiel #3
0
        public void Put(
            object methodParams,
            EventTable[] rows)
        {
            var schedulingService = agentInstanceContext.SchedulingService;
            var timeAbacus = agentInstanceContext.ImportServiceRuntime.TimeAbacus;

            var key = methodParams;
            var now = schedulingService.Time;
            var item = new Item(rows, now);
            cache.Put(key, item);

            if (!isScheduled) {
                var callback = new EPStatementHandleCallbackSchedule(
                    agentInstanceContext.EpStatementAgentInstanceHandle,
                    this);
                var timeDelta = timeAbacus.DeltaForSecondsDouble(PurgeIntervalSec);
                agentInstanceContext.AuditProvider.ScheduleAdd(
                    timeDelta,
                    agentInstanceContext,
                    callback,
                    ScheduleObjectType.historicaldatacache,
                    NAME_AUDITPROVIDER_SCHEDULE);
                schedulingService.Add(timeDelta, callback, scheduleSlot);
                isScheduled = true;
            }
        }
Beispiel #4
0
        public TimeAccumView(
            TimeAccumViewFactory timeBatchViewFactory,
            AgentInstanceViewFactoryChainContext agentInstanceContext,
            ViewUpdatedCollection viewUpdatedCollection,
            TimePeriodProvide timePeriodProvide)
        {
            this.agentInstanceContext = agentInstanceContext.AgentInstanceContext;
            factory = timeBatchViewFactory;
            this.viewUpdatedCollection = viewUpdatedCollection;
            scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
            this.timePeriodProvide = timePeriodProvide;

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
                ProcScheduledTrigger = () => {
                    agentInstanceContext.AuditProvider.ScheduleFire(
                        agentInstanceContext.AgentInstanceContext,
                        ScheduleObjectType.view,
                        factory.ViewName);
                    agentInstanceContext.InstrumentationProvider.QViewScheduledEval(factory);
                    SendRemoveStream();
                    agentInstanceContext.InstrumentationProvider.AViewScheduledEval();
                }
            };
            handle = new EPStatementHandleCallbackSchedule(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                callback);
        }
Beispiel #5
0
        public void StartObserve()
        {
            if (isTimerActive) {
                throw new IllegalStateException("Timer already active");
            }

            if (deltaTime <= 0) {
                observerEventEvaluator.ObserverEvaluateTrue(BeginState, true);
            }
            else {
                var agentInstanceContext = observerEventEvaluator.Context.AgentInstanceContext;
                scheduleHandle = new EPStatementHandleCallbackSchedule(
                    agentInstanceContext.EpStatementAgentInstanceHandle,
                    this);
                agentInstanceContext.AuditProvider.ScheduleAdd(
                    deltaTime,
                    agentInstanceContext,
                    scheduleHandle,
                    ScheduleObjectType.pattern,
                    NAME_AUDITPROVIDER_SCHEDULE);
                observerEventEvaluator.Context.StatementContext.SchedulingService.Add(
                    deltaTime,
                    scheduleHandle,
                    scheduleSlot);
                isTimerActive = true;
            }
        }
Beispiel #6
0
        private void ScheduleCallback()
        {
            var current = _agentInstanceContext.StatementContext.SchedulingService.Time;
            TimePeriodDeltaResult deltaWReference = _timePeriodProvide.DeltaAddWReference(
                current,
                _currentReferencePoint.Value,
                null,
                true,
                _agentInstanceContext);
            long afterTime = deltaWReference.Delta;
            _currentReferencePoint = deltaWReference.LastReference;

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
                ProcScheduledTrigger = () => {
                    _agentInstanceContext.AuditProvider.ScheduleFire(
                        _agentInstanceContext,
                        ScheduleObjectType.view,
                        _factory.ViewName);
                    _agentInstanceContext.InstrumentationProvider.QViewScheduledEval(_factory);
                    SendBatch();
                    _agentInstanceContext.InstrumentationProvider.AViewScheduledEval();
                }
            };
            _handle = new EPStatementHandleCallbackSchedule(
                _agentInstanceContext.EpStatementAgentInstanceHandle,
                callback);
            _agentInstanceContext.AuditProvider.ScheduleAdd(
                afterTime,
                _agentInstanceContext,
                _handle,
                ScheduleObjectType.view,
                _factory.ViewName);
            _agentInstanceContext.StatementContext.SchedulingService.Add(afterTime, _handle, _scheduleSlot);
        }
        private void ScheduleCallback()
        {
            isCallbackScheduled = true;

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
                ProcScheduledTrigger = () => {
                    context.InstrumentationProvider.QOutputRateConditionScheduledEval();
                    context.AuditProvider.ScheduleFire(
                        context,
                        ScheduleObjectType.outputratelimiting,
                        NAME_AUDITPROVIDER_SCHEDULE);
                    isCallbackScheduled = false;
                    outputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE);
                    ScheduleCallback();
                    context.InstrumentationProvider.AOutputRateConditionScheduledEval();
                }
            };
            var handle = new EPStatementHandleCallbackSchedule(context.EpStatementAgentInstanceHandle, callback);
            var schedulingService = context.StatementContext.SchedulingService;
            var classpathImportService = context.StatementContext.ImportServiceRuntime;
            long nextScheduledTime = ScheduleComputeHelper.ComputeDeltaNextOccurance(
                scheduleSpec,
                schedulingService.Time,
                classpathImportService.TimeZone,
                classpathImportService.TimeAbacus);
            context.AuditProvider.ScheduleAdd(
                nextScheduledTime,
                context,
                handle,
                ScheduleObjectType.outputratelimiting,
                NAME_AUDITPROVIDER_SCHEDULE);
            schedulingService.Add(nextScheduledTime, handle, scheduleSlot);
        }
Beispiel #8
0
        public TimeOrderView(
            AgentInstanceViewFactoryChainContext agentInstanceContext,
            TimeOrderViewFactory factory,
            IStreamSortRankRandomAccess optionalSortedRandomAccess,
            TimePeriodProvide timePeriodProvide)
        {
            this.agentInstanceContext = agentInstanceContext.AgentInstanceContext;
            this.factory = factory;
            this.optionalSortedRandomAccess = optionalSortedRandomAccess;
            scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
            this.timePeriodProvide = timePeriodProvide;

            sortedEvents = new OrderedListDictionary<object, object>();

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
                ProcScheduledTrigger = () => {
                    agentInstanceContext.AuditProvider.ScheduleFire(
                        agentInstanceContext.AgentInstanceContext,
                        ScheduleObjectType.view,
                        factory.ViewName);
                    agentInstanceContext.InstrumentationProvider.QViewScheduledEval(factory);
                    Expire();
                    agentInstanceContext.InstrumentationProvider.AViewScheduledEval();
                }
            };
            handle = new EPStatementHandleCallbackSchedule(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                callback);
        }
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="services">runtime services</param>
 /// <param name="runtime">runtime to process</param>
 /// <param name="handleCallback">callback</param>
 public TimerUnitSingleStaged(
     StageSpecificServices services,
     EPStageEventServiceImpl runtime,
     EPStatementHandleCallbackSchedule handleCallback)
 {
     this.services = services;
     this.runtime = runtime;
     this.handleCallback = handleCallback;
 }
Beispiel #10
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="services">runtime services</param>
 /// <param name="runtime">runtime to process</param>
 /// <param name="handleCallback">callback</param>
 public TimerUnitSingle(
     EPServicesContext services,
     EPEventServiceImpl runtime,
     EPStatementHandleCallbackSchedule handleCallback)
 {
     this.services = services;
     this.runtime = runtime;
     this.handleCallback = handleCallback;
 }
 public override void StopOutputCondition()
 {
     if (scheduleHandle != null) {
         agentInstanceContext.AuditProvider.ScheduleRemove(
             agentInstanceContext,
             scheduleHandle,
             ScheduleObjectType.outputratelimiting,
             NAME_AUDITPROVIDER_SCHEDULE);
         agentInstanceContext.StatementContext.SchedulingService.Remove(scheduleHandle, scheduleSlot);
         scheduleHandle = null;
     }
 }
Beispiel #12
0
        public void Deactivate()
        {
            if (scheduleHandle != null) {
                var agentInstanceContext = controller.Realization.AgentInstanceContextCreate;
                agentInstanceContext.AuditProvider.ScheduleRemove(
                    agentInstanceContext,
                    scheduleHandle,
                    ScheduleObjectType.context,
                    NAME_AUDITPROVIDER_SCHEDULE);
                agentInstanceContext.SchedulingService.Remove(scheduleHandle, scheduleSlot);
            }

            scheduleHandle = null;
        }
Beispiel #13
0
 public void StopObserve()
 {
     if (isTimerActive) {
         var agentInstanceContext = observerEventEvaluator.Context.AgentInstanceContext;
         agentInstanceContext.AuditProvider.ScheduleRemove(
             agentInstanceContext,
             scheduleHandle,
             ScheduleObjectType.pattern,
             NAME_AUDITPROVIDER_SCHEDULE);
         agentInstanceContext.SchedulingService.Remove(scheduleHandle, scheduleSlot);
         isTimerActive = false;
         scheduleHandle = null;
     }
 }
Beispiel #14
0
 public void StopGuard()
 {
     if (isTimerActive) {
         var agentInstanceContext = quitable.Context.AgentInstanceContext;
         agentInstanceContext.AuditProvider.ScheduleRemove(
             agentInstanceContext,
             scheduleHandle,
             ScheduleObjectType.pattern,
             NAME_AUDITPROVIDER_SCHEDULE);
         agentInstanceContext.SchedulingService.Remove(scheduleHandle, scheduleSlot);
         scheduleHandle = null;
         isTimerActive = false;
     }
 }
        private void DeactivateTimer()
        {
            if (scheduleHandle != null) {
                var agentInstanceContext = quitable.Context.AgentInstanceContext;
                agentInstanceContext.AuditProvider.ScheduleRemove(
                    agentInstanceContext,
                    scheduleHandle,
                    ScheduleObjectType.pattern,
                    NAME_AUDITPROVIDER_SCHEDULE);
                agentInstanceContext.SchedulingService.Remove(scheduleHandle, scheduleSlot);
            }

            scheduleHandle = null;
            isTimerActive = false;
        }
Beispiel #16
0
        private void ScheduleCallback()
        {
            isCallbackScheduled = true;
            long current = context.StatementContext.SchedulingService.Time;
            TimePeriodDeltaResult delta = parent.TimePeriodCompute.DeltaAddWReference(
                current,
                currentReferencePoint.Value,
                null,
                true,
                context);
            long deltaTime = delta.Delta;
            currentReferencePoint = delta.LastReference;
            currentScheduledTime = deltaTime;

            if ((ExecutionPathDebugLog.IsDebugEnabled) && (log.IsDebugEnabled)) {
                log.Debug(
                    ".scheduleCallback Scheduled new callback for " +
                    " afterMsec=" +
                    deltaTime +
                    " now=" +
                    current +
                    " currentReferencePoint=" +
                    currentReferencePoint);
            }

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback() {
                ProcScheduledTrigger = () => {
                    context.InstrumentationProvider.QOutputRateConditionScheduledEval();
                    context.AuditProvider.ScheduleFire(
                        context,
                        ScheduleObjectType.outputratelimiting,
                        NAME_AUDITPROVIDER_SCHEDULE);
                    this.isCallbackScheduled = false;
                    this.outputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE);
                    ScheduleCallback();
                    context.InstrumentationProvider.AOutputRateConditionScheduledEval();
                },
            };
            handle = new EPStatementHandleCallbackSchedule(context.EpStatementAgentInstanceHandle, callback);
            context.AuditProvider.ScheduleAdd(
                deltaTime,
                context,
                handle,
                ScheduleObjectType.outputratelimiting,
                NAME_AUDITPROVIDER_SCHEDULE);
            context.StatementContext.SchedulingService.Add(deltaTime, handle, scheduleSlot);
        }
Beispiel #17
0
        public void StartGuard()
        {
            if (isTimerActive) {
                throw new IllegalStateException("Timer already active");
            }

            // Start the stopwatch timer
            scheduleHandle = new EPStatementHandleCallbackSchedule(
                quitable.Context.AgentInstanceContext.EpStatementAgentInstanceHandle,
                this);
            var agentInstanceContext = quitable.Context.AgentInstanceContext;
            agentInstanceContext.AuditProvider.ScheduleAdd(
                deltaTime,
                agentInstanceContext,
                scheduleHandle,
                ScheduleObjectType.pattern,
                NAME_AUDITPROVIDER_SCHEDULE);
            agentInstanceContext.SchedulingService.Add(deltaTime, scheduleHandle, scheduleSlot);
            isTimerActive = true;
        }
Beispiel #18
0
        /// <summary>
        /// Processing single schedule matche for a statement.
        /// </summary>
        /// <param name="handle">statement handle</param>
        /// <param name="services">runtime services</param>
        public static void ProcessStatementScheduleSingle(
            EPStatementHandleCallbackSchedule handle,
            EPServicesEvaluation services)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QTimeCP(handle.AgentInstanceHandle, services.SchedulingService.Time);
            }

            var statementLock = handle.AgentInstanceHandle.StatementAgentInstanceLock;

            statementLock.AcquireWriteLock();
            try {
                if (!handle.AgentInstanceHandle.IsDestroyed)
                {
                    if (handle.AgentInstanceHandle.HasVariables)
                    {
                        services.VariableManagementService.SetLocalVersion();
                    }

                    handle.ScheduleCallback.ScheduledTrigger();
                    handle.AgentInstanceHandle.InternalDispatch();
                }
            }
            catch (Exception ex) {
                services.ExceptionHandlingService.HandleException(ex, handle.AgentInstanceHandle, ExceptionHandlerExceptionType.PROCESS, null);
            }
            finally {
                if (handle.AgentInstanceHandle.HasTableAccess)
                {
                    services.TableExprEvaluatorContext.ReleaseAcquiredLocks();
                }

                handle.AgentInstanceHandle.StatementAgentInstanceLock.ReleaseWriteLock();

                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().ATimeCP();
                }
            }
        }
Beispiel #19
0
        public void StartObserve()
        {
            if (isTimerActive) {
                throw new IllegalStateException("Timer already active");
            }

            var agentInstanceContext = observerEventEvaluator.Context.AgentInstanceContext;
            var schedulingService = agentInstanceContext.SchedulingService;
            var timeAbacus = agentInstanceContext.ImportServiceRuntime.TimeAbacus;

            if (anchorTime == null) {
                if (spec.OptionalDate == null) {
                    anchorTime = DateTimeEx.GetInstance(
                        observerEventEvaluator.Context.StatementContext.ImportServiceRuntime.TimeZone);
                    anchorRemainder = timeAbacus.DateTimeSet(schedulingService.Time, anchorTime);
                }
                else {
                    anchorTime = spec.OptionalDate;
                    anchorRemainder = spec.OptionalRemainder.GetValueOrDefault(0);
                }
            }

            var nextScheduledTime = ComputeNextSetLastScheduled(schedulingService.Time, timeAbacus);
            if (nextScheduledTime == -1) {
                StopObserve();
                observerEventEvaluator.ObserverEvaluateFalse(false);
                return;
            }

            scheduleHandle = new EPStatementHandleCallbackSchedule(
                observerEventEvaluator.Context.AgentInstanceContext.EpStatementAgentInstanceHandle,
                this);
            agentInstanceContext.AuditProvider.ScheduleAdd(
                nextScheduledTime,
                agentInstanceContext,
                scheduleHandle,
                ScheduleObjectType.context,
                NAME_AUDITPROVIDER_SCHEDULE);
            schedulingService.Add(nextScheduledTime, scheduleHandle, scheduleSlot);
            isTimerActive = true;
        }
Beispiel #20
0
 protected void ScheduleCallback(long delta)
 {
     ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
         ProcScheduledTrigger = () => {
             agentInstanceContext.AuditProvider.ScheduleFire(
                 agentInstanceContext,
                 ScheduleObjectType.view,
                 factory.ViewName);
             agentInstanceContext.InstrumentationProvider.QViewScheduledEval(factory);
             SendBatch(true);
             agentInstanceContext.InstrumentationProvider.AViewScheduledEval();
         }
     };
     handle = new EPStatementHandleCallbackSchedule(
         agentInstanceContext.EpStatementAgentInstanceHandle,
         callback);
     var currentTime = agentInstanceContext.StatementContext.SchedulingService.Time;
     var scheduled = timePeriodProvide.DeltaAdd(currentTime, null, true, agentInstanceContext) - delta;
     agentInstanceContext.StatementContext.SchedulingService.Add(scheduled, handle, scheduleSlot);
     callbackScheduledTime = agentInstanceContext.StatementContext.SchedulingService.Time + scheduled;
 }
 public void SetScheduleCallback(
     AgentInstanceContext agentInstanceContext,
     RowRecogNFAViewScheduleCallback scheduleCallback)
 {
     this.agentInstanceContext = agentInstanceContext;
     scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
     ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
         ProcScheduledTrigger = () => {
             agentInstanceContext.AuditProvider.ScheduleFire(
                 agentInstanceContext,
                 ScheduleObjectType.matchrecognize,
                 NAME_AUDITPROVIDER_SCHEDULE);
             agentInstanceContext.InstrumentationProvider.QRegExScheduledEval();
             scheduleCallback.Triggered();
             agentInstanceContext.InstrumentationProvider.ARegExScheduledEval();
         }
     };
     handle = new EPStatementHandleCallbackSchedule(
         agentInstanceContext.EpStatementAgentInstanceHandle,
         callback);
 }
Beispiel #22
0
        private void ScheduleNextCallback()
        {
            var nextScheduleCallback = new ProxyScheduleHandleCallback(delegate { ContinueSendingEvents(); });
            var spi           = (EPRuntimeSPI)_runtime;
            var deploymentId  = "CSV-adapter-" + UuidGenerator.Generate();
            var metricsHandle = spi.ServicesContext.MetricReportingService.GetStatementHandle(-1, deploymentId, "AbstractCoordinatedAdapter");
            var lockImpl      = _container.RWLockManager().CreateLock("CSV");
            var stmtHandle    = new EPStatementHandle(
                "AbstractCoordinatedAdapter", deploymentId, -1, null, 0, false, false,
                spi.ServicesContext.MultiMatchHandlerFactory.Make(false, false), false, false, metricsHandle, null, null);
            var agentInstanceHandle = new EPStatementAgentInstanceHandle(stmtHandle, -1, lockImpl);
            var scheduleCSVHandle   = new EPStatementHandleCallbackSchedule(agentInstanceHandle, nextScheduleCallback);

            long nextScheduleSlot;

            if (EventsToSend.IsEmpty())
            {
                if ((ExecutionPathDebugLog.IsDebugEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".scheduleNextCallback no events to send, scheduling callback in 100 ms");
                }
                nextScheduleSlot = 0L;
                _schedulingService.Add(100, scheduleCSVHandle, nextScheduleSlot);
            }
            else
            {
                // Offset is not a function of the currentTime alone.
                var  first     = EventsToSend.First();
                long baseMsec  = _currentTime - _startTime;
                long afterMsec = first.SendTime - baseMsec;
                nextScheduleSlot = first.ScheduleSlot;
                if ((ExecutionPathDebugLog.IsDebugEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".scheduleNextCallback schedulingCallback in " + afterMsec + " milliseconds");
                }
                _schedulingService.Add(afterMsec, scheduleCSVHandle, nextScheduleSlot);
            }
        }
        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 #24
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;
        }
Beispiel #25
0
        public ExpressionViewBase(
            ExpressionViewFactoryBase factory,
            ViewUpdatedCollection viewUpdatedCollection,
            ObjectArrayEventBean builtinEventProps,
            AgentInstanceViewFactoryChainContext agentInstanceContext)
        {
            this.factory = factory;
            this.viewUpdatedCollection = viewUpdatedCollection;
            this.builtinEventProps = builtinEventProps;
            eventsPerStream = new EventBean[] {null, builtinEventProps};
            this.agentInstanceContext = agentInstanceContext.AgentInstanceContext;

            if (factory.Variables != null && factory.Variables.Length > 0) {
                foreach (var variable in factory.Variables) {
                    var variableDepId = variable.DeploymentId;
                    var variableName = variable.MetaData.VariableName;
                    int agentInstanceId = agentInstanceContext.AgentInstanceId;
                    agentInstanceContext.StatementContext.VariableManagementService.RegisterCallback(
                        variable.DeploymentId,
                        variableName,
                        agentInstanceId,
                        this);
                    agentInstanceContext.AgentInstanceContext.AddTerminationCallback(
                        new ProxyAgentInstanceMgmtCallback {
                            ProcStop = services => {
                                services.AgentInstanceContext.VariableManagementService
                                    .UnregisterCallback(variableDepId, variableName, agentInstanceId, this);
                            }
                        });
                }

                ScheduleHandleCallback callback = new ProxyScheduleHandleCallback {
                    ProcScheduledTrigger = () => {
                        agentInstanceContext.AuditProvider.ScheduleFire(
                            agentInstanceContext.AgentInstanceContext,
                            ScheduleObjectType.view,
                            factory.ViewName);
                        agentInstanceContext.InstrumentationProvider.QViewScheduledEval(factory);
                        ScheduleCallback();
                        agentInstanceContext.InstrumentationProvider.AViewScheduledEval();
                    }
                };
                scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
                scheduleHandle = new EPStatementHandleCallbackSchedule(
                    agentInstanceContext.EpStatementAgentInstanceHandle,
                    callback);
            }
            else {
                scheduleSlot = -1;
                scheduleHandle = null;
            }

            if (factory.AggregationServiceFactory != null) {
                aggregationService = factory.AggregationServiceFactory.MakeService(
                    agentInstanceContext.AgentInstanceContext,
                    agentInstanceContext.ImportService,
                    false,
                    null,
                    null);
            }
            else {
                aggregationService = null;
            }
        }