private void HandleEvent( EventBean theEvent, bool isNew) { 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) { subView = GroupByViewUtil.MakeSubView(this, groupByValuesKey); subViewPerKey.Put(groupByValuesKey, subView); } // Construct a pair of lists to hold the events for the grouped value if not already there Pair<object, object> pair = groupedEvents.Get(subView); if (pair == null) { pair = new Pair<object, object>(null, null); groupedEvents.Put(subView, pair); } // Add event to a child view event list for later child update that includes new and old events if (isNew) { pair.First = AddUpgradeToDequeIfPopulated(pair.First, theEvent); } else { pair.Second = AddUpgradeToDequeIfPopulated(pair.Second, theEvent); } }
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 override void Update( EventBean[] newData, EventBean[] oldData) { AgentInstanceContext aiContext = agentInstanceContext.AgentInstanceContext; aiContext.AuditProvider.View(newData, oldData, aiContext, ViewFactory); aiContext.InstrumentationProvider.QViewProcessIRStream(ViewFactory, newData, oldData); // Algorithm for single new event if (newData != null && oldData == null && newData.Length == 1) { var theEvent = newData[0]; var newDataToPost = new EventBean[] {theEvent}; 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) { subView = GroupByViewUtil.MakeSubView(this, groupByValuesKey); subViewPerKey.Put(groupByValuesKey, subView); } agentInstanceContext.InstrumentationProvider.QViewIndicate(ViewFactory, newDataToPost, null); subView.Update(newDataToPost, 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 (KeyValuePair<View, Pair<object, object>> entry in groupedEvents) { var newEvents = ConvertToArray(entry.Value.First); var oldEvents = ConvertToArray(entry.Value.Second); agentInstanceContext.InstrumentationProvider.QViewIndicate(ViewFactory, newEvents, oldEvents); entry.Key.Update(newEvents, oldEvents); agentInstanceContext.InstrumentationProvider.AViewIndicate(); } groupedEvents.Clear(); } agentInstanceContext.InstrumentationProvider.AViewProcessIRStream(); }
private void Sweep(long currentTime) { var removed = new ArrayDeque<object>(); foreach (var entry in subViewPerKey) { var age = currentTime - entry.Value.LastUpdateTime; if (age > ViewFactory.ReclaimMaxAge) { removed.Add(entry.Key); } } foreach (var key in removed) { var entry = subViewPerKey.Delete(key); GroupByViewUtil.RemoveSubview( entry.Subview, new AgentInstanceStopServices(AgentInstanceContext.AgentInstanceContext)); } }
public void Stop(AgentInstanceStopServices services) { foreach (KeyValuePair<object, View> entry in subViewPerKey) { GroupByViewUtil.RemoveSubview(entry.Value, services); } }
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(); }
public void Stop(AgentInstanceStopServices services) { foreach (var entry in subViewPerKey) { GroupByViewUtil.RemoveSubview(entry.Value.Subview, services); } }