Interface Journal

  • All Superinterfaces:
    org.apache.activemq.artemis.core.server.ActiveMQComponent
    All Known Subinterfaces:
    TestableJournal
    All Known Implementing Classes:
    FileWrapperJournal, JournalImpl

    public interface Journal
    extends org.apache.activemq.artemis.core.server.ActiveMQComponent
    Most methods on the journal provide a blocking version where you select the sync mode and a non blocking mode where you pass a completion callback as a parameter.

    Notice also that even on the callback methods it's possible to pass the sync mode. That will only make sense on the NIO operations.

    • Method Detail

      • setRemoveExtraFilesOnLoad

        void setRemoveExtraFilesOnLoad​(boolean removeExtraFilesOnLoad)
      • isRemoveExtraFilesOnLoad

        boolean isRemoveExtraFilesOnLoad()
      • isHistory

        default boolean isHistory()
      • appendAddRecord

        void appendAddRecord​(long id,
                             byte recordType,
                             byte[] record,
                             boolean sync)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendAddRecord

        default void appendAddRecord​(long id,
                                     byte recordType,
                                     EncodingSupport record,
                                     boolean sync)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setHistoryFolder

        default Journal setHistoryFolder​(java.io.File historyFolder,
                                         long maxBytes,
                                         long period)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendAddRecord

        void appendAddRecord​(long id,
                             byte recordType,
                             org.apache.activemq.artemis.core.persistence.Persister persister,
                             java.lang.Object record,
                             boolean sync)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendAddRecord

        void appendAddRecord​(long id,
                             byte recordType,
                             org.apache.activemq.artemis.core.persistence.Persister persister,
                             java.lang.Object record,
                             boolean sync,
                             IOCompletion completionCallback)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendAddEvent

        void appendAddEvent​(long id,
                            byte recordType,
                            org.apache.activemq.artemis.core.persistence.Persister persister,
                            java.lang.Object record,
                            boolean sync,
                            IOCompletion completionCallback)
                     throws java.lang.Exception
        An event is data recorded on the journal, but it won't have any weight or deletes. It's always ready to be removed. It is useful on recovery data while in use with backup history journal.
        Throws:
        java.lang.Exception
      • appendAddRecord

        default void appendAddRecord​(long id,
                                     byte recordType,
                                     EncodingSupport record,
                                     boolean sync,
                                     IOCompletion completionCallback)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • replaceableRecord

        default void replaceableRecord​(byte recordType)
      • appendUpdateRecord

        void appendUpdateRecord​(long id,
                                byte recordType,
                                byte[] record,
                                boolean sync)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tryAppendUpdateRecord

        void tryAppendUpdateRecord​(long id,
                                   byte recordType,
                                   byte[] record,
                                   JournalUpdateCallback updateCallback,
                                   boolean sync,
                                   boolean replaceableRecord)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendUpdateRecord

        default void appendUpdateRecord​(long id,
                                        byte recordType,
                                        EncodingSupport record,
                                        boolean sync)
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tryAppendUpdateRecord

        default void tryAppendUpdateRecord​(long id,
                                           byte recordType,
                                           EncodingSupport record,
                                           JournalUpdateCallback updateCallback,
                                           boolean sync,
                                           boolean replaceableRecord)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendUpdateRecord

        void appendUpdateRecord​(long id,
                                byte recordType,
                                org.apache.activemq.artemis.core.persistence.Persister persister,
                                java.lang.Object record,
                                boolean sync)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tryAppendUpdateRecord

        void tryAppendUpdateRecord​(long id,
                                   byte recordType,
                                   org.apache.activemq.artemis.core.persistence.Persister persister,
                                   java.lang.Object record,
                                   JournalUpdateCallback updateCallback,
                                   boolean sync,
                                   boolean replaceableUpdate)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendUpdateRecord

        default void appendUpdateRecord​(long id,
                                        byte recordType,
                                        EncodingSupport record,
                                        boolean sync,
                                        IOCompletion completionCallback)
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tryAppendUpdateRecord

        default void tryAppendUpdateRecord​(long id,
                                           byte recordType,
                                           EncodingSupport record,
                                           boolean sync,
                                           boolean replaceableUpdate,
                                           JournalUpdateCallback updateCallback,
                                           IOCompletion completionCallback)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendUpdateRecord

        void appendUpdateRecord​(long id,
                                byte recordType,
                                org.apache.activemq.artemis.core.persistence.Persister persister,
                                java.lang.Object record,
                                boolean sync,
                                IOCompletion callback)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tryAppendUpdateRecord

        void tryAppendUpdateRecord​(long id,
                                   byte recordType,
                                   org.apache.activemq.artemis.core.persistence.Persister persister,
                                   java.lang.Object record,
                                   boolean sync,
                                   boolean replaceableUpdate,
                                   JournalUpdateCallback updateCallback,
                                   IOCompletion callback)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendDeleteRecord

        void appendDeleteRecord​(long id,
                                boolean sync)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tryAppendDeleteRecord

        void tryAppendDeleteRecord​(long id,
                                   JournalUpdateCallback updateCallback,
                                   boolean sync)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendDeleteRecord

        void appendDeleteRecord​(long id,
                                boolean sync,
                                IOCompletion completionCallback)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tryAppendDeleteRecord

        void tryAppendDeleteRecord​(long id,
                                   boolean sync,
                                   JournalUpdateCallback updateCallback,
                                   IOCompletion completionCallback)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendAddRecordTransactional

        void appendAddRecordTransactional​(long txID,
                                          long id,
                                          byte recordType,
                                          byte[] record)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendAddRecordTransactional

        default void appendAddRecordTransactional​(long txID,
                                                  long id,
                                                  byte recordType,
                                                  EncodingSupport record)
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendAddRecordTransactional

        void appendAddRecordTransactional​(long txID,
                                          long id,
                                          byte recordType,
                                          org.apache.activemq.artemis.core.persistence.Persister persister,
                                          java.lang.Object record)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendUpdateRecordTransactional

        void appendUpdateRecordTransactional​(long txID,
                                             long id,
                                             byte recordType,
                                             byte[] record)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendUpdateRecordTransactional

        default void appendUpdateRecordTransactional​(long txID,
                                                     long id,
                                                     byte recordType,
                                                     EncodingSupport record)
                                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendUpdateRecordTransactional

        void appendUpdateRecordTransactional​(long txID,
                                             long id,
                                             byte recordType,
                                             org.apache.activemq.artemis.core.persistence.Persister persister,
                                             java.lang.Object record)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendDeleteRecordTransactional

        void appendDeleteRecordTransactional​(long txID,
                                             long id,
                                             byte[] record)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendDeleteRecordTransactional

        void appendDeleteRecordTransactional​(long txID,
                                             long id,
                                             EncodingSupport record)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendDeleteRecordTransactional

        void appendDeleteRecordTransactional​(long txID,
                                             long id)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendCommitRecord

        void appendCommitRecord​(long txID,
                                boolean sync)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendCommitRecord

        void appendCommitRecord​(long txID,
                                boolean sync,
                                IOCompletion callback)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendCommitRecord

        void appendCommitRecord​(long txID,
                                boolean sync,
                                IOCompletion callback,
                                boolean lineUpContext)
                         throws java.lang.Exception
        Parameters:
        txID -
        sync -
        callback -
        lineUpContext - if appendCommitRecord should call a storeLineUp. This is because the caller may have already taken into account
        Throws:
        java.lang.Exception
      • appendPrepareRecord

        void appendPrepareRecord​(long txID,
                                 EncodingSupport transactionData,
                                 boolean sync)
                          throws java.lang.Exception

        If the system crashed after a prepare was called, it should store information that is required to bring the transaction back to a state it could be committed.

        transactionData allows you to store any other supporting user-data related to the transaction

        Parameters:
        txID -
        transactionData - - extra user data for the prepare
        Throws:
        java.lang.Exception
      • appendPrepareRecord

        void appendPrepareRecord​(long txID,
                                 EncodingSupport transactionData,
                                 boolean sync,
                                 IOCompletion callback)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendPrepareRecord

        void appendPrepareRecord​(long txID,
                                 byte[] transactionData,
                                 boolean sync)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendRollbackRecord

        void appendRollbackRecord​(long txID,
                                  boolean sync)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • appendRollbackRecord

        void appendRollbackRecord​(long txID,
                                  boolean sync,
                                  IOCompletion callback)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • loadInternalOnly

        JournalLoadInformation loadInternalOnly()
                                         throws java.lang.Exception
        Load internal data structures and not expose any data. This is only useful if you're using the journal but not interested on the current data. Useful in situations where the journal is being replicated, copied... etc.
        Throws:
        java.lang.Exception
      • loadSyncOnly

        JournalLoadInformation loadSyncOnly​(Journal.JournalState state)
                                     throws java.lang.Exception
        Load internal data structures, and remain waiting for synchronization to complete.
        Parameters:
        state - the current state of the journal, this parameter ensures consistency.
        Throws:
        java.lang.Exception
      • lineUpContext

        void lineUpContext​(IOCompletion callback)
      • getAlignment

        int getAlignment()
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getNumberOfRecords

        int getNumberOfRecords()
      • getUserVersion

        int getUserVersion()
      • createFilesForBackupSync

        java.util.Map<java.lang.Long,​JournalFile> createFilesForBackupSync​(long[] fileIds)
                                                                          throws java.lang.Exception
        Reserves journal file IDs, creates the necessary files for synchronization, and places references to these (reserved for sync) files in the map.

        During the synchronization between a live server and backup, we reserve in the backup the journal file IDs used in the live server. This call also makes sure the files are created empty without any kind of headers added.

        Parameters:
        fileIds - IDs to reserve for synchronization
        Returns:
        map to be filled with id and journal file pairs for synchronization.
        Throws:
        java.lang.Exception
      • synchronizationLock

        void synchronizationLock()
        Write lock the Journal and write lock the compacting process. Necessary only during replication for backup synchronization.
      • synchronizationUnlock

        void synchronizationUnlock()
        Unlock the Journal and the compacting process.
        See Also:
        synchronizationLock()
      • processBackup

        default void processBackup()
        It will rename temporary files and place them on the copy folder, by resotring the original file name.
      • processBackupCleanup

        default void processBackupCleanup()
        It will check max files and max days on files and remove extra files.
      • forceMoveNextFile

        void forceMoveNextFile()
                        throws java.lang.Exception
        Force the usage of a new JournalFile.
        Throws:
        java.lang.Exception
      • forceBackup

        default void forceBackup​(int timeout,
                                 java.util.concurrent.TimeUnit unit)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getFileSize

        int getFileSize()
      • scheduleCompactAndBlock

        void scheduleCompactAndBlock​(int timeout)
                              throws java.lang.Exception
        This method will start compact using the compactorExecutor and block up to timeout seconds
        Parameters:
        timeout - the timeout in seconds or block forever if <= 0
        Throws:
        java.lang.Exception
      • replicationSyncPreserveOldFiles

        void replicationSyncPreserveOldFiles()
        Stops any operation that may delete or modify old (stale) data.

        Meant to be used during synchronization of data between a live server and its replicating (remote) backup. Old files must not be compacted or deleted during synchronization.

      • replicationSyncFinished

        void replicationSyncFinished()
        Restarts file reclaim and compacting on the journal.

        Meant to be used to revert the effect of replicationSyncPreserveOldFiles(). it should only be called once the synchronization of the backup and live servers is completed.

      • flush

        void flush()
            throws java.lang.Exception
        It will make sure there are no more pending operations on the Executors.
        Throws:
        java.lang.Exception
      • getMaxRecordSize

        long getMaxRecordSize()
        The max size record that can be stored in the journal
        Returns: