internal RawLogFileMonitorOccurence(RawLogFile f, string monitorId, long streamOffset)
 {
     LogFile        = f;
     MonitorId      = monitorId;
     FirstOffset    = streamOffset;
     FirstEntryTime = DateTimeStamp.MaxValue;
     LastEntryTime  = DateTimeStamp.MinValue;
 }
        /// <summary>
        /// Adds a file to this reader. This is thread safe (can be called from any thread at any time).
        /// </summary>
        /// <param name="filePath">The path of the file to add.</param>
        /// <param name="newFileIndex">True if the file has actually been added, false if it was already added.</param>
        /// <returns>The RawLogFile object (newly created or already existing).</returns>
        public RawLogFile Add(string filePath, out bool newFileIndex)
        {
            newFileIndex = false;
            filePath     = FileUtil.NormalizePathSeparator(filePath, false);
            _lockWriteRead.EnterReadLock();
            RawLogFile f = _files.GetOrAdd(filePath, fileName => new RawLogFile(fileName));
            var        l = f.InitializerLock;

            if (l != null)
            {
                lock ( l )
                {
                    if (f.InitializerLock != null)
                    {
                        newFileIndex = true;
                        f.Initialize(this);
                        f.InitializerLock = null;
                    }
                }
            }
            if (newFileIndex)
            {
                lock ( _globalInfoLock )
                {
                    if (_globalFirstEntryTime > f.FirstEntryTime.TimeUtc)
                    {
                        _globalFirstEntryTime = f.FirstEntryTime.TimeUtc;
                    }
                    if (_globalLastEntryTime < f.LastEntryTime.TimeUtc)
                    {
                        _globalLastEntryTime = f.LastEntryTime.TimeUtc;
                    }
                }
            }
            _lockWriteRead.ExitReadLock();
            return(f);
        }
Exemple #3
0
 internal RawLogFileMonitorOccurence( RawLogFile f, Guid monitorId, long streamOffset )
 {
     LogFile = f;
     MonitorId = monitorId;
     FirstOffset = streamOffset;
     FirstEntryTime = DateTimeStamp.MaxValue;
     LastEntryTime = DateTimeStamp.MinValue;
 }