Class JournalImpl
- All Implemented Interfaces:
JournalRecordProvider,Journal,TestableJournal,org.apache.activemq.artemis.core.server.ActiveMQComponent
Look at load(LoaderCallback) for the file layout
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.activemq.artemis.core.journal.Journal
Journal.JournalState -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final Stringstatic final bytestatic final bytestatic final bytestatic final byteprotected final intprotected static final bytestatic final intprotected ExecutorFactorystatic final intstatic final byteprotected booleanstatic final bytestatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final doublethis is a factor where when you have more than UPDATE_FACTOR updates for every ADD.static final bytestatic final byte -
Constructor Summary
ConstructorsConstructorDescriptionJournalImpl(int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, int journalFileOpenTimeout, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) JournalImpl(int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO) JournalImpl(int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) JournalImpl(ExecutorFactory ioExecutors, int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, int journalFileOpenTimeout, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) JournalImpl(ExecutorFactory ioExecutors, int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, int journalFileOpenTimeout, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion, IOCriticalErrorListener criticalErrorListener, int maxAtticFiles) JournalImpl(ExecutorFactory ioExecutors, int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendAddEvent(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, IOCompletion callback) An event is data recorded on the journal, but it won't have any weight or deletes.voidappendAddRecord(long id, byte recordType, byte[] record, boolean sync) voidappendAddRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync) voidappendAddRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, IOCompletion callback) voidappendAddRecordTransactional(long txID, long id, byte recordType, byte[] record) voidappendAddRecordTransactional(long txID, long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record) voidappendCommitRecord(long txID, boolean sync) voidappendCommitRecord(long txID, boolean sync, IOCompletion callback) voidappendCommitRecord(long txID, boolean sync, IOCompletion callback, boolean lineUpContext) Regarding the number of operations in a given file seeJournalCompleteRecordTX.voidappendDeleteRecord(long id, boolean sync) voidappendDeleteRecord(long id, boolean sync, IOCompletion callback) voidappendDeleteRecordTransactional(long txID, long id) voidappendDeleteRecordTransactional(long txID, long id, byte[] record) voidappendDeleteRecordTransactional(long txID, long id, EncodingSupport record) voidappendPrepareRecord(long txID, byte[] transactionData, boolean sync) voidappendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync) 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.voidappendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync, IOCompletion callback) 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.voidappendRollbackRecord(long txID, boolean sync) voidappendRollbackRecord(long txID, boolean sync, IOCompletion callback) voidappendUpdateRecord(long id, byte recordType, byte[] record, boolean sync) voidappendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync) voidappendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, IOCompletion callback) voidappendUpdateRecordTransactional(long txID, long id, byte recordType, byte[] record) voidappendUpdateRecordTransactional(long txID, long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record) final voidvoidcompact()Note: This method can't be called from the main executor, as it will invoke other methods depending on it.protected SequentialFilecreateControlFile(List<JournalFile> files, List<JournalFile> newFiles, Pair<String, String> cleanupRename) createFilesForBackupSync(long[] fileIds) Returns map with the IDs and correspondingJournalFiles; these are the files needed to be sent to a backup in order to synchronize it.debug()voidMethod for use on testcases.protected voiddeleteControlFile(SequentialFile controlFile) voidflush()It will make sure there are no more pending operations on the Executors.booleanflushAppendExecutor(long timeout, TimeUnit unit) voidforceBackup(int timeout, TimeUnit unit) voidForce the usage of a newJournalFile.intintFor tests onlyintfloatReturns array with allJournalFiles in use.intgetDatePortion(String name) longgetDatePortionMillis(String name) intintgetHistoryFileName(long sequence, Calendar calendar) intintlongThe max size record that can be stored in the journalintintintorg.apache.activemq.artemis.utils.collections.ConcurrentLongHashMap<JournalRecord>protected SyncIOCompletiongetSyncCallback(boolean sync) intlongstatic intinitFileHeader(SequentialFileFactory fileFactory, SequentialFile sequentialFile, int userVersion, long fileID) final booleanbooleanbooleanbooleanvoidlineUpContext(IOCompletion callback) load(List<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback transactionFailure, boolean fixBadTx) load(LoaderCallback loadManager) Load data accordingly to the record layoutsload(org.apache.activemq.artemis.utils.collections.SparseArrayLinkedList<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback failureCallback, boolean fixBadTX) Load internal data structures and not expose any data.loadSyncOnly(Journal.JournalState syncState) Load internal data structures, and remain waiting for synchronization to complete.protected voidmoveNextFile(boolean scheduleReclaim, boolean blockOnClose) You need to guarantee lock.acquire() before calling this method!protected voidThis is an interception point for testcases, when the compacted files are written, before replacing the data structuresprotected voidThis is an interception point for testcases, when the compacted files are written, to be called as soon as the compactor gets a writeLockprotected voidThis is an interception point for testcases, when the compacted files are written, before replacing the data structuresthis method is used internally only however tools may use it to maintenance.voidWith the exception of initialization, this has to be always called within the compactorExecutorvoidIt will check max files and max days on files and remove extra files.readFileHeader(SequentialFile file) static intreadJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader) this method is used internally only however tools may use it to maintenance.static intreadJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader, AtomicReference<ByteBuffer> wholeFileBufferReference) static intreadJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader, AtomicReference<ByteBuffer> wholeFileBufferReference, boolean reclaimed) static intreadJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader, AtomicReference<ByteBuffer> wholeFileBufferReference, boolean reclaimed, io.netty.util.collection.ByteObjectHashMap<Boolean> replaceableRecords) removeBackupExtension(String name) protected static StringrenameExtensionFile(String name, String extension) protected voidrenameFiles(List<JournalFile> oldFiles, List<JournalFile> newFiles) being protected as testcases can override this methodvoidreplaceableRecord(byte recordType) This will declare a record type as being replaceable on updates.voidRestarts file reclaim and compacting on the journal.voidStops any operation that may delete or modify old (stale) data.voidscheduleCompactAndBlock(int timeout) This method will start compact using the compactorExecutor and block up to timeout secondsfinal voidsetAutoReclaim(boolean autoReclaim) setCriticalErrorListener(IOCriticalErrorListener criticalErrorListener) setHistoryFolder(File historyFolder, long maxBytes, long period) voidsetRemoveExtraFilesOnLoad(boolean setting) protected JournalFilesetUpCurrentFile(int lastDataPos) voidstart()voidstop()protected JournalFileswitchFileIfNecessary(int size) final voidWrite lock the Journal and write lock the compacting process.final voidUnlock the Journal and the compacting process.voidtoString()voidtryAppendDeleteRecord(long id, boolean sync, JournalUpdateCallback updateCallback, IOCompletion callback) voidtryAppendDeleteRecord(long id, JournalUpdateCallback updateCallback, boolean sync) voidtryAppendUpdateRecord(long id, byte recordType, byte[] record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceableRecord) voidtryAppendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, boolean replaceableUpdate, JournalUpdateCallback updateCallback, IOCompletion callback) voidtryAppendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceableUpdate) protected SequentialFilewriteControlFile(SequentialFileFactory fileFactory, List<JournalFile> files, List<JournalFile> newFiles, List<Pair<String, String>> renames) static voidwriteHeader(ActiveMQBuffer buffer, int userVersion, long fileID) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.activemq.artemis.core.server.ActiveMQComponent
asyncStopMethods inherited from interface org.apache.activemq.artemis.core.journal.Journal
appendAddRecord, appendAddRecord, appendAddRecord, appendAddRecord, appendAddRecordTransactional, appendAddRecordTransactional, appendCommitRecord, appendCommitRecord, appendDeleteRecord, appendDeleteRecordTransactional, appendDeleteRecordTransactional, appendPrepareRecord, appendPrepareRecord, appendRollbackRecord, appendUpdateRecord, appendUpdateRecord, appendUpdateRecord, appendUpdateRecord, appendUpdateRecordTransactional, appendUpdateRecordTransactional, isRemoveExtraFilesOnLoad, load, load, setRemoveExtraFilesOnLoad, tryAppendDeleteRecord, tryAppendUpdateRecord, tryAppendUpdateRecord, tryAppendUpdateRecord, tryAppendUpdateRecord
-
Field Details
-
UPDATE_FACTOR
public static final double UPDATE_FACTORthis is a factor where when you have more than UPDATE_FACTOR updates for every ADD.When this happens we should issue a compacting event.
I don't foresee users needing to configure this value. However if this ever happens we would have a system property aligned for this.
With that being said, if you needed this, please raise an issue on why you needed to use this, so we may eventually add it to broker.xml when a real use case would determine the configuration exposed in there.
To update this value, define a System Property org.apache.activemq.artemis.core.journal.impl.JournalImpl.UPDATE_FACTOR=YOUR VALUE
We only calculate this against replaceable updates, on this case for redelivery counts and rescheduled redelivery in artemis server
-
BKP
- See Also:
-
FORMAT_VERSION
public static final int FORMAT_VERSION- See Also:
-
MIN_FILE_SIZE
public static final int MIN_FILE_SIZE- See Also:
-
SIZE_HEADER
public static final int SIZE_HEADER- See Also:
-
SIZE_ADD_RECORD
public static final int SIZE_ADD_RECORD- See Also:
-
EVENT_RECORD
public static final byte EVENT_RECORD- See Also:
-
ADD_RECORD
public static final byte ADD_RECORD- See Also:
-
UPDATE_RECORD
public static final byte UPDATE_RECORD- See Also:
-
SIZE_ADD_RECORD_TX
public static final int SIZE_ADD_RECORD_TX- See Also:
-
ADD_RECORD_TX
public static final byte ADD_RECORD_TX- See Also:
-
UPDATE_RECORD_TX
public static final byte UPDATE_RECORD_TX- See Also:
-
SIZE_DELETE_RECORD_TX
public static final int SIZE_DELETE_RECORD_TX- See Also:
-
DELETE_RECORD_TX
public static final byte DELETE_RECORD_TX- See Also:
-
SIZE_DELETE_RECORD
public static final int SIZE_DELETE_RECORD- See Also:
-
DELETE_RECORD
public static final byte DELETE_RECORD- See Also:
-
SIZE_COMPLETE_TRANSACTION_RECORD
public static final int SIZE_COMPLETE_TRANSACTION_RECORD- See Also:
-
SIZE_PREPARE_RECORD
public static final int SIZE_PREPARE_RECORD- See Also:
-
PREPARE_RECORD
public static final byte PREPARE_RECORD- See Also:
-
SIZE_COMMIT_RECORD
public static final int SIZE_COMMIT_RECORD- See Also:
-
COMMIT_RECORD
public static final byte COMMIT_RECORD- See Also:
-
SIZE_ROLLBACK_RECORD
public static final int SIZE_ROLLBACK_RECORD- See Also:
-
ROLLBACK_RECORD
public static final byte ROLLBACK_RECORD- See Also:
-
FILL_CHARACTER
protected static final byte FILL_CHARACTER- See Also:
-
ioExecutorFactory
-
fileSize
protected final int fileSize -
removeExtraFilesOnLoad
protected boolean removeExtraFilesOnLoad
-
-
Constructor Details
-
JournalImpl
public JournalImpl(int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO) -
JournalImpl
public JournalImpl(int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) -
JournalImpl
public JournalImpl(int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, int journalFileOpenTimeout, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) -
JournalImpl
public JournalImpl(ExecutorFactory ioExecutors, int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) -
JournalImpl
public JournalImpl(ExecutorFactory ioExecutors, int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, int journalFileOpenTimeout, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion) -
JournalImpl
public JournalImpl(ExecutorFactory ioExecutors, int fileSize, int minFiles, int poolSize, int compactMinFiles, int compactPercentage, int journalFileOpenTimeout, SequentialFileFactory fileFactory, String filePrefix, String fileExtension, int maxAIO, int userVersion, IOCriticalErrorListener criticalErrorListener, int maxAtticFiles)
-
-
Method Details
-
isHistory
public boolean isHistory() -
getHistoryFolder
- Specified by:
getHistoryFolderin interfaceJournal
-
setHistoryFolder
public JournalImpl setHistoryFolder(File historyFolder, long maxBytes, long period) throws Exception - Specified by:
setHistoryFolderin interfaceJournal- Throws:
Exception
-
replaceableRecord
public void replaceableRecord(byte recordType) This will declare a record type as being replaceable on updates. Certain update records only need the last value, and they could be replaceable during compacting.- Specified by:
replaceableRecordin interfaceJournal
-
getCompactPercentage
public float getCompactPercentage() -
getCompactMinFiles
public int getCompactMinFiles() -
getFilesRepository
-
toString
-
getCriticalErrorListener
- Specified by:
getCriticalErrorListenerin interfaceJournal
-
setCriticalErrorListener
- Specified by:
setCriticalErrorListenerin interfaceJournal
-
getRecords
public org.apache.activemq.artemis.utils.collections.ConcurrentLongHashMap<JournalRecord> getRecords()- Specified by:
getRecordsin interfaceJournalRecordProvider
-
getCurrentFile
- Specified by:
getCurrentFilein interfaceTestableJournal
-
getCompactor
- Specified by:
getCompactorin interfaceJournalRecordProvider
-
orderFiles
this method is used internally only however tools may use it to maintenance. It won't be part of the interface as the tools should be specific to the implementation- Throws:
Exception
-
readJournalFile
public static int readJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader, AtomicReference<ByteBuffer> wholeFileBufferReference) throws Exception - Throws:
Exception
-
readJournalFile
public static int readJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader, AtomicReference<ByteBuffer> wholeFileBufferReference, boolean reclaimed) throws Exception - Throws:
Exception
-
readJournalFile
public static int readJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader, AtomicReference<ByteBuffer> wholeFileBufferReference, boolean reclaimed, io.netty.util.collection.ByteObjectHashMap<Boolean> replaceableRecords) throws Exception - Throws:
Exception
-
readJournalFile
public static int readJournalFile(SequentialFileFactory fileFactory, JournalFile file, JournalReaderCallback reader) throws Exception this method is used internally only however tools may use it to maintenance.- Throws:
Exception
-
appendAddRecord
public void appendAddRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, IOCompletion callback) throws Exception - Specified by:
appendAddRecordin interfaceJournal- Throws:
Exception
-
appendAddEvent
public void appendAddEvent(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, IOCompletion callback) throws Exception Description copied from interface:JournalAn 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.- Specified by:
appendAddEventin interfaceJournal- Throws:
Exception
-
appendUpdateRecord
public void appendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, IOCompletion callback) throws Exception - Specified by:
appendUpdateRecordin interfaceJournal- Throws:
Exception
-
tryAppendUpdateRecord
public void tryAppendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync, boolean replaceableUpdate, JournalUpdateCallback updateCallback, IOCompletion callback) throws Exception - Specified by:
tryAppendUpdateRecordin interfaceJournal- Throws:
Exception
-
appendDeleteRecord
- Specified by:
appendDeleteRecordin interfaceJournal- Throws:
Exception
-
tryAppendDeleteRecord
public void tryAppendDeleteRecord(long id, boolean sync, JournalUpdateCallback updateCallback, IOCompletion callback) throws Exception - Specified by:
tryAppendDeleteRecordin interfaceJournal- Throws:
Exception
-
appendAddRecordTransactional
public void appendAddRecordTransactional(long txID, long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record) throws Exception - Specified by:
appendAddRecordTransactionalin interfaceJournal- Throws:
Exception
-
appendUpdateRecordTransactional
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record) throws Exception - Specified by:
appendUpdateRecordTransactionalin interfaceJournal- Throws:
Exception
-
appendDeleteRecordTransactional
public void appendDeleteRecordTransactional(long txID, long id, EncodingSupport record) throws Exception - Specified by:
appendDeleteRecordTransactionalin interfaceJournal- Throws:
Exception
-
appendPrepareRecord
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync, IOCompletion callback) throws 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
This method also uses the same logic applied on
Journal.appendCommitRecord(long, boolean)- Specified by:
appendPrepareRecordin interfaceJournal- Parameters:
transactionData- extra user data for the prepare- Throws:
Exception
-
lineUpContext
- Specified by:
lineUpContextin interfaceJournal
-
appendCommitRecord
public void appendCommitRecord(long txID, boolean sync, IOCompletion callback, boolean lineUpContext) throws Exception Regarding the number of operations in a given file seeJournalCompleteRecordTX.- Specified by:
appendCommitRecordin interfaceJournallineUpContext- if appendCommitRecord should call a storeLineUp. This is because the caller may have already taken into account- Throws:
Exception
-
appendRollbackRecord
- Specified by:
appendRollbackRecordin interfaceJournal- Throws:
Exception
-
getAlignment
- Specified by:
getAlignmentin interfaceJournal- Throws:
Exception
-
loadInternalOnly
Description copied from interface:JournalLoad 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.- Specified by:
loadInternalOnlyin interfaceJournal- Throws:
Exception
-
loadSyncOnly
Description copied from interface:JournalLoad internal data structures, and remain waiting for synchronization to complete.- Specified by:
loadSyncOnlyin interfaceJournal- Parameters:
syncState- the current state of the journal, this parameter ensures consistency.- Throws:
Exception
-
load
public JournalLoadInformation load(List<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback transactionFailure, boolean fixBadTx) throws Exception -
load
public JournalLoadInformation load(org.apache.activemq.artemis.utils.collections.SparseArrayLinkedList<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback failureCallback, boolean fixBadTX) throws Exception -
scheduleCompactAndBlock
Description copied from interface:JournalThis method will start compact using the compactorExecutor and block up to timeout seconds- Specified by:
scheduleCompactAndBlockin interfaceJournal- Parameters:
timeout- the timeout in seconds or block forever if<= 0- Throws:
Exception
-
compact
public void compact()Note: This method can't be called from the main executor, as it will invoke other methods depending on it.Note: only synchronized methods on journal are methods responsible for the life-cycle such as stop, start records will still come as this is being executed
-
load
Load data accordingly to the record layouts
Basic record layout:
Field Name Size RecordType Byte (1) FileID Integer (4 bytes) Compactor Counter 1 byte TransactionID (if record is transactional) Long (8 bytes) RecordID Long (8 bytes) BodySize(Add, update and delete) Integer (4 bytes) UserDefinedRecordType (If add/update only) Byte (1) RecordBody Byte Array (size=BodySize) Check Size Integer (4 bytes) The check-size is used to validate if the record is valid and complete
Commit/Prepare record layout:
Field Name Size RecordType Byte (1) FileID Integer (4 bytes) Compactor Counter 1 byte TransactionID (if record is transactional) Long (8 bytes) ExtraDataLength (Prepares only) Integer (4 bytes) Number Of Files (N) Integer (4 bytes) ExtraDataBytes Bytes (sized by ExtraDataLength) * FileID(n) Integer (4 bytes) * NumberOfElements(n) Integer (4 bytes) CheckSize Integer (4 bytes) * FileID and NumberOfElements are the transaction summary, and they will be repeated (N)umberOfFiles times
-
processBackupCleanup
public void processBackupCleanup()Description copied from interface:JournalIt will check max files and max days on files and remove extra files.- Specified by:
processBackupCleanupin interfaceJournal
-
processBackup
public void processBackup()With the exception of initialization, this has to be always called within the compactorExecutor- Specified by:
processBackupin interfaceJournal
-
getHistoryFileName
-
removeBackupExtension
-
getDatePortionMillis
-
getDatePortion
-
checkReclaimStatus
- Specified by:
checkReclaimStatusin interfaceTestableJournal- Throws:
Exception
-
setAutoReclaim
public final void setAutoReclaim(boolean autoReclaim) - Specified by:
setAutoReclaimin interfaceTestableJournal
-
isAutoReclaim
public final boolean isAutoReclaim()- Specified by:
isAutoReclaimin interfaceTestableJournal
-
debug
- Specified by:
debugin interfaceTestableJournal- Throws:
Exception
-
debugWait
Method for use on testcases. It will call waitComplete on every transaction, so any assertions on the file system will be correct after this- Specified by:
debugWaitin interfaceTestableJournal- Throws:
InterruptedException
-
flush
Description copied from interface:JournalIt will make sure there are no more pending operations on the Executors. -
getMaxRecordSize
public long getMaxRecordSize()The max size record that can be stored in the journal- Specified by:
getMaxRecordSizein interfaceJournal- Returns:
- the max size record that can be stored in the journal
-
getWarningRecordSize
public long getWarningRecordSize()- Specified by:
getWarningRecordSizein interfaceJournal
-
flushAppendExecutor
- Throws:
InterruptedException
-
getDataFilesCount
public int getDataFilesCount()- Specified by:
getDataFilesCountin interfaceTestableJournal
-
getDataFiles
Description copied from interface:JournalReturns array with allJournalFiles in use.- Specified by:
getDataFilesin interfaceJournal- Specified by:
getDataFilesin interfaceTestableJournal- Returns:
- array with all
JournalFiles in use
-
getFreeFilesCount
public int getFreeFilesCount()- Specified by:
getFreeFilesCountin interfaceTestableJournal
-
getOpenedFilesCount
public int getOpenedFilesCount()- Specified by:
getOpenedFilesCountin interfaceTestableJournal
-
getIDMapSize
public int getIDMapSize()- Specified by:
getIDMapSizein interfaceTestableJournal
-
getFileSize
public int getFileSize()- Specified by:
getFileSizein interfaceJournal- Specified by:
getFileSizein interfaceTestableJournal
-
getMinFiles
public int getMinFiles()- Specified by:
getMinFilesin interfaceTestableJournal
-
getFilePrefix
- Specified by:
getFilePrefixin interfaceTestableJournal
-
getFileExtension
- Specified by:
getFileExtensionin interfaceTestableJournal
-
getMaxAIO
public int getMaxAIO()- Specified by:
getMaxAIOin interfaceTestableJournal
-
getUserVersion
public int getUserVersion()- Specified by:
getUserVersionin interfaceJournal
-
forceMoveNextFile
Description copied from interface:JournalForce the usage of a newJournalFile.- Specified by:
forceMoveNextFilein interfaceJournal- Specified by:
forceMoveNextFilein interfaceTestableJournal- Throws:
Exception
-
forceBackup
- Specified by:
forceBackupin interfaceJournal- Throws:
Exception
-
isStarted
public boolean isStarted()- Specified by:
isStartedin interfaceorg.apache.activemq.artemis.core.server.ActiveMQComponent
-
start
public void start()- Specified by:
startin interfaceorg.apache.activemq.artemis.core.server.ActiveMQComponent
-
stop
- Specified by:
stopin interfaceorg.apache.activemq.artemis.core.server.ActiveMQComponent- Throws:
Exception
-
getNumberOfRecords
public int getNumberOfRecords()- Specified by:
getNumberOfRecordsin interfaceJournal
-
createControlFile
protected SequentialFile createControlFile(List<JournalFile> files, List<JournalFile> newFiles, Pair<String, String> cleanupRename) throws Exception- Throws:
Exception
-
writeControlFile
protected SequentialFile writeControlFile(SequentialFileFactory fileFactory, List<JournalFile> files, List<JournalFile> newFiles, List<Pair<String, String>> renames) throws Exception- Throws:
Exception
-
deleteControlFile
- Throws:
Exception
-
renameFiles
being protected as testcases can override this method- Throws:
Exception
-
renameExtensionFile
-
onCompactStart
This is an interception point for testcases, when the compacted files are written, before replacing the data structures- Throws:
Exception
-
onCompactLockingTheJournal
This is an interception point for testcases, when the compacted files are written, to be called as soon as the compactor gets a writeLock- Throws:
Exception
-
onCompactDone
protected void onCompactDone()This is an interception point for testcases, when the compacted files are written, before replacing the data structures -
readFileHeader
- Throws:
Exception
-
initFileHeader
public static int initFileHeader(SequentialFileFactory fileFactory, SequentialFile sequentialFile, int userVersion, long fileID) throws Exception - Throws:
Exception
-
writeHeader
-
synchronizationLock
public final void synchronizationLock()Description copied from interface:JournalWrite lock the Journal and write lock the compacting process. Necessary only during replication for backup synchronization.- Specified by:
synchronizationLockin interfaceJournal
-
synchronizationUnlock
public final void synchronizationUnlock()Description copied from interface:JournalUnlock the Journal and the compacting process.- Specified by:
synchronizationUnlockin interfaceJournal- See Also:
-
createFilesForBackupSync
Returns map with the IDs and correspondingJournalFiles; these are the files needed to be sent to a backup in order to synchronize it.- Specified by:
createFilesForBackupSyncin interfaceJournal- Parameters:
fileIds- IDs to reserve for synchronization- Returns:
- map with the IDs and corresponding
JournalFiles; these are the files needed to be sent to a backup in order to synchronize it - Throws:
Exception
-
getFileFactory
- Specified by:
getFileFactoryin interfaceJournal
-
setUpCurrentFile
- Throws:
Exception
-
switchFileIfNecessary
- Throws:
Exception
-
moveNextFile
You need to guarantee lock.acquire() before calling this method!- Throws:
Exception
-
replicationSyncPreserveOldFiles
public void replicationSyncPreserveOldFiles()Description copied from interface:JournalStops any operation that may delete or modify old (stale) data.Meant to be used during synchronization of data between a replicating server and its replica. Old files must not be compacted or deleted during synchronization.
- Specified by:
replicationSyncPreserveOldFilesin interfaceJournal
-
replicationSyncFinished
public void replicationSyncFinished()Description copied from interface:JournalRestarts file reclaim and compacting on the journal.Meant to be used to revert the effect of
Journal.replicationSyncPreserveOldFiles(). it should only be called once the synchronization of the replica and replicating servers is completed.- Specified by:
replicationSyncFinishedin interfaceJournal
-
testCompact
public void testCompact()- Specified by:
testCompactin interfaceTestableJournal
-
getCompactCount
public int getCompactCount()For tests only -
setRemoveExtraFilesOnLoad
public void setRemoveExtraFilesOnLoad(boolean setting) - Specified by:
setRemoveExtraFilesOnLoadin interfaceJournal
-
isRemoveExtraFilesOnLoad
public boolean isRemoveExtraFilesOnLoad()- Specified by:
isRemoveExtraFilesOnLoadin interfaceJournal
-
appendAddRecord
- Specified by:
appendAddRecordin interfaceJournal- Throws:
Exception
-
appendAddRecord
public void appendAddRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync) throws Exception - Specified by:
appendAddRecordin interfaceJournal- Throws:
Exception
-
appendCommitRecord
- Specified by:
appendCommitRecordin interfaceJournal- Throws:
Exception
-
appendCommitRecord
- Specified by:
appendCommitRecordin interfaceJournal- Throws:
Exception
-
appendUpdateRecord
public void appendUpdateRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception - Specified by:
appendUpdateRecordin interfaceJournal- Throws:
Exception
-
tryAppendUpdateRecord
public void tryAppendUpdateRecord(long id, byte recordType, byte[] record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceableRecord) throws Exception - Specified by:
tryAppendUpdateRecordin interfaceJournal- Throws:
Exception
-
appendUpdateRecordTransactional
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, byte[] record) throws Exception - Specified by:
appendUpdateRecordTransactionalin interfaceJournal- Throws:
Exception
-
appendAddRecordTransactional
public void appendAddRecordTransactional(long txID, long id, byte recordType, byte[] record) throws Exception - Specified by:
appendAddRecordTransactionalin interfaceJournal- Throws:
Exception
-
appendDeleteRecordTransactional
- Specified by:
appendDeleteRecordTransactionalin interfaceJournal- Throws:
Exception
-
appendPrepareRecord
- Specified by:
appendPrepareRecordin interfaceJournal- Throws:
Exception
-
appendPrepareRecord
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync) throws Exception Description copied from interface:JournalIf 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.- Specified by:
appendPrepareRecordin interfaceJournaltransactionData- allows you to store any extra supporting user-data related to the transaction- Throws:
Exception
-
appendDeleteRecordTransactional
- Specified by:
appendDeleteRecordTransactionalin interfaceJournal- Throws:
Exception
-
appendUpdateRecord
public void appendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, boolean sync) throws Exception - Specified by:
appendUpdateRecordin interfaceJournal- Throws:
Exception
-
tryAppendUpdateRecord
public void tryAppendUpdateRecord(long id, byte recordType, org.apache.activemq.artemis.core.persistence.Persister persister, Object record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceableUpdate) throws Exception - Specified by:
tryAppendUpdateRecordin interfaceJournal- Throws:
Exception
-
appendRollbackRecord
- Specified by:
appendRollbackRecordin interfaceJournal- Throws:
Exception
-
appendDeleteRecord
- Specified by:
appendDeleteRecordin interfaceJournal- Throws:
Exception
-
tryAppendDeleteRecord
public void tryAppendDeleteRecord(long id, JournalUpdateCallback updateCallback, boolean sync) throws Exception - Specified by:
tryAppendDeleteRecordin interfaceJournal- Throws:
Exception
-
getSyncCallback
-