/// <summary> /// This method removes (expires) objects from the window and schedules a new callback for the /// time when the next oldest message would expire from the window. /// </summary> public void Expire() { long current = _agentInstanceContext.StatementContext.SchedulingService.Time; long expireBeforeTimestamp = current - _timeDeltaComputation.DeltaSubtract(current) + 1; // Remove from the timeWindow any events that have an older or timestamp then the given timestamp // The window : from X to (X - timeDeltaComputation + 1) var expired = _timeWindow.ExpireEvents(expireBeforeTimestamp); // If there are child views, fireStatementStopped Update method if (HasViews) { if ((expired != null) && (expired.IsNotEmpty())) { EventBean[] oldEvents = expired.ToArray(); if (_viewUpdatedCollection != null) { _viewUpdatedCollection.Update(null, oldEvents); } Instrument.With( i => i.QViewIndicate(this, _timeWindowViewFactory.ViewName, null, oldEvents), i => i.AViewIndicate(), () => UpdateChildren(null, oldEvents)); } } ScheduleExpiryCallback(); }
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(); }
/// <summary> /// This method removes (expires) objects from the window and schedules a new callback for the /// time when the next oldest message would expire from the window. /// </summary> private void Expire() { var current = agentInstanceContext.StatementContext.SchedulingService.Time; var expireBeforeTimestamp = current - timePeriodProvide.DeltaSubtract(current, null, true, agentInstanceContext) + 1; // Remove from the timeWindow any events that have an older or timestamp then the given timestamp // The window : from X to (X - millisecondsBeforeExpiry + 1) var expired = timeWindow.ExpireEvents(expireBeforeTimestamp); // If there are child views, fireStatementStopped update method if (Child != null) { if (expired != null && !expired.IsEmpty()) { EventBean[] oldEvents = expired.ToArray(); ViewUpdatedCollection?.Update(null, oldEvents); agentInstanceContext.InstrumentationProvider.QViewIndicate(timeWindowViewFactory, null, oldEvents); Child.Update(null, oldEvents); agentInstanceContext.InstrumentationProvider.AViewIndicate(); } } ScheduleExpiryCallback(); }
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(); } }