Beispiel #1
0
        public void CanSetDate()
        {
            var page = _fileManager.ResolvePage();

            var block = new Block(RandomFilename, 0);

            page.Read(block);
            page.SetDate(0, new DateTime(2020, 1, 1));
            page.Write(block);

            _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6);
            var buffer = _bufferManager.Pin(block);

            var lsn = _recoveryManager.SetDate(buffer, 0, new DateTime(2000, 1, 1));

            _logManager.Flush(lsn);

            _bufferManager.Unpin(buffer);
            _bufferManager.FlushAll(6);

            var enumerator = _logManager.GetEnumerator();

            var record        = enumerator.Current;
            var setBoolRecord = new SetDateRecord(_logManager, _bufferManager, record);

            Assert.AreEqual(LogRecordType.SetDate, setBoolRecord.Type);
            Assert.AreEqual(0, setBoolRecord.Block.Id);
            Assert.AreEqual(0, setBoolRecord.Offset);
            Assert.AreEqual(new DateTime(2020, 1, 1), setBoolRecord.Value);
            Assert.AreEqual(6, setBoolRecord.TransactionNumber);
        }
Beispiel #2
0
        public bool SetDate(Block block, int offset, DateTime value)
        {
            _concurrencyManager.ExclusiveLock(block);
            var buffer = _bufferList.GetBuffer(block);
            int lsn    = _recoveryManager.SetDate(buffer, offset, value);

            return(buffer.SetDate(offset, value, _transactionNumber, lsn));
        }
Beispiel #3
0
        public void CanSetTempDate()
        {
            var page = _fileManager.ResolvePage();

            var block = new Block("temp" + RandomFilename, 0);

            page.Read(block);
            page.SetDate(0, new DateTime(2020, 1, 1));
            page.Write(block);

            _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6);
            var buffer = _bufferManager.Pin(block);

            var lsn = _recoveryManager.SetDate(buffer, 0, new DateTime(2000, 1, 1));

            Assert.AreEqual(-1, lsn);
        }