/// <summary> /// Stores the local flow cache to the global flow table. /// </summary> /// <param name="flowTracker">A flow tracker object that contains a local flow cache.</param> private void PopulateFlowTable(IFlowTracker <FlowData> flowTracker, ProgressRecord progressRecord) { var flowCache = CacheFactory.GetOrCreateFlowCache(m_ignite, FlowCacheName); using (var dataStreamer = m_ignite.GetDataStreamer <FlowKey, FlowData>(flowCache.Name)) { dataStreamer.AllowOverwrite = true; var updateProcessor = new MergePacketFlowProcessor(); dataStreamer.Receiver = new FlowStreamVisitor(updateProcessor); progressRecord.TotalFlows = flowTracker.FlowTable.Count; var flowCount = 0; foreach (var flow in flowTracker.FlowTable) { flow.Value.FlowUid = FlowUidGenerator.NewUid(flow.Key, flow.Value.FirstSeen); dataStreamer.AddData(flow.Key, flow.Value); if (++flowCount % ProgressFlowBatch == 0) { progressRecord.CompletedFlows += ProgressFlowBatch; Progress?.Report(progressRecord); } } progressRecord.CompletedFlows += flowCount % ProgressFlowBatch; Progress?.Report(progressRecord); dataStreamer.Flush(); } }
public FlowData Process(IMutableCacheEntry <FlowKey, FlowData> entry, FlowData arg) { if (entry.Exists) { var flowUid = FlowUidGenerator.NewUid(entry.Key, Math.Min(entry.Value.FirstSeen, arg.FirstSeen)); entry.Value = Merge(entry.Value, arg, flowUid.ToString()); } else { entry.Value = arg; } return(null); }