Exemple #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="viewUpdatedCollection">is a collection that the view must update when receiving events</param>
        /// <param name="timeBatchViewFactory">fr copying this view in a group-by</param>
        /// <param name="agentInstanceContext">is required view services</param>
        /// <param name="timeDeltaComputation">delta computation</param>
        public TimeAccumView(
            TimeAccumViewFactory timeBatchViewFactory,
            AgentInstanceViewFactoryChainContext agentInstanceContext,
            ExprTimePeriodEvalDeltaConst timeDeltaComputation,
            ViewUpdatedCollection viewUpdatedCollection)
        {
            _agentInstanceContext = agentInstanceContext;
            _factory = timeBatchViewFactory;
            _timeDeltaComputation  = timeDeltaComputation;
            _viewUpdatedCollection = viewUpdatedCollection;

            _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();

            var callback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = extensionServicesContext =>
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QViewScheduledEval(this, _factory.ViewName);
                    }
                    SendRemoveStream();
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AViewScheduledEval();
                    }
                }
            };

            _handle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback);
            agentInstanceContext.AddTerminationCallback(this);
        }
        private void StartContextCallback()
        {
            var scheduleCallback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = (extensionServicesContext) =>
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QContextScheduledEval(_statementContext.ContextDescriptor);
                    }
                    _scheduleHandle = null;  // terminates automatically unless scheduled again
                    _callback.RangeNotification(Collections.EmptyDataMap, this, null, null, _filterAddendum);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AContextScheduledEval();
                    }
                }
            };
            var agentHandle = new EPStatementAgentInstanceHandle(_statementContext.EpStatementHandle, _statementContext.DefaultAgentInstanceLock, -1, new StatementAgentInstanceFilterVersion(), _statementContext.FilterFaultHandlerFactory);

            _scheduleHandle = new EPStatementHandleCallback(agentHandle, scheduleCallback);
            var schedulingService   = _statementContext.SchedulingService;
            var engineImportService = _statementContext.EngineImportService;
            var nextScheduledTime   = ScheduleComputeHelper.ComputeDeltaNextOccurance(_spec.Schedule, schedulingService.Time, engineImportService.TimeZone, engineImportService.TimeAbacus);

            _statementContext.SchedulingService.Add(nextScheduledTime, _scheduleHandle, _scheduleSlot);
        }
Exemple #3
0
        protected void ScheduleCallback()
        {
            long current = _agentInstanceContext.StatementContext.SchedulingService.Time;
            ExprTimePeriodEvalDeltaResult deltaWReference = _timeDeltaComputation.DeltaAddWReference(
                current, _currentReferencePoint.Value);
            long afterTime = deltaWReference.Delta;

            _currentReferencePoint = deltaWReference.LastReference;

            var callback = new ProxyScheduleHandleCallback()
            {
                ProcScheduledTrigger = (extensionServicesContext) =>
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QViewScheduledEval(this, _timeBatchViewFactory.ViewName);
                    }
                    SendBatch();
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AViewScheduledEval();
                    }
                }
            };

            _handle = new EPStatementHandleCallback(_agentInstanceContext.EpStatementAgentInstanceHandle, callback);
            _agentInstanceContext.StatementContext.SchedulingService.Add(afterTime, _handle, _scheduleSlot);
        }
Exemple #4
0
        private void StartContextCallback(long timeOffset)
        {
            var scheduleCallback = new ProxyScheduleHandleCallback()
            {
                ProcScheduledTrigger = extensionServicesContext =>
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QContextScheduledEval(_agentInstanceContext.StatementContext.ContextDescriptor);
                    }
                    _scheduleHandle = null; // terminates automatically unless scheduled again
                    _callback.RangeNotification(Collections.GetEmptyMap <String, Object>(), this, null, null, _filterAddendum);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AContextScheduledEval();
                    }
                }
            };
            var agentHandle =
                new EPStatementAgentInstanceHandle(
                    _agentInstanceContext.StatementContext.EpStatementHandle,
                    _agentInstanceContext.StatementContext.DefaultAgentInstanceLock, -1,
                    new StatementAgentInstanceFilterVersion(),
                    _agentInstanceContext.StatementContext.FilterFaultHandlerFactory);

            _scheduleHandle = new EPStatementHandleCallback(agentHandle, scheduleCallback);


            long timeDelta = _spec.TimePeriod.NonconstEvaluator().DeltaUseEngineTime(null, _agentInstanceContext) - timeOffset;

            _agentInstanceContext.StatementContext.SchedulingService.Add(timeDelta, _scheduleHandle, _scheduleSlot);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="timeBatchViewFactory">for copying this view in a group-by</param>
        /// <param name="agentInstanceContext">The agent instance context.</param>
        /// <param name="timeDeltaComputation">The time delta computation.</param>
        public TimeAccumViewRStream(
            TimeAccumViewFactory timeBatchViewFactory,
            AgentInstanceViewFactoryChainContext agentInstanceContext,
            ExprTimePeriodEvalDeltaConst timeDeltaComputation)
        {
            _agentInstanceContext = agentInstanceContext;
            _factory = timeBatchViewFactory;
            _timeDeltaComputation = timeDeltaComputation;

            _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = extensionServicesContext =>
                {
                    using (Instrument.With(
                               i => i.QViewScheduledEval(this, _factory.ViewName),
                               i => i.AViewScheduledEval()))
                    {
                        SendRemoveStream();
                    }
                }
            };

            _handle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback);
            agentInstanceContext.AddTerminationCallback(Stop);
        }
Exemple #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="agentInstanceContext">The agent instance context.</param>
        /// <param name="timeWindowViewFactory">for copying the view in a group-by</param>
        /// <param name="timeDeltaComputation">is the computation of number of milliseconds before events gets pushedout of the timeWindow as oldData in the Update method.</param>
        /// <param name="viewUpdatedCollection">is a collection the view must Update when receiving events</param>
        public TimeWindowView(
            AgentInstanceViewFactoryChainContext agentInstanceContext,
            TimeWindowViewFactory timeWindowViewFactory,
            ExprTimePeriodEvalDeltaConst timeDeltaComputation,
            ViewUpdatedCollection viewUpdatedCollection)
        {
            _agentInstanceContext  = agentInstanceContext;
            _timeWindowViewFactory = timeWindowViewFactory;
            _timeDeltaComputation  = timeDeltaComputation;
            _viewUpdatedCollection = viewUpdatedCollection;
            _scheduleSlot          = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
            _timeWindow            = new TimeWindow(agentInstanceContext.IsRemoveStream);

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = extensionServicesContext => Instrument.With(
                    i => i.QViewScheduledEval(this, timeWindowViewFactory.ViewName),
                    i => i.AViewScheduledEval(),
                    Expire)
            };

            _handle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback);

            if (agentInstanceContext.StatementContext.ScheduleAdjustmentService != null)
            {
                agentInstanceContext.StatementContext.ScheduleAdjustmentService.AddCallback(this);
            }
            agentInstanceContext.AddTerminationCallback(Stop);
        }
Exemple #7
0
        private void ScheduleCallback()
        {
            _isCallbackScheduled = true;
            var current = _context.StatementContext.SchedulingService.Time;

            if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
            {
                Log.Debug(
                    ".scheduleCallback Scheduled new callback for " +
                    " now=" + current +
                    " currentReferencePoint=" + _currentReferencePoint +
                    " spec=" + _factory.ScheduleSpec);
            }

            var callback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = extensionServicesContext => Instrument.With(
                    i => i.QOutputRateConditionScheduledEval(),
                    i => i.AOutputRateConditionScheduledEval(),
                    () =>
                {
                    _isCallbackScheduled = false;
                    OutputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE);
                    ScheduleCallback();
                })
            };
            var handle            = new EPStatementHandleCallback(_context.EpStatementAgentInstanceHandle, callback);
            var schedulingService = _context.StatementContext.SchedulingService;
            var nextScheduledTime = ScheduleComputeHelper.ComputeDeltaNextOccurance(
                _factory.ScheduleSpec, schedulingService.Time,
                _context.StatementContext.MethodResolutionService.EngineImportService.TimeZone);

            schedulingService.Add(nextScheduledTime, handle, _scheduleSlot);
        }
Exemple #8
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="agentInstanceContext">The agent instance context.</param>
        /// <param name="viewFactory">for copying this view in a group-by</param>
        /// <param name="timestampExpr">the property name of the event supplying timestamp values</param>
        /// <param name="timestampEvaluator">The timestamp evaluator.</param>
        /// <param name="timeDeltaComputation">The time delta computation.</param>
        /// <param name="optionalSortedRandomAccess">is the friend class handling the random access, if required byexpressions</param>
        public TimeOrderView(
            AgentInstanceViewFactoryChainContext agentInstanceContext,
            ViewFactory viewFactory,
            ExprNode timestampExpr,
            ExprEvaluator timestampEvaluator,
            ExprTimePeriodEvalDeltaConst timeDeltaComputation,
            IStreamSortRankRandomAccess optionalSortedRandomAccess)
        {
            _agentInstanceContext       = agentInstanceContext;
            _viewFactory                = viewFactory;
            _timestampExpression        = timestampExpr;
            _timestampEvaluator         = timestampEvaluator;
            _timeDeltaComputation       = timeDeltaComputation;
            _optionalSortedRandomAccess = optionalSortedRandomAccess;
            _scheduleSlot               = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();

            _sortedEvents = new OrderedDictionary <Object, Object>();

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = extensionServicesContext => Instrument.With(
                    i => i.QViewScheduledEval(this, _viewFactory.ViewName),
                    i => i.AViewScheduledEval(),
                    Expire)
            };

            _handle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback);
            agentInstanceContext.AddTerminationCallback(Stop);
        }
Exemple #9
0
        private void ScheduleCallback()
        {
            _isCallbackScheduled = true;
            long current = _agentInstanceContext.StatementContext.SchedulingService.Time;

            if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
            {
                Log.Debug(
                    ".scheduleCallback Scheduled new callback for " +
                    " afterMsec=" + 0 +
                    " now=" + current);
            }

            ScheduleHandleCallback callback = new ProxyScheduleHandleCallback()
            {
                ProcScheduledTrigger = extensionServicesContext => Instrument.With(
                    i => i.QOutputRateConditionScheduledEval(),
                    i => i.AOutputRateConditionScheduledEval(),
                    () =>
                {
                    _isCallbackScheduled = false;
                    OutputCallback.Invoke(true, true);
                    ResetBuiltinProperties();
                })
            };

            _scheduleHandle = new EPStatementHandleCallback(
                _agentInstanceContext.EpStatementAgentInstanceHandle, callback);
            _agentInstanceContext.StatementContext.SchedulingService.Add(0, _scheduleHandle, _scheduleSlot);
            _agentInstanceContext.AddTerminationCallback(Stop);

            // execute assignments
            ExecuteThenAssignments();
        }
Exemple #10
0
        public void Open(DataFlowOpOpenContext openContext)
        {
            FilterValueSet valueSet;

            try
            {
                IList <ExprNode> filters = new ExprNode[0];
                if (filter != null)
                {
                    filters = new ExprNode[] { filter };
                }

                var spec = FilterSpecCompiler.MakeFilterSpec(
                    _eventType, _eventType.Name, filters, null,
                    null, null,
                    new StreamTypeServiceImpl(
                        _eventType,
                        _eventType.Name, true,
                        _agentInstanceContext.EngineURI),
                    null,
                    _agentInstanceContext.StatementContext,
                    new List <int>());
                valueSet = spec.GetValueSet(null, _agentInstanceContext, null);
            }
            catch (ExprValidationException ex)
            {
                throw new EPException("Failed to open filter: " + ex.Message, ex);
            }

            var handle = new EPStatementAgentInstanceHandle(_agentInstanceContext.StatementContext.EpStatementHandle, _agentInstanceContext.AgentInstanceLock, 0, new StatementAgentInstanceFilterVersion());

            _callbackHandle     = new EPStatementHandleCallback(handle, this);
            _filterServiceEntry = _agentInstanceContext.StatementContext.FilterService.Add(valueSet, _callbackHandle);
        }
