Class JournalFilesRepository


  • public class JournalFilesRepository
    extends Object
    This is a helper class for the Journal, which will control access to dataFiles, openedFiles and freeFiles Guaranteeing that they will be delivered in order to the Journal
    • Constructor Detail

      • JournalFilesRepository

        public JournalFilesRepository​(SequentialFileFactory fileFactory,
                                      JournalImpl journal,
                                      String filePrefix,
                                      String fileExtension,
                                      int userVersion,
                                      int maxAIO,
                                      int fileSize,
                                      int minFiles,
                                      int poolSize,
                                      int journalFileOpenTimeout,
                                      int maxAtticFiles)
    • Method Detail

      • getPoolSize

        public int getPoolSize()
      • setExecutor

        public void setExecutor​(Executor fileExecutor)
      • getMaxAIO

        public int getMaxAIO()
      • getFileExtension

        public String getFileExtension()
      • getFilePrefix

        public String getFilePrefix()
      • calculateNextfileID

        public void calculateNextfileID​(List<JournalFile> files)
      • setNextFileID

        public void setNextFileID​(long targetUpdate)
        Set the {link #nextFileID} value to targetUpdate if the current value is less than targetUpdate. Notice that nextFileID is incremented before being used, see generateFileID().
        Parameters:
        targetUpdate -
      • getDataFilesArray

        public JournalFile[] getDataFilesArray()
      • pollLastDataFile

        public JournalFile pollLastDataFile()
      • removeDataFile

        public void removeDataFile​(JournalFile file)
      • getDataFilesCount

        public int getDataFilesCount()
      • getJournalFileOpenTimeout

        public int getJournalFileOpenTimeout()
      • clearDataFiles

        public void clearDataFiles()
      • addDataFileOnTop

        public void addDataFileOnTop​(JournalFile file)
      • debugFiles

        public String debugFiles()
      • checkDataFiles

        public void checkDataFiles()
      • addDataFileOnBottom

        public void addDataFileOnBottom​(JournalFile file)
      • getFreeFilesCount

        public int getFreeFilesCount()
      • addFreeFile

        public void addFreeFile​(JournalFile file,
                                boolean renameTmp,
                                boolean checkDelete)
                         throws Exception
        Parameters:
        file -
        renameTmp - - should rename the file as it's being added to free files
        checkDelete - - should delete the file if max condition has been met
        Throws:
        Exception
      • getOpenedFilesCount

        public int getOpenedFilesCount()
      • openFile

        public JournalFile openFile()
                             throws InterruptedException,
                                    ActiveMQIOErrorException

        This method will instantly return the opened file, and schedule opening and reclaiming.

        In case there are no cached opened files, this method will block until the file was opened, what would happen only if the system is under heavy load by another system (like a backup system, or a DB sharing the same box as ActiveMQ).

        Throws:
        ActiveMQIOErrorException - In case the file could not be opened
        InterruptedException
      • pushOpenedFile

        public void pushOpenedFile()
                            throws Exception
        Open a file and place it into the openedFiles queue
        Throws:
        Exception
      • createRemoteBackupSyncFile

        public JournalFile createRemoteBackupSyncFile​(long fileID)
                                               throws Exception
        Creates files for journal synchronization of a replicated backup. In order to simplify synchronization, the file IDs in the backup match those in the live server.
        Parameters:
        fileID - the fileID to use when creating the file.
        Throws:
        Exception
      • getFileNameID

        public static long getFileNameID​(String filePrefix,
                                         String fileName)
        Get the ID part of the name
      • removeNegatives

        public void removeNegatives​(JournalFile file)