Class ReplicatedJournal
- java.lang.Object
-
- org.apache.activemq.artemis.core.replication.ReplicatedJournal
-
- All Implemented Interfaces:
Journal,ActiveMQComponent
public class ReplicatedJournal extends Object implements Journal
Used by theJournalStorageManagerto replicate journal calls.This class wraps a
ReplicationManagerand the localJournal. Every call will be relayed to both instances.- See Also:
JournalStorageManager
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.activemq.artemis.core.journal.Journal
Journal.JournalState
-
-
Constructor Summary
Constructors Constructor Description ReplicatedJournal(byte journalID, Journal localJournal, ReplicationManager replicationManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendAddEvent(long id, byte recordType, Persister persister, Object record, boolean sync, IOCompletion completionCallback)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, Persister persister, Object record, boolean sync)voidappendAddRecord(long id, byte recordType, Persister persister, Object record, boolean sync, IOCompletion completionCallback)voidappendAddRecordTransactional(long txID, long id, byte recordType, byte[] record)voidappendAddRecordTransactional(long txID, long id, byte recordType, 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)voidappendDeleteRecord(long id, boolean sync)voidappendDeleteRecord(long id, boolean sync, IOCompletion completionCallback)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)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, Persister persister, Object record, boolean sync)voidappendUpdateRecord(long id, byte journalRecordType, Persister persister, Object record, boolean sync, IOCompletion completionCallback)voidappendUpdateRecordTransactional(long txID, long id, byte recordType, byte[] record)voidappendUpdateRecordTransactional(long txID, long id, byte recordType, Persister persister, Object record)Map<Long,JournalFile>createFilesForBackupSync(long[] fileIds)Reserves journal file IDs, creates the necessary files for synchronization, and places references to these (reserved for sync) files in the map.voidflush()It will make sure there are no more pending operations on the Executors.voidforceMoveNextFile()Force the usage of a newJournalFile.intgetAlignment()JournalFile[]getDataFiles()Returns theJournalFiles in use.SequentialFileFactorygetFileFactory()intgetFileSize()longgetMaxRecordSize()The max size record that can be stored in the journalintgetNumberOfRecords()intgetUserVersion()booleanisRemoveExtraFilesOnLoad()booleanisStarted()voidlineUpContext(IOCompletion callback)JournalLoadInformationload(List<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback transactionFailure, boolean fixbadTX)JournalLoadInformationload(LoaderCallback reloadManager)JournalLoadInformationload(SparseArrayLinkedList<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback transactionFailure, boolean fixbadTX)JournalLoadInformationloadInternalOnly()Load internal data structures and not expose any data.JournalLoadInformationloadSyncOnly(Journal.JournalState state)Load internal data structures, and remain waiting for synchronization to complete.voidreplicationSyncFinished()Restarts file reclaim and compacting on the journal.voidreplicationSyncPreserveOldFiles()Stops 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 secondsvoidsetRemoveExtraFilesOnLoad(boolean removeExtraFilesOnLoad)voidstart()voidstop()voidsynchronizationLock()Write lock the Journal and write lock the compacting process.voidsynchronizationUnlock()Unlock the Journal and the compacting process.voidtryAppendDeleteRecord(long id, boolean sync, JournalUpdateCallback updateCallback, IOCompletion completionCallback)voidtryAppendDeleteRecord(long id, JournalUpdateCallback updateCallback, boolean sync)voidtryAppendUpdateRecord(long id, byte recordType, byte[] record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceableRecord)voidtryAppendUpdateRecord(long id, byte journalRecordType, Persister persister, Object record, boolean sync, boolean replaceableUpdate, JournalUpdateCallback updateCallback, IOCompletion completionCallback)voidtryAppendUpdateRecord(long id, byte recordType, Persister persister, Object record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceable)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.core.server.ActiveMQComponent
asyncStop
-
Methods inherited from interface org.apache.activemq.artemis.core.journal.Journal
appendAddRecord, appendAddRecord, appendAddRecordTransactional, appendUpdateRecord, appendUpdateRecord, appendUpdateRecordTransactional, forceBackup, getCriticalErrorListener, isHistory, load, load, processBackup, processBackupCleanup, replaceableRecord, setCriticalErrorListener, setHistoryFolder, tryAppendUpdateRecord, tryAppendUpdateRecord
-
-
-
-
Constructor Detail
-
ReplicatedJournal
public ReplicatedJournal(byte journalID, Journal localJournal, ReplicationManager replicationManager)
-
-
Method Detail
-
setRemoveExtraFilesOnLoad
public void setRemoveExtraFilesOnLoad(boolean removeExtraFilesOnLoad)
- Specified by:
setRemoveExtraFilesOnLoadin interfaceJournal
-
isRemoveExtraFilesOnLoad
public boolean isRemoveExtraFilesOnLoad()
- Specified by:
isRemoveExtraFilesOnLoadin interfaceJournal
-
flush
public void flush() throws ExceptionDescription copied from interface:JournalIt will make sure there are no more pending operations on the Executors.
-
appendAddRecord
public void appendAddRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception- Specified by:
appendAddRecordin interfaceJournal- Parameters:
id-recordType-record-sync-- Throws:
Exception- See Also:
Journal.appendAddRecord(long, byte, byte[], boolean)
-
appendAddRecord
public void appendAddRecord(long id, byte recordType, Persister persister, Object record, boolean sync) throws Exception- Specified by:
appendAddRecordin interfaceJournal- Throws:
Exception
-
appendAddRecord
public void appendAddRecord(long id, byte recordType, Persister persister, Object record, boolean sync, IOCompletion completionCallback) throws Exception- Specified by:
appendAddRecordin interfaceJournal- Parameters:
id-recordType-record-sync-- Throws:
Exception- See Also:
Journal.appendAddRecord(long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport, boolean)
-
appendAddEvent
public void appendAddEvent(long id, byte recordType, Persister persister, Object record, boolean sync, IOCompletion completionCallback) throws ExceptionDescription 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
-
appendAddRecordTransactional
public void appendAddRecordTransactional(long txID, long id, byte recordType, byte[] record) throws Exception- Specified by:
appendAddRecordTransactionalin interfaceJournal- Parameters:
txID-id-recordType-record-- Throws:
Exception- See Also:
Journal.appendAddRecordTransactional(long, long, byte, byte[])
-
appendAddRecordTransactional
public void appendAddRecordTransactional(long txID, long id, byte recordType, Persister persister, Object record) throws Exception- Specified by:
appendAddRecordTransactionalin interfaceJournal- Parameters:
txID-id-recordType-record-- Throws:
Exception- See Also:
Journal.appendAddRecordTransactional(long, long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport)
-
appendCommitRecord
public void appendCommitRecord(long txID, boolean sync) throws Exception- Specified by:
appendCommitRecordin interfaceJournal- Parameters:
txID-sync-- Throws:
Exception- See Also:
Journal.appendCommitRecord(long, boolean)
-
appendCommitRecord
public void appendCommitRecord(long txID, boolean sync, IOCompletion callback) throws Exception- Specified by:
appendCommitRecordin interfaceJournal- Throws:
Exception
-
appendCommitRecord
public void appendCommitRecord(long txID, boolean sync, IOCompletion callback, boolean lineUpContext) throws Exception- Specified by:
appendCommitRecordin interfaceJournallineUpContext- if appendCommitRecord should call a storeLineUp. This is because the caller may have already taken into account- Throws:
Exception
-
appendDeleteRecord
public void appendDeleteRecord(long id, boolean sync) throws Exception- Specified by:
appendDeleteRecordin interfaceJournal- Parameters:
id-sync-- Throws:
Exception- See Also:
Journal.appendDeleteRecord(long, boolean)
-
tryAppendDeleteRecord
public void tryAppendDeleteRecord(long id, JournalUpdateCallback updateCallback, boolean sync) throws Exception- Specified by:
tryAppendDeleteRecordin interfaceJournal- Parameters:
id-sync-- Throws:
Exception- See Also:
Journal.appendDeleteRecord(long, boolean)
-
appendDeleteRecord
public void appendDeleteRecord(long id, boolean sync, IOCompletion completionCallback) throws Exception- Specified by:
appendDeleteRecordin interfaceJournal- Throws:
Exception
-
tryAppendDeleteRecord
public void tryAppendDeleteRecord(long id, boolean sync, JournalUpdateCallback updateCallback, IOCompletion completionCallback) throws Exception- Specified by:
tryAppendDeleteRecordin interfaceJournal- Throws:
Exception
-
appendDeleteRecordTransactional
public void appendDeleteRecordTransactional(long txID, long id, byte[] record) throws Exception- Specified by:
appendDeleteRecordTransactionalin interfaceJournal- Parameters:
txID-id-record-- Throws:
Exception- See Also:
Journal.appendDeleteRecordTransactional(long, long, byte[])
-
appendDeleteRecordTransactional
public void appendDeleteRecordTransactional(long txID, long id, EncodingSupport record) throws Exception- Specified by:
appendDeleteRecordTransactionalin interfaceJournal- Parameters:
txID-id-record-- Throws:
Exception- See Also:
Journal.appendDeleteRecordTransactional(long, long, org.apache.activemq.artemis.core.journal.EncodingSupport)
-
appendDeleteRecordTransactional
public void appendDeleteRecordTransactional(long txID, long id) throws Exception- Specified by:
appendDeleteRecordTransactionalin interfaceJournal- Parameters:
txID-id-- Throws:
Exception- See Also:
Journal.appendDeleteRecordTransactional(long, long)
-
appendPrepareRecord
public void appendPrepareRecord(long txID, byte[] transactionData, boolean sync) throws Exception- Specified by:
appendPrepareRecordin interfaceJournal- Parameters:
txID-transactionData-sync-- Throws:
Exception- See Also:
Journal.appendPrepareRecord(long, byte[], boolean)
-
appendPrepareRecord
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync) throws ExceptionDescription 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.
transactionData allows you to store any other supporting user-data related to the transaction
- Specified by:
appendPrepareRecordin interfaceJournal- Parameters:
txID-transactionData-sync-- Throws:
Exception- See Also:
Journal.appendPrepareRecord(long, org.apache.activemq.artemis.core.journal.EncodingSupport, boolean)
-
appendPrepareRecord
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync, IOCompletion callback) throws Exception- Specified by:
appendPrepareRecordin interfaceJournal- Throws:
Exception
-
appendRollbackRecord
public void appendRollbackRecord(long txID, boolean sync) throws Exception- Specified by:
appendRollbackRecordin interfaceJournal- Parameters:
txID-sync-- Throws:
Exception- See Also:
Journal.appendRollbackRecord(long, boolean)
-
appendRollbackRecord
public void appendRollbackRecord(long txID, boolean sync, IOCompletion callback) throws Exception- Specified by:
appendRollbackRecordin interfaceJournal- Throws:
Exception
-
appendUpdateRecord
public void appendUpdateRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception- Specified by:
appendUpdateRecordin interfaceJournal- Parameters:
id-recordType-record-sync-- Throws:
Exception- See Also:
Journal.appendUpdateRecord(long, byte, byte[], boolean)
-
tryAppendUpdateRecord
public void tryAppendUpdateRecord(long id, byte recordType, byte[] record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceableRecord) throws Exception- Specified by:
tryAppendUpdateRecordin interfaceJournal- Throws:
Exception
-
appendUpdateRecord
public void appendUpdateRecord(long id, byte recordType, Persister persister, Object record, boolean sync) throws Exception- Specified by:
appendUpdateRecordin interfaceJournal- Parameters:
id-recordType-record-sync-- Throws:
Exception- See Also:
Journal.appendUpdateRecord(long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport, boolean)
-
tryAppendUpdateRecord
public void tryAppendUpdateRecord(long id, byte recordType, Persister persister, Object record, JournalUpdateCallback updateCallback, boolean sync, boolean replaceable) throws Exception- Specified by:
tryAppendUpdateRecordin interfaceJournal- Throws:
Exception
-
appendUpdateRecord
public void appendUpdateRecord(long id, byte journalRecordType, Persister persister, Object record, boolean sync, IOCompletion completionCallback) throws Exception- Specified by:
appendUpdateRecordin interfaceJournal- Throws:
Exception
-
tryAppendUpdateRecord
public void tryAppendUpdateRecord(long id, byte journalRecordType, Persister persister, Object record, boolean sync, boolean replaceableUpdate, JournalUpdateCallback updateCallback, IOCompletion completionCallback) 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- Parameters:
txID-id-recordType-record-- Throws:
Exception- See Also:
Journal.appendUpdateRecordTransactional(long, long, byte, byte[])
-
appendUpdateRecordTransactional
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, Persister persister, Object record) throws Exception- Specified by:
appendUpdateRecordTransactionalin interfaceJournal- Parameters:
txID-id-recordType-record-- Throws:
Exception- See Also:
Journal.appendUpdateRecordTransactional(long, long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport)
-
load
public JournalLoadInformation load(List<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback transactionFailure, boolean fixbadTX) throws Exception
- Specified by:
loadin interfaceJournal- Parameters:
committedRecords-preparedTransactions-transactionFailure-- Throws:
Exception- See Also:
Journal.load(java.util.List, java.util.List, org.apache.activemq.artemis.core.journal.TransactionFailureCallback)
-
load
public JournalLoadInformation load(SparseArrayLinkedList<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback transactionFailure, boolean fixbadTX) throws Exception
- Specified by:
loadin interfaceJournal- Parameters:
committedRecords-preparedTransactions-transactionFailure-- Throws:
Exception- See Also:
Journal.load(java.util.List, java.util.List, org.apache.activemq.artemis.core.journal.TransactionFailureCallback)
-
load
public JournalLoadInformation load(LoaderCallback reloadManager) throws Exception
- Specified by:
loadin interfaceJournal- Parameters:
reloadManager-- Throws:
Exception- See Also:
Journal.load(org.apache.activemq.artemis.core.journal.LoaderCallback)
-
start
public void start() throws Exception- Specified by:
startin interfaceActiveMQComponent- Throws:
Exception- See Also:
ActiveMQComponent.start()
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceActiveMQComponent- Throws:
Exception- See Also:
ActiveMQComponent.stop()
-
getAlignment
public int getAlignment() throws Exception- Specified by:
getAlignmentin interfaceJournal- Throws:
Exception
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceActiveMQComponent
-
loadInternalOnly
public JournalLoadInformation loadInternalOnly() throws Exception
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
-
getNumberOfRecords
public int getNumberOfRecords()
- Specified by:
getNumberOfRecordsin interfaceJournal
-
getUserVersion
public int getUserVersion()
- Specified by:
getUserVersionin interfaceJournal
-
lineUpContext
public void lineUpContext(IOCompletion callback)
- Specified by:
lineUpContextin interfaceJournal
-
loadSyncOnly
public JournalLoadInformation loadSyncOnly(Journal.JournalState state) throws Exception
Description copied from interface:JournalLoad internal data structures, and remain waiting for synchronization to complete.- Specified by:
loadSyncOnlyin interfaceJournal- Parameters:
state- the current state of the journal, this parameter ensures consistency.- Throws:
Exception
-
createFilesForBackupSync
public Map<Long,JournalFile> createFilesForBackupSync(long[] fileIds) throws Exception
Description copied from interface:JournalReserves 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.
- Specified by:
createFilesForBackupSyncin interfaceJournal- Parameters:
fileIds- IDs to reserve for synchronization- Returns:
- map to be filled with id and journal file pairs for synchronization.
- Throws:
Exception
-
synchronizationLock
public 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 void synchronizationUnlock()
Description copied from interface:JournalUnlock the Journal and the compacting process.- Specified by:
synchronizationUnlockin interfaceJournal- See Also:
Journal.synchronizationLock()
-
forceMoveNextFile
public void forceMoveNextFile() throws ExceptionDescription copied from interface:JournalForce the usage of a newJournalFile.- Specified by:
forceMoveNextFilein interfaceJournal- Throws:
Exception
-
getDataFiles
public JournalFile[] getDataFiles()
Description copied from interface:JournalReturns theJournalFiles in use.- Specified by:
getDataFilesin interfaceJournal- Returns:
- array with all
JournalFiles in use
-
getFileFactory
public SequentialFileFactory getFileFactory()
- Specified by:
getFileFactoryin interfaceJournal
-
getFileSize
public int getFileSize()
- Specified by:
getFileSizein interfaceJournal
-
scheduleCompactAndBlock
public void scheduleCompactAndBlock(int timeout) throws ExceptionDescription 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
-
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 live server and its replicating (remote) backup. 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 backup and live servers is completed.- Specified by:
replicationSyncFinishedin interfaceJournal
-
getMaxRecordSize
public long getMaxRecordSize()
Description copied from interface:JournalThe max size record that can be stored in the journal- Specified by:
getMaxRecordSizein interfaceJournal- Returns:
-
-