示例#1
0
        public Snapshot(LockMode mode, string collectionName, HeaderPage header, uint transactionID, TransactionPages transPages, LockService locker, WalIndexService walIndex, DiskReader reader, bool addIfNotExists)
        {
            _mode           = mode;
            _collectionName = collectionName;
            _header         = header;
            _transactionID  = transactionID;
            _transPages     = transPages;
            _locker         = locker;
            _walIndex       = walIndex;
            _reader         = reader;

            // enter in lock mode according initial mode
            if (mode == LockMode.Read)
            {
                _locker.EnterRead(_collectionName);
            }
            else
            {
                _locker.EnterReserved(_collectionName);
            }

            // get lastest read version from wal-index
            _readVersion = _walIndex.CurrentReadVersion;

            var srv = new CollectionService(_header, this, _transPages);

            // read collection (create if new - load virtual too)
            srv.Get(_collectionName, addIfNotExists, ref _collectionPage);

            // clear local pages (will clear _collectionPage link reference)
            if (_collectionPage != null)
            {
                _localPages.Remove(_collectionPage.PageID);
            }
        }
示例#2
0
        public TransactionService(HeaderPage header, LockService locker, DiskService disk, WalIndexService walIndex, int maxTransactionSize, TransactionMonitor monitor, bool queryOnly)
        {
            // retain instances
            _header   = header;
            _locker   = locker;
            _disk     = disk;
            _walIndex = walIndex;
            _monitor  = monitor;

            this.QueryOnly          = queryOnly;
            this.MaxTransactionSize = maxTransactionSize;

            // create new transactionID
            _transactionID = walIndex.NextTransactionID();
            _startTime     = DateTime.UtcNow;
            _reader        = _disk.GetReader();
        }
示例#3
0
        public TransactionService(HeaderPage header, LockService locker, DiskService disk, WalIndexService walIndex, int maxTransactionSize, Action <uint> done)
        {
            // retain instances
            _header             = header;
            _locker             = locker;
            _disk               = disk;
            _walIndex           = walIndex;
            _maxTransactionSize = maxTransactionSize;
            _done               = done;

            // create new transactionID
            _transactionID = walIndex.NextTransactionID();
            _startTime     = DateTime.UtcNow;
            _reader        = _disk.GetReader();

            // enter transaction locker to avoid 2 transactions in same thread
            _locker.EnterTransaction();
        }