Exemplo n.º 1
0
        public void Start()
        {
            if (EnableLogging)
            {
                lock (initLock) {
                    if (journalingThread == null)
                    {
                        // Start the background journaling thread,
                        journalingThread = new JournalingThread(this);
                        journalingThread.Start();
                        // Scan for any changes and make the changes.
                        RollForwardRecover();

                        if (!ReadOnly)
                        {
                            // Create a new top journal file
                            NewTopJournalFile();
                        }
                    }
                    else
                    {
                        throw new Exception("Assertion failed - already started.");
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Stop()
        {
            if (EnableLogging)
            {
                lock (initLock) {
                    if (journalingThread != null)
                    {
                        // Stop the journal thread
                        journalingThread.PersistArchives(0);
                        journalingThread.Finish();
                        journalingThread.Wait();
                        journalingThread = null;
                    }
                    else
                    {
                        throw new Exception("Assertion failed - already stopped.");
                    }
                }

                if (!ReadOnly)
                {
                    // Close any remaining journals and roll forward recover (shouldn't
                    // actually be necessary but just incase...)
                    lock (topJournalLock) {
                        // Close all the journals
                        int sz = journalArchives.Count;
                        for (int i = 0; i < sz; ++i)
                        {
                            var jf = journalArchives[i];
                            jf.Close();
                        }

                        // Close the top journal
                        TopJournal.Close();
                        // Scan for journals and make the changes.
                        RollForwardRecover();

                        DisposeResources();
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Stops the journal system.
        /// </summary>
        /// <remarks>
        /// This will persist any pending changes up to the last check point 
        /// and then finish.
        /// </remarks>
        internal void Stop()
        {
            if (ENABLE_LOGGING) {
                lock (init_lock) {
                    if (journaling_thread != null) {
                        // Stop the journal thread
                        journaling_thread.PersistArchives(0);
                        journaling_thread.Finish();
                        journaling_thread.WaitUntilFinished();
                        journaling_thread = null;
                    } else {
                        throw new ApplicationException("Assertion failed - already stopped.");
                    }
                }

                if (!read_only) {
                    // Close any remaining journals and roll forward recover (shouldn't
                    // actually be necessary but just incase...)
                    lock (top_journal_lock) {
                        // Close all the journals
                        int sz = journal_archives.Count;
                        for (int i = 0; i < sz; ++i) {
                            JournalFile jf = (JournalFile)journal_archives[i];
                            jf.Close();
                        }
                        // Close the top journal
                        TopJournal.Close();
                        // Scan for journals and make the changes.
                        RollForwardRecover();
                    }
                }

            }

            // Close all the resources
            lock (all_resources) {
                foreach (DictionaryEntry entry in all_resources) {
                    AbstractResource r = GetResource((string)entry.Key);
                    r.PersistClose();
                }
            }

            // Release, close and delete the lock file
            lock_file.Unlock(0, lock_file.Length);
            lock_file.Close();
            File.Delete(Path.Combine(journal_path, "lock.m"));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Starts the journal system.
        /// </summary>
        internal void Start()
        {
            lock_file = new FileStream(Path.Combine(journal_path, "lock.m"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
            lock_file.Lock(0, lock_file.Length);

            if (ENABLE_LOGGING) {
                lock (init_lock) {
                    if (journaling_thread == null) {
                        // Start the background journaling thread,
                        journaling_thread = new JournalingThread(this);
                        journaling_thread.Start();
                        // Scan for any changes and make the changes.
                        RollForwardRecover();
                        if (!read_only) {
                            // Create a new top journal file
                            NewTopJournalFile();
                        }
                    } else {
                        throw new ApplicationException("Assertion failed - already started.");
                    }
                }
            }
        }