Class ReplicationManager
- java.lang.Object
-
- org.apache.activemq.artemis.core.replication.ReplicationManager
-
- All Implemented Interfaces:
ActiveMQComponent
public final class ReplicationManager extends Object implements ActiveMQComponent
Manages replication tasks on the live server (that is the live server side of a "remote backup" use case).Its equivalent in the backup server is
ReplicationEndpoint.- See Also:
ReplicationEndpoint
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReplicationManager.ADD_OPERATION_TYPE
-
Constructor Summary
Constructors Constructor Description ReplicationManager(ActiveMQServer server, CoreRemotingConnection remotingConnection, long timeout, long initialReplicationSyncTimeout, ExecutorFactory ioExecutorFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendAddRecordTransactional(byte journalID, ReplicationManager.ADD_OPERATION_TYPE operation, long txID, long id, byte recordType, Persister persister, Object record)voidappendCommitRecord(byte journalID, long txID, boolean sync, boolean lineUp)voidappendDeleteRecord(byte journalID, long id)voidappendDeleteRecordTransactional(byte journalID, long txID, long id)voidappendDeleteRecordTransactional(byte journalID, long txID, long id, EncodingSupport record)voidappendPrepareRecord(byte journalID, long txID, EncodingSupport transactionData)voidappendRollbackRecord(byte journalID, long txID)voidappendUpdateRecord(byte journalID, ReplicationManager.ADD_OPERATION_TYPE operation, long id, byte recordType, Persister persister, Object record)voidclearReplicationTokens()Completes any pending operations.Set<OperationContext>getActiveTokens()A list of tokens that are still waiting for replications to be completedCoreRemotingConnectiongetBackupTransportConnection()Used while stopping the server to ensure that we freeze communications with the backup.booleanisStarted()booleanisSynchronizing()voidlargeMessageBegin(long messageId)voidlargeMessageClosed(Long messageId, JournalStorageManager storageManager)voidlargeMessageDelete(Long messageId, JournalStorageManager storageManager)voidlargeMessageWrite(long messageId, byte[] body)voidpageClosed(SimpleString storeName, long pageNumber)voidpageDeleted(SimpleString storeName, long pageNumber)voidpageWrite(PagedMessage message, long pageNumber)voidsendLargeMessageIdListMessage(Map<Long,Pair<String,Long>> largeMessages)Reserves several LargeMessage IDs in the backup.OperationContextsendLiveIsStopping(ReplicationLiveIsStoppingMessage.LiveStopping finalMessage)Notifies the backup that the live server is stopping.voidsendStartSyncMessage(JournalFile[] datafiles, AbstractJournalStorageManager.JournalContent contentType, String nodeID, boolean allowsAutoFailBack)Reserve the following fileIDs in the backup server.voidsendSynchronizationDone(String nodeID, long initialReplicationSyncTimeout, IOCriticalErrorListener criticalErrorListener)Informs backup that data synchronization is done.voidstart()voidstop()voidstop(boolean clearTokens)voidsyncJournalFile(JournalFile jf, AbstractJournalStorageManager.JournalContent content)Sends the whole content of the file to be duplicated.voidsyncLargeMessageFile(SequentialFile file, long size, long id)voidsyncPages(SequentialFile file, long id, SimpleString queueName)-
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
-
-
-
-
Constructor Detail
-
ReplicationManager
public ReplicationManager(ActiveMQServer server, CoreRemotingConnection remotingConnection, long timeout, long initialReplicationSyncTimeout, ExecutorFactory ioExecutorFactory)
- Parameters:
remotingConnection-
-
-
Method Detail
-
appendUpdateRecord
public void appendUpdateRecord(byte journalID, ReplicationManager.ADD_OPERATION_TYPE operation, long id, byte recordType, Persister persister, Object record) throws Exception- Throws:
Exception
-
appendDeleteRecord
public void appendDeleteRecord(byte journalID, long id) throws Exception- Throws:
Exception
-
appendAddRecordTransactional
public void appendAddRecordTransactional(byte journalID, ReplicationManager.ADD_OPERATION_TYPE operation, long txID, long id, byte recordType, Persister persister, Object record) throws Exception- Throws:
Exception
-
appendCommitRecord
public void appendCommitRecord(byte journalID, long txID, boolean sync, boolean lineUp) throws Exception- Throws:
Exception
-
appendDeleteRecordTransactional
public void appendDeleteRecordTransactional(byte journalID, long txID, long id, EncodingSupport record) throws Exception- Throws:
Exception
-
appendDeleteRecordTransactional
public void appendDeleteRecordTransactional(byte journalID, long txID, long id) throws Exception- Throws:
Exception
-
appendPrepareRecord
public void appendPrepareRecord(byte journalID, long txID, EncodingSupport transactionData) throws Exception- Throws:
Exception
-
appendRollbackRecord
public void appendRollbackRecord(byte journalID, long txID) throws Exception- Throws:
Exception
-
pageClosed
public void pageClosed(SimpleString storeName, long pageNumber)
- Parameters:
storeName-pageNumber-
-
pageDeleted
public void pageDeleted(SimpleString storeName, long pageNumber)
-
pageWrite
public void pageWrite(PagedMessage message, long pageNumber)
-
largeMessageBegin
public void largeMessageBegin(long messageId)
-
largeMessageDelete
public void largeMessageDelete(Long messageId, JournalStorageManager storageManager)
-
largeMessageClosed
public void largeMessageClosed(Long messageId, JournalStorageManager storageManager)
-
largeMessageWrite
public void largeMessageWrite(long messageId, byte[] body)
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceActiveMQComponent
-
start
public void start() throws ActiveMQException- Specified by:
startin interfaceActiveMQComponent- Throws:
ActiveMQException
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceActiveMQComponent- Throws:
Exception
-
clearReplicationTokens
public void clearReplicationTokens()
Completes any pending operations.This can be necessary in case the live loses connection to the backup (network failure, or backup crashing).
-
getActiveTokens
public Set<OperationContext> getActiveTokens()
A list of tokens that are still waiting for replications to be completed
-
syncJournalFile
public void syncJournalFile(JournalFile jf, AbstractJournalStorageManager.JournalContent content) throws Exception
Sends the whole content of the file to be duplicated.- Throws:
ActiveMQExceptionException
-
syncLargeMessageFile
public void syncLargeMessageFile(SequentialFile file, long size, long id) throws Exception
- Throws:
Exception
-
syncPages
public void syncPages(SequentialFile file, long id, SimpleString queueName) throws Exception
- Throws:
Exception
-
sendStartSyncMessage
public void sendStartSyncMessage(JournalFile[] datafiles, AbstractJournalStorageManager.JournalContent contentType, String nodeID, boolean allowsAutoFailBack) throws ActiveMQException
Reserve the following fileIDs in the backup server.- Parameters:
datafiles-contentType-- Throws:
ActiveMQException
-
sendSynchronizationDone
public void sendSynchronizationDone(String nodeID, long initialReplicationSyncTimeout, IOCriticalErrorListener criticalErrorListener) throws ActiveMQReplicationTimeooutException
Informs backup that data synchronization is done.So if 'live' fails, the (up-to-date) backup now may take over its duties. To do so, it must know which is the live's
nodeID.- Parameters:
nodeID-- Throws:
ActiveMQReplicationTimeooutException
-
sendLargeMessageIdListMessage
public void sendLargeMessageIdListMessage(Map<Long,Pair<String,Long>> largeMessages)
Reserves several LargeMessage IDs in the backup.Doing this before hand removes the need of synchronizing large-message deletes with the largeMessageSyncList.
- Parameters:
largeMessages-
-
sendLiveIsStopping
public OperationContext sendLiveIsStopping(ReplicationLiveIsStoppingMessage.LiveStopping finalMessage)
Notifies the backup that the live server is stopping.This notification allows the backup to skip quorum voting (or any other measure to avoid 'split-brain') and do a faster fail-over.
- Returns:
-
getBackupTransportConnection
public CoreRemotingConnection getBackupTransportConnection()
Used while stopping the server to ensure that we freeze communications with the backup.- Returns:
- remoting connection with the backup
-
isSynchronizing
public boolean isSynchronizing()
- Returns:
-
-