Esempio n. 1
0
 internal void Register( RawLogFileMonitorOccurence fileOccurrence, bool newOccurrence, long streamOffset, IMulticastLogEntry log )
 {
     lock( _files )
     {
         Debug.Assert( newOccurrence == !_files.Contains( fileOccurrence ) ); 
         if( newOccurrence ) _files.Add( fileOccurrence );
         if( _firstEntryTime > log.LogTime )
         {
             _firstEntryTime = log.LogTime;
             _firstDepth = log.GroupDepth;
         }
         if( _lastEntryTime < log.LogTime )
         {
             _lastEntryTime = log.LogTime;
             _lastDepth = log.GroupDepth;
         }
         if( !log.Tags.IsEmpty )
         {
             if( _tags == null )
             {
                 _tags = new Dictionary<CKTrait, int>();
                 foreach( var t in log.Tags.AtomicTraits ) _tags.Add( t, 1 );
             }
             else
             {
                 foreach( var t in log.Tags.AtomicTraits )
                 {
                     int count;
                     _tags.TryGetValue( t, out count );
                     _tags[t] = count + 1;
                 }
             }
         }
     }
 }
 public OneLogReader(RawLogFileMonitorOccurence file, long offset)
 {
     _reader = file.CreateFilteredReader(offset);
     _reader.MoveNext();
     FirstGroupDepth = _reader.CurrentMulticast.GroupDepth;
     Head            = _reader.CurrentMulticastWithOffset;
 }
 public OneLogReader(RawLogFileMonitorOccurence file, DateTimeStamp firstLogTime)
 {
     File            = file;
     _reader         = file.CreateFilteredReaderAndMoveTo(firstLogTime);
     FirstGroupDepth = _reader.CurrentMulticast.GroupDepth;
     Head            = _reader.CurrentMulticastWithOffset;
 }
Esempio n. 4
0
 OneLogReader(RawLogFileMonitorOccurence file, LogReader positioned)
 {
     File    = file;
     _reader = positioned;
     Debug.Assert(_reader.CurrentMulticast != null);
     FirstGroupDepth = _reader.CurrentMulticast.GroupDepth;
     Head            = _reader.CurrentMulticastWithOffset;
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 internal void Register(RawLogFileMonitorOccurence fileOccurrence, bool newOccurrence, long streamOffset, IMulticastLogEntry log)
 {
     lock ( _files )
     {
         Debug.Assert(newOccurrence == !_files.Contains(fileOccurrence));
         if (newOccurrence)
         {
             _files.Add(fileOccurrence);
         }
         if (_firstEntryTime > log.LogTime)
         {
             _firstEntryTime = log.LogTime;
             _firstDepth     = log.GroupDepth;
         }
         if (_lastEntryTime < log.LogTime)
         {
             _lastEntryTime = log.LogTime;
             _lastDepth     = log.GroupDepth;
         }
         if (!log.Tags.IsEmpty)
         {
             if (_tags == null)
             {
                 _tags = new Dictionary <CKTrait, int>();
                 foreach (var t in log.Tags.AtomicTraits)
                 {
                     HandleIdentityCardTag(log, t);
                     _tags.Add(t, 1);
                 }
             }
             else
             {
                 foreach (var t in log.Tags.AtomicTraits)
                 {
                     HandleIdentityCardTag(log, t);
                     _tags.TryGetValue(t, out var count);
                     _tags[t] = count + 1;
                 }
             }
         }
     }
 }
Esempio n. 8
0
            void UpdateMonitor(MultiLogReader reader, long streamOffset, Dictionary <string, RawLogFileMonitorOccurence> monitorOccurrence, List <RawLogFileMonitorOccurence> monitorOccurenceList, IMulticastLogEntry log)
            {
                bool newOccurrence = false;

                if (!monitorOccurrence.TryGetValue(log.MonitorId, out RawLogFileMonitorOccurence? occ))
                {
                    occ = new RawLogFileMonitorOccurence(this, log.MonitorId, streamOffset);
                    monitorOccurrence.Add(log.MonitorId, occ);
                    monitorOccurenceList.Add(occ);
                    newOccurrence = true;
                }
                if (occ.FirstEntryTime > log.LogTime)
                {
                    occ.FirstEntryTime = log.LogTime;
                }
                if (occ.LastEntryTime < log.LogTime)
                {
                    occ.LastEntryTime = log.LogTime;
                }
                occ.LastOffset = streamOffset;
                reader.RegisterOneLog(occ, newOccurrence, streamOffset, log);
            }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 void UpdateMonitor( MultiLogReader reader, long streamOffset, Dictionary<Guid, RawLogFileMonitorOccurence> monitorOccurrence, List<RawLogFileMonitorOccurence> monitorOccurenceList, IMulticastLogEntry log )
 {
     bool newOccurrence = false;
     RawLogFileMonitorOccurence occ;
     if( !monitorOccurrence.TryGetValue( log.MonitorId, out occ ) )
     {
         occ = new RawLogFileMonitorOccurence( this, log.MonitorId, streamOffset );
         monitorOccurrence.Add( log.MonitorId, occ );
         monitorOccurenceList.Add( occ );
         newOccurrence = true;
     }
     if( occ.FirstEntryTime > log.LogTime ) occ.FirstEntryTime = log.LogTime;
     if( occ.LastEntryTime < log.LogTime ) occ.LastEntryTime = log.LogTime;
     occ.LastOffset = streamOffset;
     reader.RegisterOneLog( occ, newOccurrence, streamOffset, log );
 }
Esempio n. 11
0
 public OneLogReader(RawLogFileMonitorOccurence file, long offset)
     : this(file, file.CreateFilteredReaderAndMoveTo(offset))
 {
 }
Esempio n. 12
0
 public OneLogReader(RawLogFileMonitorOccurence file, DateTimeStamp firstLogTime)
     : this(file, file.CreateFilteredReaderAndMoveTo(firstLogTime))
 {
 }