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 Summary
Constructors Constructor Description JournalFilesRepository(SequentialFileFactory fileFactory, JournalImpl journal, String filePrefix, String fileExtension, int userVersion, int maxAIO, int fileSize, int minFiles, int poolSize, int journalFileOpenTimeout, int maxAtticFiles)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDataFileOnBottom(JournalFile file)voidaddDataFileOnTop(JournalFile file)voidaddFreeFile(JournalFile file, boolean renameTmp)voidaddFreeFile(JournalFile file, boolean renameTmp, boolean checkDelete)voidcalculateNextfileID(List<JournalFile> files)voidcheckDataFiles()voidclear()voidclearDataFiles()voidcloseFile(JournalFile file, boolean block)JournalFilecreateRemoteBackupSyncFile(long fileID)Creates files for journal synchronization of a replicated backup.StringdebugFiles()voidensureMinFiles()Collection<JournalFile>getDataFiles()JournalFile[]getDataFilesArray()intgetDataFilesCount()StringgetFileExtension()static longgetFileNameID(String filePrefix, String fileName)Get the ID part of the nameStringgetFilePrefix()JournalFilegetFreeFile()Collection<JournalFile>getFreeFiles()intgetFreeFilesCount()intgetJournalFileOpenTimeout()intgetMaxAIO()intgetOpenedFilesCount()intgetPoolSize()JournalFileopenFile()This method will instantly return the opened file, and schedule opening and reclaiming.voidopenFile(JournalFile file, boolean multiAIO)JournalFileopenFileCMP()JournalFilepollLastDataFile()voidpushOpenedFile()Open a file and place it into the openedFiles queuevoidremoveDataFile(JournalFile file)voidremoveNegatives(JournalFile file)voidsetExecutor(Executor fileExecutor)voidsetNextFileID(long targetUpdate)Set the {link #nextFileID} value totargetUpdateif the current value is less thantargetUpdate.StringtoString()
-
-
-
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 totargetUpdateif the current value is less thantargetUpdate. Notice thatnextFileIDis incremented before being used, seegenerateFileID().- Parameters:
targetUpdate-
-
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
- Parameters:
file-- Throws:
Exception
-
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 filescheckDelete- - 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
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 openedInterruptedException
-
pushOpenedFile
public void pushOpenedFile() throws ExceptionOpen 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)
-
-