Ejemplo n.º 1
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            Instrument.With(
                i => i.QViewProcessIRStream(this, _timeWindowViewFactory.ViewName, newData, oldData),
                i => i.AViewProcessIRStream(),
                () =>
            {
                long timestamp = _agentInstanceContext.StatementContext.SchedulingService.Time;

                if (oldData != null)
                {
                    for (int i = 0; i < oldData.Length; i++)
                    {
                        _timeWindow.Remove(oldData[i]);
                    }
                }

                // we don't care about removed data from a prior view
                if ((newData != null) && (newData.Length > 0))
                {
                    // If we have an empty window about to be filled for the first time, schedule a callback
                    // for now plus timeDeltaComputation
                    if (_timeWindow.IsEmpty())
                    {
                        long current = _agentInstanceContext.StatementContext.SchedulingService.Time;
                        ScheduleCallback(_timeDeltaComputation.DeltaAdd(current));
                    }

                    // add data points to the timeWindow
                    for (int i = 0; i < newData.Length; i++)
                    {
                        _timeWindow.Add(timestamp, newData[i]);
                    }

                    if (_viewUpdatedCollection != null)
                    {
                        _viewUpdatedCollection.Update(newData, null);
                    }
                }

                // Update child views
                if (HasViews)
                {
                    Instrument.With(
                        i => i.QViewIndicate(this, _timeWindowViewFactory.ViewName, newData, oldData),
                        i => i.AViewIndicate(),
                        () => UpdateChildren(newData, oldData));
                }
            });
        }
