private void HandleEvent( EventBean theEvent, bool isNew) { var groupByValuesKey = GetGroupKey(theEvent); // Get child views that belong to this group-by value combination var subViews = subViewPerKey.Get(groupByValuesKey); // If this is a new group-by value, the list of subviews is null and we need to make clone sub-views if (subViews == null) { var subview = GroupByViewUtil.MakeSubView(this, groupByValuesKey); var currentTime = AgentInstanceContext.StatementContext.TimeProvider.Time; subViews = new GroupByViewAgedEntry(subview, currentTime); subViewPerKey.Put(groupByValuesKey, subViews); } else { subViews.SetLastUpdateTime(AgentInstanceContext.StatementContext.TimeProvider.Time); } // Construct a pair of lists to hold the events for the grouped value if not already there var pair = groupedEvents.Get(subViews); if (pair == null) { pair = new Pair<object, object>(null, null); groupedEvents.Put(subViews, pair); } // Add event to a child view event list for later child update that includes new and old events if (isNew) { pair.First = GroupByViewImpl.AddUpgradeToDequeIfPopulated(pair.First, theEvent); } else { pair.Second = GroupByViewImpl.AddUpgradeToDequeIfPopulated(pair.Second, theEvent); } }
public void VisitViewContainer(ViewDataVisitorContained viewDataVisitor) { viewDataVisitor.VisitPrimary(GroupByViewImpl.VIEWNAME, subViewPerKey.Count); foreach (var entry in subViewPerKey) { GroupByViewImpl.VisitView(viewDataVisitor, entry.Key, entry.Value.Subview); } }
public override void Update( EventBean[] newData, EventBean[] oldData) { var aiContext = AgentInstanceContext.AgentInstanceContext; aiContext.AuditProvider.View(newData, oldData, aiContext, ViewFactory); aiContext.InstrumentationProvider.QViewProcessIRStream(ViewFactory, newData, oldData); var currentTime = AgentInstanceContext.TimeProvider.Time; if (nextSweepTime == null || nextSweepTime <= currentTime) { if (ExecutionPathDebugLog.IsDebugEnabled && Log.IsDebugEnabled) { Log.Debug( "Reclaiming groups older then " + ViewFactory.ReclaimMaxAge + " msec and every " + ViewFactory.ReclaimFrequency + "msec in frequency"); } nextSweepTime = currentTime + ViewFactory.ReclaimFrequency; Sweep(currentTime); } // Algorithm for single new event if (newData != null && oldData == null && newData.Length == 1) { var theEvent = newData[0]; var groupByValuesKey = GetGroupKey(theEvent); // Get child views that belong to this group-by value combination var subView = subViewPerKey.Get(groupByValuesKey); // If this is a new group-by value, the list of subviews is null and we need to make clone sub-views if (subView == null) { var subview = GroupByViewUtil.MakeSubView(this, groupByValuesKey); subView = new GroupByViewAgedEntry(subview, currentTime); subViewPerKey.Put(groupByValuesKey, subView); } else { subView.SetLastUpdateTime(currentTime); } AgentInstanceContext.InstrumentationProvider.QViewIndicate(ViewFactory, newData, null); subView.Subview.Update(newData, null); AgentInstanceContext.InstrumentationProvider.AViewIndicate(); } else { // Algorithm for dispatching multiple events if (newData != null) { foreach (var newValue in newData) { HandleEvent(newValue, true); } } if (oldData != null) { foreach (var oldValue in oldData) { HandleEvent(oldValue, false); } } // Update child views foreach (var entry in groupedEvents) { var newEvents = GroupByViewImpl.ConvertToArray(entry.Value.First); var oldEvents = GroupByViewImpl.ConvertToArray(entry.Value.Second); AgentInstanceContext.InstrumentationProvider.QViewIndicate(ViewFactory, newEvents, oldEvents); entry.Key.Subview.Update(newEvents, oldEvents); AgentInstanceContext.InstrumentationProvider.AViewIndicate(); } groupedEvents.Clear(); } AgentInstanceContext.InstrumentationProvider.AViewProcessIRStream(); }