public class ReplicatedJournal extends Object implements Journal
JournalStorageManager
to replicate journal calls.
This class wraps a ReplicationManager
and the local Journal
. Every call will be
relayed to both instances.
JournalStorageManager
Journal.JournalState
Constructor and Description |
---|
ReplicatedJournal(byte journalID,
Journal localJournal,
ReplicationManager replicationManager) |
Modifier and Type | Method and Description |
---|---|
void |
appendAddRecord(long id,
byte recordType,
byte[] record,
boolean sync) |
void |
appendAddRecord(long id,
byte recordType,
EncodingSupport record,
boolean sync) |
void |
appendAddRecord(long id,
byte recordType,
EncodingSupport record,
boolean sync,
IOCompletion completionCallback) |
void |
appendAddRecordTransactional(long txID,
long id,
byte recordType,
byte[] record) |
void |
appendAddRecordTransactional(long txID,
long id,
byte recordType,
EncodingSupport record) |
void |
appendCommitRecord(long txID,
boolean sync) |
void |
appendCommitRecord(long txID,
boolean sync,
IOCompletion callback) |
void |
appendCommitRecord(long txID,
boolean sync,
IOCompletion callback,
boolean lineUpContext) |
void |
appendDeleteRecord(long id,
boolean sync) |
void |
appendDeleteRecord(long id,
boolean sync,
IOCompletion completionCallback) |
void |
appendDeleteRecordTransactional(long txID,
long id) |
void |
appendDeleteRecordTransactional(long txID,
long id,
byte[] record) |
void |
appendDeleteRecordTransactional(long txID,
long id,
EncodingSupport record) |
void |
appendPrepareRecord(long txID,
byte[] transactionData,
boolean sync) |
void |
appendPrepareRecord(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.
|
void |
appendPrepareRecord(long txID,
EncodingSupport transactionData,
boolean sync,
IOCompletion callback) |
void |
appendRollbackRecord(long txID,
boolean sync) |
void |
appendRollbackRecord(long txID,
boolean sync,
IOCompletion callback) |
void |
appendUpdateRecord(long id,
byte recordType,
byte[] record,
boolean sync) |
void |
appendUpdateRecord(long id,
byte recordType,
EncodingSupport record,
boolean sync) |
void |
appendUpdateRecord(long id,
byte journalRecordType,
EncodingSupport record,
boolean sync,
IOCompletion completionCallback) |
void |
appendUpdateRecordTransactional(long txID,
long id,
byte recordType,
byte[] record) |
void |
appendUpdateRecordTransactional(long txID,
long id,
byte recordType,
EncodingSupport 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.
|
void |
flush()
It will make sure there are no more pending operations on the Executors.
|
void |
forceMoveNextFile()
Force the usage of a new
JournalFile . |
int |
getAlignment() |
JournalFile[] |
getDataFiles()
Returns the
JournalFile s in use. |
SequentialFileFactory |
getFileFactory() |
int |
getFileSize() |
int |
getNumberOfRecords() |
int |
getUserVersion() |
boolean |
isStarted() |
void |
lineUpContext(IOCompletion callback) |
JournalLoadInformation |
load(List<RecordInfo> committedRecords,
List<PreparedTransactionInfo> preparedTransactions,
TransactionFailureCallback transactionFailure) |
JournalLoadInformation |
load(LoaderCallback reloadManager) |
JournalLoadInformation |
loadInternalOnly()
Load internal data structures and not expose any data.
|
JournalLoadInformation |
loadSyncOnly(Journal.JournalState state)
Load internal data structures, and remain waiting for synchronization to complete.
|
void |
perfBlast(int pages) |
void |
replicationSyncFinished()
Restarts file reclaim and compacting on the journal.
|
void |
replicationSyncPreserveOldFiles()
Stops any operation that may delete or modify old (stale) data.
|
void |
runDirectJournalBlast() |
void |
scheduleCompactAndBlock(int timeout)
This method will start compact using the compactorExecutor and block up to timeout seconds
|
void |
start() |
void |
stop() |
void |
synchronizationLock()
Write lock the Journal and write lock the compacting process.
|
void |
synchronizationUnlock()
Unlock the Journal and the compacting process.
|
public ReplicatedJournal(byte journalID, Journal localJournal, ReplicationManager replicationManager)
public void flush() throws Exception
Journal
public void appendAddRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception
appendAddRecord
in interface Journal
id
- recordType
- record
- sync
- Exception
Journal.appendAddRecord(long, byte, byte[], boolean)
public void appendAddRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception
appendAddRecord
in interface Journal
Exception
public void appendAddRecord(long id, byte recordType, EncodingSupport record, boolean sync, IOCompletion completionCallback) throws Exception
appendAddRecord
in interface Journal
id
- recordType
- record
- sync
- Exception
Journal.appendAddRecord(long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport, boolean)
public void appendAddRecordTransactional(long txID, long id, byte recordType, byte[] record) throws Exception
appendAddRecordTransactional
in interface Journal
txID
- id
- recordType
- record
- Exception
Journal.appendAddRecordTransactional(long, long, byte, byte[])
public void appendAddRecordTransactional(long txID, long id, byte recordType, EncodingSupport record) throws Exception
appendAddRecordTransactional
in interface Journal
txID
- id
- recordType
- record
- Exception
Journal.appendAddRecordTransactional(long, long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport)
public void appendCommitRecord(long txID, boolean sync) throws Exception
appendCommitRecord
in interface Journal
txID
- sync
- Exception
Journal.appendCommitRecord(long, boolean)
public void appendCommitRecord(long txID, boolean sync, IOCompletion callback) throws Exception
appendCommitRecord
in interface Journal
Exception
public void appendCommitRecord(long txID, boolean sync, IOCompletion callback, boolean lineUpContext) throws Exception
appendCommitRecord
in interface Journal
lineUpContext
- if appendCommitRecord should call a storeLineUp. This is because the
caller may have already taken into accountException
public void appendDeleteRecord(long id, boolean sync) throws Exception
appendDeleteRecord
in interface Journal
id
- sync
- Exception
Journal.appendDeleteRecord(long, boolean)
public void appendDeleteRecord(long id, boolean sync, IOCompletion completionCallback) throws Exception
appendDeleteRecord
in interface Journal
Exception
public void appendDeleteRecordTransactional(long txID, long id, byte[] record) throws Exception
appendDeleteRecordTransactional
in interface Journal
txID
- id
- record
- Exception
Journal.appendDeleteRecordTransactional(long, long, byte[])
public void appendDeleteRecordTransactional(long txID, long id, EncodingSupport record) throws Exception
appendDeleteRecordTransactional
in interface Journal
txID
- id
- record
- Exception
Journal.appendDeleteRecordTransactional(long, long, org.apache.activemq.artemis.core.journal.EncodingSupport)
public void appendDeleteRecordTransactional(long txID, long id) throws Exception
appendDeleteRecordTransactional
in interface Journal
txID
- id
- Exception
Journal.appendDeleteRecordTransactional(long, long)
public void appendPrepareRecord(long txID, byte[] transactionData, boolean sync) throws Exception
appendPrepareRecord
in interface Journal
txID
- transactionData
- sync
- Exception
Journal.appendPrepareRecord(long, byte[], boolean)
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync) throws Exception
Journal
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
appendPrepareRecord
in interface Journal
txID
- transactionData
- sync
- Exception
Journal.appendPrepareRecord(long, org.apache.activemq.artemis.core.journal.EncodingSupport, boolean)
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync, IOCompletion callback) throws Exception
appendPrepareRecord
in interface Journal
Exception
public void appendRollbackRecord(long txID, boolean sync) throws Exception
appendRollbackRecord
in interface Journal
txID
- sync
- Exception
Journal.appendRollbackRecord(long, boolean)
public void appendRollbackRecord(long txID, boolean sync, IOCompletion callback) throws Exception
appendRollbackRecord
in interface Journal
Exception
public void appendUpdateRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception
appendUpdateRecord
in interface Journal
id
- recordType
- record
- sync
- Exception
Journal.appendUpdateRecord(long, byte, byte[], boolean)
public void appendUpdateRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception
appendUpdateRecord
in interface Journal
id
- recordType
- record
- sync
- Exception
Journal.appendUpdateRecord(long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport, boolean)
public void appendUpdateRecord(long id, byte journalRecordType, EncodingSupport record, boolean sync, IOCompletion completionCallback) throws Exception
appendUpdateRecord
in interface Journal
Exception
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, byte[] record) throws Exception
appendUpdateRecordTransactional
in interface Journal
txID
- id
- recordType
- record
- Exception
Journal.appendUpdateRecordTransactional(long, long, byte, byte[])
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, EncodingSupport record) throws Exception
appendUpdateRecordTransactional
in interface Journal
txID
- id
- recordType
- record
- Exception
Journal.appendUpdateRecordTransactional(long, long, byte, org.apache.activemq.artemis.core.journal.EncodingSupport)
public JournalLoadInformation load(List<RecordInfo> committedRecords, List<PreparedTransactionInfo> preparedTransactions, TransactionFailureCallback transactionFailure) throws Exception
load
in interface Journal
committedRecords
- preparedTransactions
- transactionFailure
- Exception
Journal.load(java.util.List, java.util.List, org.apache.activemq.artemis.core.journal.TransactionFailureCallback)
public JournalLoadInformation load(LoaderCallback reloadManager) throws Exception
load
in interface Journal
reloadManager
- Exception
Journal.load(org.apache.activemq.artemis.core.journal.LoaderCallback)
public void perfBlast(int pages)
perfBlast
in interface Journal
pages
- Journal.perfBlast(int)
public void start() throws Exception
start
in interface ActiveMQComponent
Exception
ActiveMQComponent.start()
public void stop() throws Exception
stop
in interface ActiveMQComponent
Exception
ActiveMQComponent.stop()
public int getAlignment() throws Exception
getAlignment
in interface Journal
Exception
public boolean isStarted()
isStarted
in interface ActiveMQComponent
public JournalLoadInformation loadInternalOnly() throws Exception
Journal
loadInternalOnly
in interface Journal
Exception
public int getNumberOfRecords()
getNumberOfRecords
in interface Journal
public void runDirectJournalBlast() throws Exception
runDirectJournalBlast
in interface Journal
Exception
public int getUserVersion()
getUserVersion
in interface Journal
public void lineUpContext(IOCompletion callback)
lineUpContext
in interface Journal
public JournalLoadInformation loadSyncOnly(Journal.JournalState state) throws Exception
Journal
loadSyncOnly
in interface Journal
state
- the current state of the journal, this parameter ensures consistency.Exception
public Map<Long,JournalFile> createFilesForBackupSync(long[] fileIds) throws Exception
Journal
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.
createFilesForBackupSync
in interface Journal
fileIds
- IDs to reserve for synchronizationException
public void synchronizationLock()
Journal
synchronizationLock
in interface Journal
public void synchronizationUnlock()
Journal
synchronizationUnlock
in interface Journal
Journal.synchronizationLock()
public void forceMoveNextFile()
Journal
JournalFile
.forceMoveNextFile
in interface Journal
public JournalFile[] getDataFiles()
Journal
JournalFile
s in use.getDataFiles
in interface Journal
JournalFile
s in usepublic SequentialFileFactory getFileFactory()
getFileFactory
in interface Journal
public int getFileSize()
getFileSize
in interface Journal
public void scheduleCompactAndBlock(int timeout) throws Exception
Journal
scheduleCompactAndBlock
in interface Journal
timeout
- the timeout in seconds or block forever if <= 0
Exception
public void replicationSyncPreserveOldFiles()
Journal
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.
replicationSyncPreserveOldFiles
in interface Journal
public void replicationSyncFinished()
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.
replicationSyncFinished
in interface Journal
Copyright © 2017 JBoss by Red Hat. All rights reserved.