Ejemplo n.º 2
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            _agentInstanceContext.AuditProvider.View(newData, oldData, _agentInstanceContext, _keepAllViewFactory);
            _agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(_keepAllViewFactory, newData, oldData);

            if (newData != null) {
                foreach (var newEvent in newData) {
                    _indexedEvents.Add(newEvent);
                    InternalHandleAdded(newEvent);
                }
            }

            if (oldData != null) {
                foreach (var anOldData in oldData) {
                    _indexedEvents.Remove(anOldData);
                    InternalHandleRemoved(anOldData);
                }
            }

            // update event buffer for access by expressions, if any
            _viewUpdatedCollection?.Update(newData, oldData);

            _agentInstanceContext.InstrumentationProvider.QViewIndicate(_keepAllViewFactory, newData, oldData);
            child.Update(newData, oldData);
            _agentInstanceContext.InstrumentationProvider.AViewIndicate();

            _agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     This method updates child views and clears the batch of events.
        /// </summary>
        protected void SendBatch()
        {
            // If there are child views and the batch was filled, fireStatementStopped update method
            if (child != null) {
                // Convert to object arrays
                EventBean[] newData = null;
                EventBean[] oldData = null;
                if (!currentBatch.IsEmpty()) {
                    newData = currentBatch.ToArray();
                }

                if (lastBatch != null && !lastBatch.IsEmpty()) {
                    oldData = lastBatch.ToArray();
                }

                // update view buffer to serve expressions require access to events held
                viewUpdatedCollection?.Update(newData, oldData);

                // Post new data (current batch) and old data (prior batch)
                if (newData != null || oldData != null) {
                    agentInstanceContext.InstrumentationProvider.QViewIndicate(
                        lengthBatchViewFactory,
                        newData,
                        oldData);
                    child.Update(newData, oldData);
                    agentInstanceContext.InstrumentationProvider.AViewIndicate();
                }
            }

            lastBatch = currentBatch;
            currentBatch = new ArrayDeque<EventBean>();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This method updates child views and clears the batch of events. We cancel and
        /// old callback and schedule a new callback at this time if there were events in
        /// the batch.
        /// </summary>
        /// <param name="isFromSchedule">true if invoked from a schedule, false if not</param>
        protected void SendBatch(bool isFromSchedule)
        {
            // No more callbacks scheduled if called from a schedule
            if (isFromSchedule)
            {
                _callbackScheduledTime = null;
            }
            else
            {
                // Remove schedule if called from on overflow due to number of events
                if (_callbackScheduledTime != null)
                {
                    _agentInstanceContext.StatementContext.SchedulingService.Remove(_handle, _scheduleSlot);
                    _callbackScheduledTime = null;
                }
            }

            // If there are child views and the batch was filled, fireStatementStopped Update method
            if (HasViews)
            {
                // Convert to object arrays
                EventBean[] newData = null;
                EventBean[] oldData = null;
                if (_currentBatch.IsNotEmpty())
                {
                    newData = _currentBatch.ToArray();
                }
                if ((_lastBatch != null) && (_lastBatch.IsNotEmpty()))
                {
                    oldData = _lastBatch.ToArray();
                }

                // Post new data (current batch) and old data (prior batch)
                if (_viewUpdatedCollection != null)
                {
                    _viewUpdatedCollection.Update(newData, oldData);
                }
                if ((newData != null) || (oldData != null) || (_isForceOutput))
                {
                    using (Instrument.With(
                               i => i.QViewIndicate(this, _timeLengthBatchViewFactory.ViewName, newData, oldData),
                               i => i.AViewIndicate()))
                    {
                        UpdateChildren(newData, oldData);
                    }
                }
            }

            // Only if there have been any events in this or the last interval do we schedule a callback,
            // such as to not waste resources when no events arrive.
            if (((_currentBatch.IsNotEmpty()) || ((_lastBatch != null) && (_lastBatch.IsNotEmpty()))) || (_isForceOutput))
            {
                ScheduleCallback(0);
            }

            // Flush and roll
            _lastBatch    = _currentBatch;
            _currentBatch = new List <EventBean>();
        }
Ejemplo n.º 5
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            AgentInstanceContext agentInstanceContext = agentInstanceViewFactoryContext.AgentInstanceContext;
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, factory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(factory, newData, oldData);
            long timestamp = -1;

            // add data points to the window
            // we don't care about removed data from a prior view
            if (newData != null) {
                for (int i = 0; i < newData.Length; i++) {
                    timestamp = GetLongValue(newData[i]);
                    timeWindow.Add(timestamp, newData[i]);
                }
            }

            // Remove from the window any events that have an older timestamp then the last event's timestamp
            ArrayDeque<EventBean> expired = null;
            if (timestamp != -1) {
                expired = timeWindow.ExpireEvents(
                    timestamp -
                    timePeriodProvide.DeltaSubtract(timestamp, null, true, agentInstanceViewFactoryContext) +
                    1);
            }

            EventBean[] oldDataUpdate = null;
            if ((expired != null) && (!expired.IsEmpty())) {
                oldDataUpdate = expired.ToArray();
            }

            if ((oldData != null) && (agentInstanceViewFactoryContext.IsRemoveStream)) {
                foreach (EventBean anOldData in oldData) {
                    timeWindow.Remove(anOldData);
                }

                if (oldDataUpdate == null) {
                    oldDataUpdate = oldData;
                }
                else {
                    oldDataUpdate = CollectionUtil.AddArrayWithSetSemantics(oldData, oldDataUpdate);
                }
            }

            viewUpdatedCollection?.Update(newData, oldDataUpdate);

            // If there are child views, fireStatementStopped update method
            if (Child != null) {
                agentInstanceContext.InstrumentationProvider.QViewIndicate(factory, newData, oldDataUpdate);
                Child.Update(newData, oldDataUpdate);
                agentInstanceContext.InstrumentationProvider.AViewIndicate();
            }

            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 6
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _lengthWindowViewFactory.ViewName, newData, oldData);
            }

            // add data points to the window
            // we don't care about removed data from a prior view
            if (newData != null)
            {
                for (int ii = 0; ii < newData.Length; ii++)
                {
                    _events.Add(newData[ii]);
                }
            }

            // Check for any events that get pushed out of the window
            int expiredCount = _events.Count - _size;

            EventBean[] expiredArr = null;
            if (expiredCount > 0)
            {
                expiredArr = new EventBean[expiredCount];
                for (int i = 0; i < expiredCount; i++)
                {
                    expiredArr[i] = _events.RemoveFirst();
                }
            }

            // Update event buffer for access by expressions, if any
            if (_viewUpdatedCollection != null)
            {
                _viewUpdatedCollection.Update(newData, expiredArr);
            }

            // If there are child views, call Update method
            if (HasViews)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QViewIndicate(this, _lengthWindowViewFactory.ViewName, newData, expiredArr);
                }
                UpdateChildren(newData, expiredArr);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewIndicate();
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     This method updates child views and clears the batch of events.
        ///     We cancel and old callback and schedule a new callback at this time if there were events in the batch.
        /// </summary>
        /// <param name="isFromSchedule">true if invoked from a schedule, false if not</param>
        protected void SendBatch(bool isFromSchedule)
        {
            // No more callbacks scheduled if called from a schedule
            if (isFromSchedule) {
                callbackScheduledTime = null;
            }
            else {
                // Remove schedule if called from on overflow due to number of events
                if (callbackScheduledTime != null) {
                    agentInstanceContext.AuditProvider.ScheduleRemove(
                        agentInstanceContext,
                        handle,
                        ScheduleObjectType.view,
                        factory.ViewName);
                    agentInstanceContext.StatementContext.SchedulingService.Remove(handle, scheduleSlot);
                    callbackScheduledTime = null;
                }
            }

            // If there are child views and the batch was filled, fireStatementStopped update method
            if (Child != null) {
                // Convert to object arrays
                EventBean[] newData = null;
                EventBean[] oldData = null;
                if (!currentBatch.IsEmpty()) {
                    newData = currentBatch.ToArray();
                }

                if (lastBatch != null && !lastBatch.IsEmpty()) {
                    oldData = lastBatch.ToArray();
                }

                // Post new data (current batch) and old data (prior batch)
                viewUpdatedCollection?.Update(newData, oldData);

                if (newData != null || oldData != null || factory.IsForceUpdate) {
                    agentInstanceContext.InstrumentationProvider.QViewIndicate(factory, newData, oldData);
                    Child.Update(newData, oldData);
                    agentInstanceContext.InstrumentationProvider.AViewIndicate();
                }
            }

            // Only if there have been any events in this or the last interval do we schedule a callback,
            // such as to not waste resources when no events arrive.
            if (!currentBatch.IsEmpty() ||
                lastBatch != null && !lastBatch.IsEmpty() ||
                factory.isForceUpdate) {
                ScheduleCallback(0);
            }

            // Flush and roll
            lastBatch = currentBatch;
            currentBatch = new List<EventBean>();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This method updates child views and clears the batch of events.
        /// We schedule a new callback at this time if there were events in the batch.
        /// </summary>
        public void SendBatch()
        {
            _isCallbackScheduled = false;

            // If there are child views and the batch was filled, fireStatementStopped update method
            if (HasViews)
            {
                // Convert to object arrays
                EventBean[] newData = null;
                EventBean[] oldData = null;
                if (!_currentBatch.IsEmpty())
                {
                    newData = _currentBatch.ToArray();
                }
                if ((_lastBatch != null) && (!_lastBatch.IsEmpty()))
                {
                    oldData = _lastBatch.ToArray();
                }

                // Post new data (current batch) and old data (prior batch)
                if (_viewUpdatedCollection != null)
                {
                    _viewUpdatedCollection.Update(newData, oldData);
                }
                if ((newData != null) || (oldData != null) || _isForceOutput)
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QViewIndicate(this, _timeBatchViewFactory.ViewName, newData, oldData);
                    }
                    UpdateChildren(newData, oldData);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AViewIndicate();
                    }
                }
            }

            // Only if forceOutput is enabled or
            // there have been any events in this or the last interval do we schedule a callback,
            // such as to not waste resources when no events arrive.
            if ((!_currentBatch.IsEmpty()) || ((_lastBatch != null) && (!_lastBatch.IsEmpty()))
                ||
                _isForceOutput)
            {
                ScheduleCallback();
                _isCallbackScheduled = true;
            }

            _lastBatch    = _currentBatch;
            _currentBatch = new ArrayDeque <EventBean>();
        }
