Пример #1
0
        protected void ScheduleCallback()
        {
            long current = _agentInstanceContext.StatementContext.SchedulingService.Time;
            ExprTimePeriodEvalDeltaResult deltaWReference = _timeDeltaComputation.DeltaMillisecondsAddWReference(
                current, _currentReferencePoint.Value);
            long afterMSec = deltaWReference.Delta;

            _currentReferencePoint = deltaWReference.LastReference;

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

            _handle = new EPStatementHandleCallback(_agentInstanceContext.EpStatementAgentInstanceHandle, callback);
            _agentInstanceContext.StatementContext.SchedulingService.Add(afterMSec, _handle, _scheduleSlot);
        }
Пример #2
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _factory.ViewName, newData, oldData);
            }

            // remove points from data window
            if (oldData != null && oldData.Length != 0)
            {
                foreach (EventBean anOldData in oldData)
                {
                    Window.Remove(anOldData);
                    HandleInternalRemovedEvent(anOldData);
                }
                DetermineOldestTimestamp();
            }

            // add data points to the window
            EventBean[] batchNewData = null;
            if (newData != null)
            {
                foreach (EventBean newEvent in newData)
                {
                    long timestamp = GetLongValue(newEvent);
                    if (ReferenceTimestamp == null)
                    {
                        ReferenceTimestamp = timestamp;
                    }

                    if (_oldestTimestamp == null)
                    {
                        _oldestTimestamp = timestamp;
                    }
                    else
                    {
                        var delta = _timeDeltaComputation.DeltaMillisecondsAddWReference(
                            _oldestTimestamp.Value, ReferenceTimestamp.Value);
                        ReferenceTimestamp = delta.LastReference;
                        if (timestamp - _oldestTimestamp >= delta.Delta)
                        {
                            if (batchNewData == null)
                            {
                                batchNewData = Window.ToArray();
                            }
                            else
                            {
                                batchNewData = EventBeanUtility.AddToArray(batchNewData, Window);
                            }
                            Window.Clear();
                            _oldestTimestamp = null;
                        }
                    }

                    Window.Add(newEvent);
                    HandleInternalAddEvent(newEvent, batchNewData != null);
                }
            }

            if (batchNewData != null)
            {
                HandleInternalPostBatch(Window, batchNewData);
                if (ViewUpdatedCollection != null)
                {
                    ViewUpdatedCollection.Update(batchNewData, LastBatch);
                }
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QViewIndicate(this, _factory.ViewName, newData, LastBatch);
                }
                UpdateChildren(batchNewData, LastBatch);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewIndicate();
                }
                LastBatch = batchNewData;
                DetermineOldestTimestamp();
            }
            if (oldData != null && oldData.Length > 0)
            {
                if (ViewUpdatedCollection != null)
                {
                    ViewUpdatedCollection.Update(null, oldData);
                }
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QViewIndicate(this, _factory.ViewName, null, oldData);
                }
                UpdateChildren(null, oldData);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewIndicate();
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }