LiveIndexedMonitor RegisterOneLog(RawLogFileMonitorOccurence fileOccurrence, bool newOccurrence, long streamOffset, IMulticastLogEntry log) { Debug.Assert(fileOccurrence.MonitorId == log.MonitorId); Debug.Assert(!newOccurrence || (fileOccurrence.FirstEntryTime == log.LogTime && fileOccurrence.LastEntryTime == log.LogTime)); LiveIndexedMonitor m = _monitors.GetOrAdd(log.MonitorId, id => new LiveIndexedMonitor(id, this)); m.Register(fileOccurrence, newOccurrence, streamOffset, log); return(m); }
internal Monitor(LiveIndexedMonitor m) { _monitorId = m.MonitorId; _files = m._files.OrderBy(f => f.FirstEntryTime).ToArray(); _firstEntryTime = m._firstEntryTime; _firstDepth = m._firstDepth; _lastEntryTime = m._lastEntryTime; _lastDepth = m._lastDepth; _tags = m._tags != null?m._tags.OrderByDescending(k => k.Key).ToArray() : Util.Array.Empty <KeyValuePair <CKTrait, int> >(); }
LiveIndexedMonitor RegisterOneLog(RawLogFileMonitorOccurence fileOccurrence, bool newOccurrence, long streamOffset, IMulticastLogEntry log) { Debug.Assert(fileOccurrence.MonitorId == log.MonitorId); Debug.Assert(!newOccurrence || (fileOccurrence.FirstEntryTime == log.LogTime && fileOccurrence.LastEntryTime == log.LogTime)); // This is required to detect the fact that it's this call that created the final monitor (the GetOrAdd may call the // value factory but another thread may have already set it) and we must ensure that the OnNewLiveMonitor is // called once and only once per new live monitor. LiveIndexedMonitor?proposal = null; LiveIndexedMonitor m = _monitors.GetOrAdd(log.MonitorId, id => proposal = new LiveIndexedMonitor(id)); m.Register(fileOccurrence, newOccurrence, streamOffset, log); if (proposal == m) { OnLiveMonitorAppeared?.Invoke(m); } return(m); }