Ejemplo n.º 9
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _keepAllViewFactory.ViewName, newData, oldData);
            }

            if (newData != null)
            {
                foreach (EventBean newEvent in newData)
                {
                    _indexedEvents.Add(newEvent);
                    InternalHandleAdded(newEvent);
                }
            }

            if (oldData != null)
            {
                foreach (EventBean anOldData in oldData)
                {
                    _indexedEvents.Remove(anOldData);
                    InternalHandleRemoved(anOldData);
                }
            }

            // Update event buffer for access by expressions, if any
            if (_viewUpdatedCollection != null)
            {
                _viewUpdatedCollection.Update(newData, oldData);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewIndicate(this, _keepAllViewFactory.ViewName, newData, oldData);
            }
            UpdateChildren(newData, oldData);
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewIndicate();
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 10
0
        /// <summary>This method updates child views and clears the batch of events. </summary>
        protected void SendBatch()
        {
            // If there are child views and the batch was filled, fireStatementStopped Update method
            if (HasViews)
            {
                // Convert to object arrays
                EventBean[] newData = null;
                EventBean[] oldData = null;
                if (CurrentBatch.IsNotEmpty())
                {
                    newData = CurrentBatch.ToArray();
                }
                if ((LastBatch != null) && (LastBatch.IsNotEmpty()))
                {
                    oldData = LastBatch.ToArray();
                }

                // Update view buffer to serve expressions require access to events held
                if (_viewUpdatedCollection != null)
                {
                    _viewUpdatedCollection.Update(newData, oldData);
                }

                // Post new data (current batch) and old data (prior batch)
                if ((newData != null) || (oldData != null))
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QViewIndicate(this, _lengthBatchViewFactory.ViewName, newData, oldData);
                    }
                    UpdateChildren(newData, oldData);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AViewIndicate();
                    }
                }
            }

            LastBatch    = CurrentBatch;
            CurrentBatch = new ArrayDeque <EventBean>();
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     This method updates child views and clears the batch of events.
        ///     We schedule a new callback at this time if there were events in the batch.
        /// </summary>
        private void SendBatch()
        {
            _isCallbackScheduled = false;

            // If there are child views and the batch was filled, fireStatementStopped update method
            if (Child != null) {
                // Convert to object arrays
                EventBean[] newData = null;
                EventBean[] oldData = null;
                if (!_currentBatch.IsEmpty()) {
                    newData = _currentBatch.ToArray();
                }

                if (_lastBatch != null && !_lastBatch.IsEmpty()) {
                    oldData = _lastBatch.ToArray();
                }

                // Post new data (current batch) and old data (prior batch)
                _viewUpdatedCollection?.Update(newData, oldData);

                if (newData != null || oldData != null || _factory.isForceUpdate) {
                    _agentInstanceContext.InstrumentationProvider.QViewIndicate(_factory, newData, oldData);
                    Child.Update(newData, oldData);
                    _agentInstanceContext.InstrumentationProvider.AViewIndicate();
                }
            }

            // Only if forceOutput is enabled or
            // there have been any events in this or the last interval do we schedule a callback,
            // such as to not waste resources when no events arrive.
            if (!_currentBatch.IsEmpty() ||
                _lastBatch != null && !_lastBatch.IsEmpty() ||
                _factory.isForceUpdate) {
                ScheduleCallback();
                _isCallbackScheduled = true;
            }

            _lastBatch = _currentBatch;
            _currentBatch = new ArrayDeque<EventBean>();
        }
Ejemplo n.º 12
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();
            }
        }
Ejemplo n.º 13
0
        // Called based on schedule evaluation registered when a variable changes (new data is null).
        // Called when new data arrives.
        private void Expire(EventBean[] newData, EventBean[] oldData)
        {
            OneEventCollection expired = null;

            if (oldData != null)
            {
                expired = new OneEventCollection();
                expired.Add(oldData);
            }
            int expiredCount = 0;

            if (!_window.IsEmpty())
            {
                ExpressionWindowTimestampEventPair newest = _window.Last;

                while (true)
                {
                    ExpressionWindowTimestampEventPair first = _window.First;

                    bool pass = CheckEvent(first, newest, expiredCount);
                    if (!pass)
                    {
                        if (expired == null)
                        {
                            expired = new OneEventCollection();
                        }
                        EventBean removed = _window.RemoveFirst().TheEvent;
                        expired.Add(removed);
                        if (AggregationService != null)
                        {
                            _removedEvents[0] = removed;
                            AggregationService.ApplyLeave(_removedEvents, null, AgentInstanceContext);
                        }
                        expiredCount++;
                        InternalHandleExpired(first);
                    }
                    else
                    {
                        break;
                    }

                    if (_window.IsEmpty())
                    {
                        if (AggregationService != null)
                        {
                            AggregationService.ClearResults(AgentInstanceContext);
                        }
                        break;
                    }
                }
            }

            // Check for any events that get pushed out of the window
            EventBean[] expiredArr = null;
            if (expired != null)
            {
                expiredArr = expired.ToArray();
            }

            // update event buffer for access by expressions, if any
            if (ViewUpdatedCollection != null)
            {
                ViewUpdatedCollection.Update(newData, expiredArr);
            }

            // If there are child views, call update method
            if (HasViews)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QViewIndicate(this, _dataWindowViewFactory.ViewName, newData, expiredArr);
                }
                UpdateChildren(newData, expiredArr);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewIndicate();
                }
            }
        }
