Example #1
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();
        }
Example #2
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));
                }
            });
        }
Example #3
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, timeWindowViewFactory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(timeWindowViewFactory, newData, oldData);
            var timestamp = agentInstanceContext.StatementContext.SchedulingService.Time;

            if (oldData != null) {
                for (var 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 millisecondsBeforeExpiry
                if (timeWindow.IsEmpty()) {
                    var current = agentInstanceContext.StatementContext.SchedulingService.Time;
                    ScheduleCallback(timePeriodProvide.DeltaAdd(current, null, true, agentInstanceContext));
                }

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

                ViewUpdatedCollection?.Update(newData, null);
            }

            // update child views
            agentInstanceContext.InstrumentationProvider.QViewIndicate(timeWindowViewFactory, newData, oldData);
            Child.Update(newData, oldData);
            agentInstanceContext.InstrumentationProvider.AViewIndicate();

            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Example #4
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();
            }
        }