Exemple #11
0
        public void Activate(EventBean optionalTriggeringEvent, MatchedEventMap priorMatches, long timeOffset, bool isRecoveringResilient)
        {
            FilterHandleCallback filterCallback = new ProxyFilterHandleCallback
            {
                ProcStatementId = () => _agentInstanceContext.StatementContext.StatementId,
                ProcIsSubselect = () => false,
                ProcMatchFound  = (theEvent, allStmtMatches) => FilterMatchFound(theEvent)
            };

            // determine addendum, if any
            FilterValueSetParam[][] addendum = null;
            if (_filterAddendum != null)
            {
                addendum = _filterAddendum.GetFilterAddendum(_endpointFilterSpec.FilterSpecCompiled);
            }

            _filterHandle = new EPStatementHandleCallback(_agentInstanceContext.EpStatementAgentInstanceHandle, filterCallback);
            FilterValueSet filterValueSet = _endpointFilterSpec.FilterSpecCompiled.GetValueSet(null, _agentInstanceContext, addendum);

            _filterServiceEntry = _servicesContext.FilterService.Add(filterValueSet, _filterHandle);

            if (optionalTriggeringEvent != null)
            {
                bool match = StatementAgentInstanceUtil.EvaluateFilterForStatement(_servicesContext, optionalTriggeringEvent, _agentInstanceContext, _filterHandle);

                if (match)
                {
                    FilterMatchFound(optionalTriggeringEvent);
                }
            }
        }
        private void ScheduleNextCallback()
        {
            var nextScheduleCallback = new ProxyScheduleHandleCallback(delegate { ContinueSendingEvents(); });
            var spi                 = (EPServiceProviderSPI)_epService;
            var metricsHandle       = spi.MetricReportingService.GetStatementHandle(-1, "AbstractCoordinatedAdapter");
            var lockImpl            = ReaderWriterLockManager.CreateLock("CSV");
            var stmtHandle          = new EPStatementHandle(-1, "AbstractCoordinatedAdapter", null, StatementType.ESPERIO, "AbstractCoordinatedAdapter", false, metricsHandle, 0, false, false, spi.ServicesContext.MultiMatchHandlerFactory.GetDefaultHandler());
            var agentInstanceHandle = new EPStatementAgentInstanceHandle(stmtHandle, lockImpl, -1, new StatementAgentInstanceFilterVersion(), null);
            var scheduleCSVHandle   = new EPStatementHandleCallback(agentInstanceHandle, nextScheduleCallback);

            ScheduleSlot nextScheduleSlot;

            if (EventsToSend.IsEmpty())
            {
                if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".scheduleNextCallback no events to send, scheduling callback in 100 ms");
                }
                nextScheduleSlot = new ScheduleSlot(0, 0);
                _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.IsEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".scheduleNextCallback schedulingCallback in " + afterMsec + " milliseconds");
                }
                _schedulingService.Add(afterMsec, scheduleCSVHandle, nextScheduleSlot);
            }
        }
 private void EndContextCallback()
 {
     if (_scheduleHandle != null)
     {
         _statementContext.SchedulingService.Remove(_scheduleHandle, _scheduleSlot);
     }
     _scheduleHandle = null;
 }
Exemple #14
0
 public void Stop()
 {
     if (_scheduleHandle != null)
     {
         _agentInstanceContext.StatementContext.SchedulingService.Remove(_scheduleHandle, _scheduleSlot);
         _scheduleHandle = null;
     }
 }
        protected ExpressionViewBase(
            ViewUpdatedCollection viewUpdatedCollection,
            ExprEvaluator expiryExpression,
            AggregationServiceFactoryDesc aggregationServiceFactoryDesc,
            ObjectArrayEventBean builtinEventProps,
            ISet <String> variableNames,
            AgentInstanceViewFactoryChainContext agentInstanceContext)
        {
            ViewUpdatedCollection = viewUpdatedCollection;
            ExpiryExpression      = expiryExpression;
            BuiltinEventProps     = builtinEventProps;
            EventsPerStream       = new EventBean[] { null, builtinEventProps };
            VariableNames         = variableNames;
            AgentInstanceContext  = agentInstanceContext;

            if (variableNames != null && !variableNames.IsEmpty())
            {
                foreach (String variable in variableNames)
                {
                    var variableName    = variable;
                    var agentInstanceId = agentInstanceContext.AgentInstanceId;
                    var variableService = agentInstanceContext.StatementContext.VariableService;

                    agentInstanceContext.StatementContext.VariableService.RegisterCallback(variable, agentInstanceId, Update);
                    agentInstanceContext.AddTerminationCallback(
                        new ProxyStopCallback(() => variableService.UnregisterCallback(variableName, agentInstanceId, Update)));
                }

                ScheduleHandleCallback callback = new ProxyScheduleHandleCallback
                {
                    ProcScheduledTrigger = extensionServicesContext => Instrument.With(
                        i => i.QViewScheduledEval(this, ViewName),
                        i => i.AViewScheduledEval(),
                        ScheduleCallback)
                };
                ScheduleSlot   = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
                ScheduleHandle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback);
                agentInstanceContext.AddTerminationCallback(this);
            }
            else
            {
                ScheduleSlot   = -1;
                ScheduleHandle = null;
            }

            if (aggregationServiceFactoryDesc != null)
            {
                AggregationService = aggregationServiceFactoryDesc.AggregationServiceFactory.MakeService(
                    agentInstanceContext.AgentInstanceContext,
                    agentInstanceContext.AgentInstanceContext.StatementContext.EngineImportService, false, null);
                AggregateNodes = aggregationServiceFactoryDesc.Expressions;
            }
            else
            {
                AggregationService = null;
                AggregateNodes     = Collections.GetEmptyList <AggregationServiceAggExpressionDesc>();
            }
        }
