Ejemplo n.º 1
0
        void CheckForIncompleteJournalRotation(string baseFileName, int currentMemTableVersion)
        {
            int previousMemTableVersion = currentMemTableVersion - 1;

            if (File.Exists(Config.JournalFile(baseFileName, previousMemTableVersion)))                 // Is there a left-over journal from a previous rotation that was aborted while in rotation?
            {
                var memTable = new JournaledMemTable(baseFileName, previousMemTableVersion);
                memTable.WriteToSortedBlockTable(_manifest);
                memTable.Close();
            }
        }
Ejemplo n.º 2
0
        // Rotates the mem table.
        public void RotateMemTable()
        {
            lock (memTableRotationLock) {
                if (_currentJournaledMemTable.Full)                   // Double check the flag in case we have multiple threads that make it into this routine.
                {
                    _rotationSemaphore.WaitOne();                     // Wait for the rotation gate to be open, and automatically reset once a single thread gets through.
                    _rotatedJournaledMemTable = Interlocked.Exchange <JournaledMemTable> (ref _currentJournaledMemTable, new JournaledMemTable(_manifest.BaseFileName, _manifest.NextVersion(0)));

                    ThreadPool.QueueUserWorkItem((o) => {
                        try {
                            _rotatedJournaledMemTable.WriteToSortedBlockTable(_manifest);
                            _rotatedJournaledMemTable = null;
                        } finally {
                            _rotationSemaphore.Release();                              // Open the gate for the next rotation.
                        }
                    });
                }
            }
        }
Ejemplo n.º 3
0
 void CheckForIncompleteJournalRotation(string baseFileName, int currentMemTableVersion)
 {
     int previousMemTableVersion = currentMemTableVersion - 1;
     if (File.Exists (Config.JournalFile (baseFileName, previousMemTableVersion))) { // Is there a left-over journal from a previous rotation that was aborted while in rotation?
         var memTable = new JournaledMemTable (baseFileName, previousMemTableVersion);
         memTable.WriteToSortedBlockTable (_manifest);
         memTable.Close ();
     }
 }
Ejemplo n.º 4
0
        // Rotates the mem table.
        public void RotateMemTable()
        {
            lock (memTableRotationLock) {
                if (_currentJournaledMemTable.Full) { // Double check the flag in case we have multiple threads that make it into this routine.
                    _rotationSemaphore.WaitOne (); // Wait for the rotation gate to be open, and automatically reset once a single thread gets through.
                    _rotatedJournaledMemTable = Interlocked.Exchange<JournaledMemTable> (ref _currentJournaledMemTable, new JournaledMemTable (_manifest.BaseFileName, _manifest.NextVersion (0)));

                    ThreadPool.QueueUserWorkItem ((o) => {
                        try {
                            _rotatedJournaledMemTable.WriteToSortedBlockTable (_manifest);
                            _rotatedJournaledMemTable = null;
                        } finally {
                            _rotationSemaphore.Release (); // Open the gate for the next rotation.
                        }
                    });
                }
            }
        }