Ejemplo n.º 14
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, factory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(factory, newData, oldData);

            // we don't care about removed data from a prior view
            if (newData == null || newData.Length == 0) {
                return;
            }

            // If we have an empty window about to be filled for the first time, addSchedule a callback
            var removeSchedule = false;
            var addSchedule = false;
            var timestamp = agentInstanceContext.StatementContext.SchedulingService.Time;

            if (!currentBatch.IsEmpty()) {
                // check if we need to reschedule
                var callbackTime = timestamp + timePeriodProvide.DeltaAdd(timestamp, null, true, agentInstanceContext);
                if (callbackTime != callbackScheduledTime) {
                    removeSchedule = true;
                    addSchedule = true;
                }
            }
            else {
                addSchedule = true;
            }

            if (removeSchedule) {
                agentInstanceContext.AuditProvider.ScheduleRemove(
                    agentInstanceContext,
                    handle,
                    ScheduleObjectType.view,
                    factory.ViewName);
                agentInstanceContext.StatementContext.SchedulingService.Remove(handle, scheduleSlot);
            }

            if (addSchedule) {
                long timeIntervalSize = timePeriodProvide.DeltaAdd(timestamp, null, true, agentInstanceContext);
                agentInstanceContext.AuditProvider.ScheduleAdd(
                    timeIntervalSize,
                    agentInstanceContext,
                    handle,
                    ScheduleObjectType.view,
                    factory.ViewName);
                agentInstanceContext.StatementContext.SchedulingService.Add(timeIntervalSize, handle, scheduleSlot);
                callbackScheduledTime = timeIntervalSize + timestamp;
            }

            // add data points to the window
            foreach (var newEvent in newData) {
                currentBatch.Add(newEvent);
            }

            // forward insert stream to child views
            viewUpdatedCollection?.Update(newData, null);

            // update child views
            if (Child != null) {
                agentInstanceContext.InstrumentationProvider.QViewIndicate(factory, newData, null);
                Child.Update(newData, null);
                agentInstanceContext.InstrumentationProvider.AViewIndicate();
            }

            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 15
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, factory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(factory, newData, oldData);

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

                DetermineOldestTimestamp();
            }

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

                    if (oldestTimestamp == null) {
                        oldestTimestamp = timestamp;
                    }
                    else {
                        var delta = timePeriodProvide.DeltaAddWReference(
                            oldestTimestamp.Value,
                            referenceTimestamp.Value,
                            null,
                            true,
                            agentInstanceContext);
                        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);
                viewUpdatedCollection?.Update(batchNewData, lastBatch);

                agentInstanceContext.InstrumentationProvider.QViewIndicate(factory, batchNewData, lastBatch);
                child.Update(batchNewData, lastBatch);
                agentInstanceContext.InstrumentationProvider.AViewIndicate();

                lastBatch = batchNewData;
                DetermineOldestTimestamp();
            }

            if (oldData != null && oldData.Length > 0) {
                viewUpdatedCollection?.Update(null, oldData);

                agentInstanceContext.InstrumentationProvider.QViewIndicate(factory, null, oldData);
                child.Update(null, oldData);
                agentInstanceContext.InstrumentationProvider.AViewIndicate();
            }

            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 16
0
 public override void Update(EventBean[] newData, EventBean[] oldData)
 {
     _buffer.Update(newData, oldData);
     UpdateChildren(newData, oldData);
 }
Ejemplo n.º 17
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _factory.ViewName, newData, oldData);
            }

            // we don't care about removed data from a prior view
            if ((newData == null) || (newData.Length == 0))
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewProcessIRStream();
                }
                return;
            }

            // If we have an empty window about to be filled for the first time, addSchedule a callback
            bool removeSchedule = false;
            bool addSchedule    = false;
            long timestamp      = _agentInstanceContext.StatementContext.SchedulingService.Time;

            if (!_currentBatch.IsEmpty())
            {
                // check if we need to reschedule
                long callbackTime = timestamp + _timeDeltaComputation.DeltaAdd(timestamp);
                if (callbackTime != _callbackScheduledTime)
                {
                    removeSchedule = true;
                    addSchedule    = true;
                }
            }
            else
            {
                addSchedule = true;
            }

            if (removeSchedule)
            {
                _agentInstanceContext.StatementContext.SchedulingService.Remove(_handle, _scheduleSlot);
            }
            if (addSchedule)
            {
                long timeIntervalSize = _timeDeltaComputation.DeltaAdd(timestamp);
                _agentInstanceContext.StatementContext.SchedulingService.Add(timeIntervalSize, _handle, _scheduleSlot);
                _callbackScheduledTime = timeIntervalSize + timestamp;
            }

            // add data points to the window
            foreach (EventBean newEvent in newData)
            {
                _currentBatch.Add(newEvent);
            }

            // forward insert stream to child views
            if (_viewUpdatedCollection != null)
            {
                _viewUpdatedCollection.Update(newData, null);
            }

            // update child views
            if (HasViews)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QViewIndicate(this, _factory.ViewName, newData, null);
                }
                UpdateChildren(newData, null);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewIndicate();
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 18
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            using (Instrument.With(
                       i => i.QViewProcessIRStream(this, _factory.ViewName, newData, oldData),
                       i => i.AViewProcessIRStream()))
            {
                // we don't care about removed data from a prior view
                if ((newData == null) || (newData.Length == 0))
                {
                    return;
                }

                // If we have an empty window about to be filled for the first time, addSchedule a callback
                bool removeSchedule = false;
                bool addSchedule    = false;
                long timestamp      = AgentInstanceContext.StatementContext.SchedulingService.Time;

                if (CurrentBatch.IsNotEmpty())
                {
                    // check if we need to reschedule
                    long callbackTime = timestamp + _timeDeltaComputation.DeltaMillisecondsAdd(timestamp);;
                    if (callbackTime != CallbackScheduledTime)
                    {
                        removeSchedule = true;
                        addSchedule    = true;
                    }
                }
                else
                {
                    addSchedule = true;
                }

                if (removeSchedule)
                {
                    AgentInstanceContext.StatementContext.SchedulingService.Remove(Handle, ScheduleSlot);
                }
                if (addSchedule)
                {
                    var msecIntervalSize = _timeDeltaComputation.DeltaMillisecondsAdd(timestamp);
                    AgentInstanceContext.StatementContext.SchedulingService.Add(msecIntervalSize, Handle, ScheduleSlot);
                    CallbackScheduledTime = msecIntervalSize + timestamp;
                }

                // add data points to the window
                foreach (EventBean newEvent in newData)
                {
                    CurrentBatch.Add(newEvent);
                }

                // forward insert stream to child views
                if (ViewUpdatedCollection != null)
                {
                    ViewUpdatedCollection.Update(newData, null);
                }

                // Update child views
                if (HasViews)
                {
                    Instrument.With(
                        i => i.QViewIndicate(this, _factory.ViewName, newData, null),
                        i => i.AViewIndicate(),
                        () => UpdateChildren(newData, null));
                }
            }
        }
