/// <summary> /// Gets a log reader capable of reading records between the specified positions /// </summary> internal PhysicalLogReader GetPhysicalLogReader( ulong startingRecordPosition, ulong endingRecordPosition, long startingLsn, string readerName, LogReaderType readerType) { PhysicalLogReader logReader; do { logReader = new PhysicalLogReader( this, startingRecordPosition, endingRecordPosition, startingLsn, readerName, readerType); if (logReader.IsValid) { break; } logReader.Dispose(); } while (true); return(logReader); }
internal string GetEarliestLogReaderName(out LogReaderType readerType) { lock (this.readersLock) { readerType = this.earliestLogReader.ReaderType; return(this.earliestLogReader.ReaderName); } }
internal LogReaderRange( long fullCopyStartingLsn, ulong startingRecordPosition, string readerName, LogReaderType readerType) { this.startingRecordPosition = startingRecordPosition; this.referenceCount = 1; this.ReaderName = readerName; this.logReaderType = readerType; this.fullCopyStartingLsn = fullCopyStartingLsn; }
internal bool AddLogReader( long startingLsn, ulong startingRecordPosition, ulong endingRecordPosition, string readerName, LogReaderType readerType) { Utility.Assert( (startingRecordPosition == 0) || (this.LogHeadRecordPosition <= startingRecordPosition), "(startingRecordPosition == 0) || (this.CurrentLogHeadPosition <= startingRecordPosition), start record position :{0}. LogHeadRecordPosition: {1}", startingRecordPosition, this.LogHeadRecordPosition); FabricEvents.Events.LogManager( this.Tracer.Type, "AddLogReader: Adding Log Reader with StartingRecordPosition: " + startingRecordPosition + " EndingRecordPosition: " + endingRecordPosition + " ReaderName: " + readerName); lock (this.readersLock) { if (this.LogHeadRecordPosition > startingRecordPosition) { return(false); } int i; LogReaderRange readerRange; for (i = 0; i < this.logReaderRanges.Count; i++) { readerRange = this.logReaderRanges[i]; if (startingRecordPosition < readerRange.StartingRecordPosition) { break; } if (readerRange.StartingRecordPosition == startingRecordPosition) { readerRange.AddRef(); // If a fullcopy reader comes in at the same position of a non-full copy reader, over-write the type as full-copy reader // have significance when determining safe LSN to delete state providers if (readerType == LogReaderType.FullCopy) { readerRange.ReaderType = LogReaderType.FullCopy; } return(true); } } readerRange = new LogReaderRange(startingLsn, startingRecordPosition, readerName, readerType); this.logReaderRanges.Insert(i, readerRange); if (i == 0) { this.earliestLogReader = this.logReaderRanges[0]; } } Utility.Assert( (endingRecordPosition == long.MaxValue) || (this.CurrentLogTailPosition >= endingRecordPosition), @"(endingRecordPosition == Int64.MaxValue) || (this.CurrentLogTailPosition >= endingRecordPosition), EndingRecordPosition: {0}", endingRecordPosition); return(true); }