Exemple #16
0
 public void StopObserve()
 {
     if (_isTimerActive)
     {
         _observerEventEvaluator.Context.PatternContext.SchedulingService.Remove(_scheduleHandle, _scheduleSlot);
         _isTimerActive  = false;
         _scheduleHandle = null;
     }
 }
Exemple #17
0
 private void DeactivateTimer()
 {
     if (scheduleHandle != null)
     {
         quitable.Context.PatternContext.SchedulingService.Remove(scheduleHandle, scheduleSlot);
     }
     scheduleHandle = null;
     isTimerActive  = false;
 }
Exemple #18
0
 public void StopGuard()
 {
     if (_isTimerActive)
     {
         _quitable.Context.PatternContext.SchedulingService.Remove(_scheduleHandle, _scheduleSlot);
         _scheduleHandle = null;
         _isTimerActive  = false;
     }
 }
Exemple #19
0
 /// <summary>Ctor. </summary>
 /// <param name="epRuntime">runtime to process</param>
 /// <param name="handleCallback">callback</param>
 /// <param name="theEvent">event</param>
 /// <param name="filterVersion">version of filter</param>
 public RouteUnitSingle(EPRuntimeImpl epRuntime,
                        EPStatementHandleCallback handleCallback,
                        EventBean theEvent,
                        long filterVersion)
 {
     _epRuntime      = epRuntime;
     _event          = theEvent;
     _handleCallback = handleCallback;
     _filterVersion  = filterVersion;
 }
Exemple #20
0
 public void Deactivate()
 {
     if (_filterHandle != null)
     {
         _servicesContext.FilterService.Remove(_filterHandle, _filterServiceEntry);
         _filterHandle       = null;
         _filterServiceEntry = null;
         long filtersVersion = _agentInstanceContext.StatementContext.FilterService.FiltersVersion;
         _agentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion;
     }
 }
 public void Stop()
 {
     lock (this)
     {
         if (_filterHandle != null)
         {
             _parent.Services.FilterService.Remove(_filterHandle, _filterServiceEntry);
         }
         _filterHandle = null;
     }
 }
 public void StopObserve()
 {
     if (_isTimerActive)
     {
         _observerEventEvaluator.Context.PatternContext.SchedulingService.Remove(_scheduleHandle, _scheduleSlot);
     }
     _isTimerActive       = false;
     _scheduleHandle      = null;
     _cachedCountRepeated = long.MaxValue;
     _cachedLastScheduled = null;
     _anchorTime          = null;
 }
Exemple #23
0
 public void Close(DataFlowOpCloseContext openContext)
 {
     using (_iLock.Acquire())
     {
         if (callbackHandle != null)
         {
             agentInstanceContext.StatementContext.FilterService.Remove(callbackHandle, filterServiceEntry);
             callbackHandle     = null;
             filterServiceEntry = null;
         }
     }
 }
Exemple #24
0
        public void StartGuard()
        {
            if (_isTimerActive)
            {
                throw new IllegalStateException("Timer already active");
            }

            // Start the stopwatch timer
            _scheduleHandle = new EPStatementHandleCallback(_quitable.Context.AgentInstanceContext.EpStatementAgentInstanceHandle, this);
            _quitable.Context.PatternContext.SchedulingService.Add(_msec, _scheduleHandle, _scheduleSlot);
            _isTimerActive = true;
        }
