Class JournalledSystem


  • class JournalledSystem
    extends java.lang.Object
    Manages a journalling data store management system. All operations are written out to a log that can be easily recovered from if a crash occurs.
    • Field Detail

      • ENABLE_LOGGING

        private final boolean ENABLE_LOGGING
        Set to true for logging behaviour.
      • journal_path

        private final java.io.File journal_path
        The path to the journal files.
      • read_only

        private final boolean read_only
        If the journal system is in read only mode.
      • page_size

        private final int page_size
        The page size.
      • all_resources

        private java.util.HashMap all_resources
        The map of all resources that are available. (resource_name -> Resource)
      • seq_id

        private long seq_id
        The unique sequence id counter for this session.
      • journal_archives

        private final java.util.ArrayList journal_archives
        The archive of journal files currently pending (JournalFile).
      • journal_number

        private long journal_number
        The current journal file number.
      • top_journal_lock

        private final java.lang.Object top_journal_lock
        Mutex when accessing the top journal file.
      • journaling_thread

        private JournalledSystem.JournalingThread journaling_thread
        A thread that runs in the background and persists information that is in the journal.
      • debug

        private final DebugLogger debug
        A debug log to output information to.
      • init_lock

        private final java.lang.Object init_lock
      • journal_list_comparator

        private java.util.Comparator journal_list_comparator
    • Method Detail

      • getJournalFileName

        private static java.lang.String getJournalFileName​(int number)
        Returns a journal file name with the given number. The journal number must be between 10 and 63
      • start

        void start()
            throws java.io.IOException
        Starts the journal system.
        Throws:
        java.io.IOException
      • stop

        void stop()
           throws java.io.IOException
        Stops the journal system. This will persist any pending changes up to the last check point and then finish.
        Throws:
        java.io.IOException
      • rollForwardRecover

        void rollForwardRecover()
                         throws java.io.IOException
        Recovers any lost operations that are currently in the journal. This retries all logged entries. This would typically be called before any other IO operations.
        Throws:
        java.io.IOException
      • newTopJournalFile

        private void newTopJournalFile()
                                throws java.io.IOException
        Creates a new top journal file.
        Throws:
        java.io.IOException
      • createResource

        public JournalledResource createResource​(java.lang.String resource_name)
        Creates a resource.
      • setCheckPoint

        void setCheckPoint​(boolean flush_journals)
                    throws java.io.IOException
        Sets a check point in the log. If 'flush_journals' is true then when the method returns we are guarenteed that all the journals are flushed and the data is absolutely current. If 'flush_journals' is false then we can't assume the journals will be empty when the method returns.
        Throws:
        java.io.IOException