public override void Update( EventBean[] newData, EventBean[] oldData) { agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, factory); agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(factory, newData, oldData); // add data points to the window if (newData != null) { foreach (var newEvent in newData) { var pair = new ExpressionWindowTimestampEventPair(agentInstanceContext.TimeProvider.Time, newEvent); window.Add(pair); InternalHandleAdd(pair); } aggregationService?.ApplyEnter(newData, null, agentInstanceContext); } if (oldData != null) { window.RemoveWhere( pair => oldData.Any(anOldData => pair.TheEvent == anOldData), InternalHandleRemoved); aggregationService?.ApplyLeave(oldData, null, agentInstanceContext); } // expire events Expire(newData, oldData); agentInstanceContext.InstrumentationProvider.AViewProcessIRStream(); }
public override void Update(EventBean[] newData, EventBean[] oldData) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewProcessIRStream(this, _dataWindowViewFactory.ViewName, newData, oldData); } // add data points to the window if (newData != null) { foreach (EventBean newEvent in newData) { var pair = new ExpressionWindowTimestampEventPair(AgentInstanceContext.TimeProvider.Time, newEvent); _window.Add(pair); InternalHandleAdd(pair); } if (AggregationService != null) { AggregationService.ApplyEnter(newData, null, AgentInstanceContext); } } if (oldData != null) { _window.RemoveWhere( pair => oldData.Any(anOldData => pair.TheEvent == anOldData), pair => InternalHandleRemoved(pair)); if (AggregationService != null) { AggregationService.ApplyLeave(oldData, null, AgentInstanceContext); } } // expire events Expire(newData, oldData); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewProcessIRStream(); } }
private void ProcessDispatches( ArrayDeque<NamedWindowConsumerLatch> dispatches, ArrayDeque<NamedWindowConsumerLatch> work, IDictionary<EPStatementAgentInstanceHandle, object> dispatchesPerStmt) { if (dispatches.Count == 1) { var latch = dispatches.First; try { latch.Await(); var newData = latch.DeltaData.NewData; var oldData = latch.DeltaData.OldData; if (metricReportingService.IsMetricsReportingEnabled) { foreach (var entry in latch.DispatchTo) { var handle = entry.Key; if (handle.StatementHandle.MetricsHandle.IsEnabled) { var performanceMetric = PerformanceMetricsHelper.Call( () => ProcessHandle(handle, entry.Value, newData, oldData), 1); metricReportingService.AccountTime( handle.StatementHandle.MetricsHandle, performanceMetric, performanceMetric.NumInput); } else { ProcessHandle(handle, entry.Value, newData, oldData); } if (isPrioritized && handle.IsPreemptive) { break; } } } else { foreach (var entry in latch.DispatchTo) { var handle = entry.Key; ProcessHandle(handle, entry.Value, newData, oldData); if (isPrioritized && handle.IsPreemptive) { break; } } } } finally { latch.Done(); } return; } // Multiple different-result dispatches to same or different statements are needed in two situations: // a) an event comes in, triggers two insert-into statements inserting into the same named window and the window produces 2 results // b) a time batch is grouped in the named window, and a timer fires for both groups at the same time producing more then one result // c) two on-merge/update/delete statements fire for the same arriving event each updating the named window // Most likely all dispatches go to different statements since most statements are not joins of // named windows that produce results at the same time. Therefore sort by statement handle. // We need to process in N-element chains to preserve dispatches that are next to each other for the same thread. while (!dispatches.IsEmpty()) { // the first latch always gets awaited var first = dispatches.RemoveFirst(); first.Await(); work.Add(first); // determine which further latches are in this chain and add these, skipping await for any latches in the chain dispatches.RemoveWhere( (next, continuation) => { var result = next.Earlier == null || work.Contains(next.Earlier); continuation.Value = !result; return result; }, work.Add); #if false var enumerator = dispatches.GetEnumerator(); while (enumerator.MoveNext()) { var next = enumerator.Current; var earlier = next.Earlier; if (earlier == null || work.Contains(earlier)) { work.Add(next); enumerator.Remove(); } else { break; } } #endif ProcessDispatches(work, dispatchesPerStmt); } }
private void ProcessDispatches( ArrayDeque <NamedWindowConsumerLatch> dispatches, ArrayDeque <NamedWindowConsumerLatch> work, IDictionary <EPStatementAgentInstanceHandle, Object> dispatchesPerStmt) { if (dispatches.Count == 1) { var latch = dispatches.First(); try { latch.Await(); var newData = latch.DeltaData.NewData; var oldData = latch.DeltaData.OldData; foreach (var entry in latch.DispatchTo) { var handle = entry.Key; handle.StatementHandle.MetricsHandle.Call( _metricReportingService.PerformanceCollector, () => { ProcessHandle(handle, entry.Value, newData, oldData); }); if ((_isPrioritized) && (handle.IsPreemptive)) { break; } } } finally { latch.Done(); } return; } // Multiple different-result dispatches to same or different statements are needed in two situations: // a) an event comes in, triggers two insert-into statements inserting into the same named window and the window produces 2 results // b) a time batch is grouped in the named window, and a timer fires for both groups at the same time producing more then one result // c) two on-merge/update/delete statements fire for the same arriving event each updating the named window // Most likely all dispatches go to different statements since most statements are not joins of // named windows that produce results at the same time. Therefore sort by statement handle. // We need to process in N-element chains to preserve dispatches that are next to each other for the same thread. while (!dispatches.IsEmpty()) { // the first latch always gets awaited var first = dispatches.RemoveFirst(); first.Await(); work.Add(first); // determine which further latches are in this chain and // add these, skipping await for any latches in the chain dispatches.RemoveWhere( (next, continuation) => { NamedWindowConsumerLatch earlier = next.Earlier; if (earlier == null || work.Contains(earlier)) { work.Add(next); return(true); } else { continuation.Value = false; return(false); } }); ProcessDispatches(work, dispatchesPerStmt); } }