コード例 #1
0
ファイル: TimeBatchView.cs プロジェクト: lanicon/nesper
        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);
        }
コード例 #2
0
ファイル: OutputConditionTime.cs プロジェクト: lanicon/nesper
        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);
        }
コード例 #3
0
ファイル: OutputConditionTime.cs プロジェクト: lanicon/nesper
        public override void UpdateOutputCondition(
            int newEventsCount,
            int oldEventsCount)
        {
            if (currentReferencePoint == null) {
                currentReferencePoint = context.StatementContext.SchedulingService.Time;
            }

            // If we pull the interval from a variable, then we may need to reschedule
            if (parent.IsVariable) {
                long now = context.StatementContext.SchedulingService.Time;
                TimePeriodDeltaResult delta = parent.TimePeriodCompute.DeltaAddWReference(
                    now,
                    currentReferencePoint.Value,
                    null,
                    true,
                    context);
                if (delta.Delta != currentScheduledTime) {
                    if (isCallbackScheduled) {
                        // reschedule
                        context.AuditProvider.ScheduleRemove(
                            context,
                            handle,
                            ScheduleObjectType.outputratelimiting,
                            NAME_AUDITPROVIDER_SCHEDULE);
                        context.StatementContext.SchedulingService.Remove(handle, scheduleSlot);
                        ScheduleCallback();
                    }
                }
            }

            // Schedule the next callback if there is none currently scheduled
            if (!isCallbackScheduled) {
                ScheduleCallback();
            }
        }