Ejemplo n.º 19
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get()
                .QViewProcessIRStream(this, _externallyTimedWindowViewFactory.ViewName, newData, oldData);
            }
            long timestamp = -1;

            // add data points to the window
            // we don't care about removed data from a prior view
            if (newData != null)
            {
                for (int i = 0; i < newData.Length; i++)
                {
                    timestamp = GetLongValue(newData[i]);
                    _timeWindow.Add(timestamp, newData[i]);
                }
            }

            // Remove from the window any events that have an older timestamp then the last event's timestamp
            ArrayDeque <EventBean> expired = null;

            if (timestamp != -1)
            {
                expired =
                    _timeWindow.ExpireEvents(timestamp - _timeDeltaComputation.DeltaMillisecondsSubtract(timestamp) + 1);
            }

            EventBean[] oldDataUpdate = null;
            if ((expired != null) && (!expired.IsEmpty()))
            {
                oldDataUpdate = expired.ToArray();
            }

            if ((oldData != null) && (AgentInstanceViewFactoryContext.IsRemoveStream))
            {
                foreach (EventBean anOldData in oldData)
                {
                    _timeWindow.Remove(anOldData);
                }

                if (oldDataUpdate == null)
                {
                    oldDataUpdate = oldData;
                }
                else
                {
                    oldDataUpdate = CollectionUtil.AddArrayWithSetSemantics(oldData, oldDataUpdate);
                }
            }

            if (_viewUpdatedCollection != null)
            {
                _viewUpdatedCollection.Update(newData, oldDataUpdate);
            }

            // If there are child views, fireStatementStopped update method
            if (HasViews)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QViewIndicate(this, _externallyTimedWindowViewFactory.ViewName, newData, oldDataUpdate);
                }
                UpdateChildren(newData, oldDataUpdate);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewIndicate();
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 20
0
        // Called based on schedule evaluation registered when a variable changes (new data is null).
        // Called when new data arrives.
        public void Expire(int numEventsInBatch)
        {
            if (numEventsInBatch == Window.Count || numEventsInBatch == -1)
            {
                var batchNewData = Window.ToArray();
                if (ViewUpdatedCollection != null)
                {
                    ViewUpdatedCollection.Update(batchNewData, LastBatch);
                }

                // post
                if (batchNewData != null || LastBatch != null)
                {
                    Instrument.With(
                        i => i.QViewIndicate(this, _dataWindowViewFactory.ViewName, batchNewData, LastBatch),
                        i => i.AViewIndicate(),
                        () => UpdateChildren(batchNewData, LastBatch));
                }

                // clear
                Window.Clear();
                LastBatch = batchNewData;
                if (AggregationService != null)
                {
                    AggregationService.ClearResults(AgentInstanceContext);
                }
                OldestEvent = null;
                NewestEvent = null;
            }
            else
            {
                var batchNewData = Window.Take(numEventsInBatch).ToArray();
                unchecked
                {
                    for (int ii = 0; ii < batchNewData.Length; ii++)
                    {
                        Window.Remove(batchNewData[ii]);
                    }
                }

                if (ViewUpdatedCollection != null)
                {
                    ViewUpdatedCollection.Update(batchNewData, LastBatch);
                }

                // post
                if (batchNewData != null || LastBatch != null)
                {
                    Instrument.With(
                        i => i.QViewIndicate(this, _dataWindowViewFactory.ViewName, batchNewData, LastBatch),
                        i => i.AViewIndicate(),
                        () => UpdateChildren(batchNewData, LastBatch));
                }

                // clear
                LastBatch = batchNewData;
                if (AggregationService != null)
                {
                    AggregationService.ApplyLeave(batchNewData, null, AgentInstanceContext);
                }
                OldestEvent = Window.FirstOrDefault();
            }
        }