Class JournalFilesRepository

java.lang.Object
org.apache.activemq.artemis.core.journal.impl.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 Details

    • 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 Details

    • getPoolSize

      public int getPoolSize()
    • setExecutor

      public void setExecutor(Executor fileExecutor)
    • clear

      public void clear() throws Exception
      Throws:
      Exception
    • 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().

    • ensureMinFiles

      public void ensureMinFiles() throws Exception
      Throws:
      Exception
    • openFile

      public void openFile(JournalFile file, boolean multiAIO) throws Exception
      Throws:
      Exception
    • getDataFilesArray

      public JournalFile[] getDataFilesArray()
    • pollLastDataFile

      public JournalFile pollLastDataFile()
    • removeDataFile

      public void removeDataFile(JournalFile file)
    • getDataFilesCount

      public int getDataFilesCount()
    • getJournalFileOpenTimeout

      public int getJournalFileOpenTimeout()
    • getDataFiles

      public Collection<JournalFile> getDataFiles()
    • 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) throws Exception
      Throws:
      Exception
    • addFreeFile

      public void addFreeFile(JournalFile file, boolean renameTmp, boolean checkDelete) throws Exception
      add a free file
      Parameters:
      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
    • getFreeFiles

      public Collection<JournalFile> getFreeFiles()
    • getFreeFile

      public JournalFile getFreeFile()
    • getOpenedFilesCount

      public int getOpenedFilesCount()
    • openFileCMP

      public JournalFile openFileCMP() throws Exception
      Throws:
      Exception
    • openFile

      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
    • closeFile

      public void closeFile(JournalFile file, boolean block) throws Exception
      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)
    • toString

      public String toString()
      Overrides:
      toString in class Object