Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the PhysicalLogReader class.
        /// </summary>
        /// <param name="logManager">The log manager.</param>
        /// <param name="startingRecordPosition">Stream position to start reading.</param>
        /// <param name="endingRecordPosition">Stream position of the start of the last record that will be read.</param>
        /// <param name="startingLsn">Logical sequence number of the first record.</param>
        /// <param name="readerName">Name of the reader that will be used in tracing.</param>
        /// <param name="readerType">Type of the reader.</param>
        /// <remarks>
        /// Note that ending record position is INCLUSIVE: the last record will be read.
        /// Starting logical sequence number is used to decide the when an lsn is safe (will not be undone or redone).
        /// </remarks>
        public PhysicalLogReader(
            LogManager logManager,
            ulong startingRecordPosition,
            ulong endingRecordPosition,
            long startingLsn,
            string readerName,
            LogManager.LogReaderType readerType)
        {
            this.logManager             = logManager;
            this.readStream             = null;
            this.startingRecordPosition = startingRecordPosition;
            this.startingLsn            = startingLsn;
            this.endingRecordPosition   = endingRecordPosition;
            Utility.Assert(
                startingRecordPosition <= endingRecordPosition,
                "startingRecordPosition <= endingRecordPosition");
            this.isValid = logManager.AddLogReader(
                startingLsn,
                startingRecordPosition,
                endingRecordPosition,
                readerName,
                readerType);
            this.isDisposed = false;

            this.startingRecord = LogRecord.InvalidLogRecord;
            this.endRecord      = LogRecord.InvalidLogRecord;
        }
Beispiel #2
0
        public IAsyncEnumerator <LogRecord> GetLogRecords(string readerName, LogManager.LogReaderType readerType)
        {
            var logRecords = new LogRecords(
                this.logManager,
                this.startingRecordPosition,
                this.endingRecordPosition,
                this.startingLsn,
                readerName,
                readerType);

            return(logRecords);
        }
Beispiel #3
0
        internal void MoveStartingRecordPosition(
            long startingLsn,
            ulong newStartingRecordPosition,
            string readerName,
            LogManager.LogReaderType readerType)
        {
            if (this.isValid)
            {
                var isValid = this.logManager.AddLogReader(
                    startingLsn,
                    newStartingRecordPosition,
                    this.endingRecordPosition,
                    readerName,
                    readerType);
                Utility.Assert(isValid, "isValid == true");
                this.logManager.RemoveLogReader(this.startingRecordPosition);
            }

            this.startingRecordPosition = newStartingRecordPosition;
            this.startingLsn            = startingLsn;
            this.startingRecord         = LogRecord.InvalidLogRecord;
        }
Beispiel #4
0
 /// <summary>
 /// Asynchronous enumerator for log records.
 /// </summary>
 /// <param name="logManager">The source log manager.</param>
 /// <param name="enumerationStartingPosition">Inclusive starting position.</param>
 /// <param name="enumerationEndingPosition">Inclusive ending position: record at this starting position will be read.</param>
 /// <param name="enumerationStartedAtLsn">Lsn of the first record. Used for determining what record is safe: no redo or undo.</param>
 /// <param name="readerName">Name of the reader for tracing.</param>
 /// <param name="readerType">Type of the reader.</param>
 /// <remarks>
 /// enumerationStartingPosition and enumerationEndingPosition is inclusive: the last record at enumerationEndingPosition position will be read.
 /// </remarks>
 internal LogRecords(
     LogManager logManager,
     ulong enumerationStartingPosition,
     ulong enumerationEndingPosition,
     long enumerationStartedAtLsn,
     string readerName,
     LogManager.LogReaderType readerType)
 {
     this.readerName = readerName;
     this.readerType = readerType;
     this.logManager = logManager;
     this.enumerationEndingPosition = enumerationEndingPosition;
     this.enumerationStartedAtLsn   = enumerationStartedAtLsn;
     this.logManager.AddLogReader(
         enumerationStartedAtLsn,
         enumerationStartingPosition,
         enumerationEndingPosition,
         readerName,
         readerType);
     this.readStream = logManager.CreateReaderStream();
     this.Init(enumerationStartingPosition);
     this.logManager.SetSequentialAccessReadSize(this.readStream, LogManager.ReadAheadBytesForSequentialStream);
 }