Exemple #25
0
        protected void StartFiltering()
        {
            FilterService filterService = _evalFilterNode.Context.PatternContext.FilterService;

            Handle = new EPStatementHandleCallback(_evalFilterNode.Context.AgentInstanceContext.EpStatementAgentInstanceHandle, this);
            FilterValueSet filterValues = _evalFilterNode.FactoryNode.FilterSpec.GetValueSet(BeginState, _evalFilterNode.Context.AgentInstanceContext, _evalFilterNode.AddendumFilters);

            FilterServiceEntry = filterService.Add(filterValues, Handle);
            long filtersVersion = filterService.FiltersVersion;

            _evalFilterNode.Context.AgentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion;
        }
Exemple #26
0
        public void StartGuard()
        {
            if (isTimerActive)
            {
                throw new IllegalStateException("Timer already active");
            }

            scheduleHandle = new EPStatementHandleCallback(quitable.Context.AgentInstanceContext.EpStatementAgentInstanceHandle, this);
            quitable.Context.PatternContext.SchedulingService.Add(deltaTime, scheduleHandle, scheduleSlot);
            isTimerActive = true;
            counter       = 0;
        }
Exemple #27
0
        /// <summary>Register an adapter. </summary>
        /// <param name="epService">engine</param>
        public void RegisterAdapter(EPServiceProvider epService)
        {
            var spi       = (EPServiceProviderSPI)epService;
            var eventType = spi.EventAdapterService.GetEventTypeByName(EventTypeName);
            var fvs       = new FilterSpecCompiled(eventType, null, new IList <FilterSpecParam> [0], null).GetValueSet(null, null, null);

            var name            = "subscription:" + SubscriptionName;
            var metricsHandle   = spi.MetricReportingService.GetStatementHandle(name, name);
            var statementHandle = new EPStatementHandle(name, name, name, StatementType.ESPERIO, name, false, metricsHandle, 0, false, false, MultiMatchHandlerFactory.DefaultHandler);
            var agentHandle     = new EPStatementAgentInstanceHandle(statementHandle, ReaderWriterLockManager.CreateDefaultLock(), -1, new StatementAgentInstanceFilterVersion());
            var registerHandle  = new EPStatementHandleCallback(agentHandle, this);

            spi.FilterService.Add(fvs, registerHandle);
        }
Exemple #28
0
        public void StartObserve()
        {
            if (_isTimerActive)
            {
                throw new IllegalStateException("Timer already active");
            }

            _scheduleHandle = new EPStatementHandleCallback(_observerEventEvaluator.Context.AgentInstanceContext.EpStatementAgentInstanceHandle, this);
            SchedulingService schedulingService = _observerEventEvaluator.Context.PatternContext.SchedulingService;
            long nextScheduledTime = ScheduleComputeHelper.ComputeDeltaNextOccurance(_scheduleSpec, schedulingService.Time, _observerEventEvaluator.Context.StatementContext.MethodResolutionService.EngineImportService.TimeZone);

            schedulingService.Add(nextScheduledTime, _scheduleHandle, _scheduleSlot);
            _isTimerActive = true;
        }
Exemple #29
0
        public void PutCached(Object[] methodParams, int numLookupKeys, EventTable[] rows)
        {
            var key  = DataCacheUtil.GetLookupKey(methodParams, numLookupKeys);
            var now  = _schedulingService.Time;
            var item = new Item(rows, now);

            _cache.Put(key, item);

            if (!_isScheduled)
            {
                var callback = new EPStatementHandleCallback(_epStatementAgentInstanceHandle, this);
                _schedulingService.Add(_timeAbacus.DeltaForSecondsDouble(_purgeIntervalSec), callback, _scheduleSlot);
                _isScheduled = true;
            }
        }
        public void PutCached(object[] lookupKeys, EventTable[] rows)
        {
            var key  = DataCacheUtil.GetLookupKey(lookupKeys);
            var now  = _schedulingService.Time;
            var item = new Item(rows, now);

            _cache.Put(key, item);

            if (!_isScheduled)
            {
                var callback = new EPStatementHandleCallback(_epStatementAgentInstanceHandle, this);
                _schedulingService.Add(PurgeIntervalMSec, callback, _scheduleSlot);
                _isScheduled = true;
            }
        }