Class JournalPersistenceAdapter
- java.lang.Object
-
- org.apache.activemq.store.journal.JournalPersistenceAdapter
-
- All Implemented Interfaces:
org.apache.activeio.journal.JournalEventListener,BrokerServiceAware,org.apache.activemq.Service,PersistenceAdapter,UsageListener
public class JournalPersistenceAdapter extends Object implements PersistenceAdapter, org.apache.activeio.journal.JournalEventListener, UsageListener, BrokerServiceAware
An implementation ofPersistenceAdapterdesigned for use with aJournaland then check pointing asynchronously on a timeout with some other long term persistent storage.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.activemq.thread.Schedulerscheduler
-
Constructor Summary
Constructors Constructor Description JournalPersistenceAdapter()JournalPersistenceAdapter(org.apache.activeio.journal.Journal journal, PersistenceAdapter longTermPersistence, org.apache.activemq.thread.TaskRunnerFactory taskRunnerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidallowIOResumption()voidbeginTransaction(ConnectionContext context)voidcheckpoint(boolean sync)voidcheckpoint(boolean sync, boolean fullCheckpoint)When we checkpoint we move all the journalled data to long term storage.voidcommitTransaction(ConnectionContext context)JobSchedulerStorecreateJobSchedulerStore()MessageStorecreateQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination)protected IOExceptioncreateRecoveryFailedException(Exception e)TopicMessageStorecreateTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destinationName)TransactionStorecreateTransactionStore()protected IOExceptioncreateWriteException(String command, Exception e)protected IOExceptioncreateWriteException(org.apache.activemq.command.DataStructure packet, Exception e)voiddeleteAllMessages()booleandoCheckpoint()This does the actual checkpoint.longgetCheckpointInterval()Set<org.apache.activemq.command.ActiveMQDestination>getDestinations()FilegetDirectory()longgetLastMessageBrokerSequenceId()longgetLastProducerSequenceId(org.apache.activemq.command.ProducerId id)PersistenceAdaptergetLongTermPersistence()intgetMaxCheckpointMessageAddSize()intgetMaxCheckpointWorkers()JournalTransactionStoregetTransactionStore()SystemUsagegetUsageManager()org.apache.activemq.wireformat.WireFormatgetWireFormat()booleanisUseExternalMessageReferences()voidonUsageChanged(Usage usage, int oldPercentUsage, int newPercentUsage)voidoverflowNotification(org.apache.activeio.journal.RecordLocation safeLocation)The Journal give us a call back so that we can move old data out of the journal.org.apache.activemq.command.DataStructurereadCommand(org.apache.activeio.journal.RecordLocation location)voidremoveQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination)Cleanup method to remove any state associated with the given destinationvoidremoveTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destination)Cleanup method to remove any state associated with the given destinationvoidrollbackTransaction(ConnectionContext context)voidsetBrokerName(String brokerName)voidsetBrokerService(BrokerService brokerService)voidsetCheckpointInterval(long checkpointInterval)voidsetDirectory(File dir)voidsetJournal(org.apache.activeio.journal.Journal journal)voidsetMaxCheckpointMessageAddSize(int maxCheckpointMessageAddSize)voidsetMaxCheckpointWorkers(int maxCheckpointWorkers)voidsetPersistenceAdapter(PersistenceAdapter longTermPersistence)voidsetTaskRunnerFactory(org.apache.activemq.thread.TaskRunnerFactory taskRunnerFactory)voidsetUsageManager(SystemUsage usageManager)voidsetUseExternalMessageReferences(boolean enable)longsize()voidstart()voidstop()ByteSequencetoByteSequence(org.apache.activeio.packet.Packet packet)org.apache.activeio.packet.PackettoPacket(ByteSequence sequence)StringtoString()org.apache.activeio.journal.RecordLocationwriteCommand(org.apache.activemq.command.DataStructure command, boolean sync)
-
-
-
Constructor Detail
-
JournalPersistenceAdapter
public JournalPersistenceAdapter()
-
JournalPersistenceAdapter
public JournalPersistenceAdapter(org.apache.activeio.journal.Journal journal, PersistenceAdapter longTermPersistence, org.apache.activemq.thread.TaskRunnerFactory taskRunnerFactory) throws IOException- Throws:
IOException
-
-
Method Detail
-
setTaskRunnerFactory
public void setTaskRunnerFactory(org.apache.activemq.thread.TaskRunnerFactory taskRunnerFactory)
-
setJournal
public void setJournal(org.apache.activeio.journal.Journal journal)
-
setPersistenceAdapter
public void setPersistenceAdapter(PersistenceAdapter longTermPersistence)
-
setUsageManager
public void setUsageManager(SystemUsage usageManager)
- Specified by:
setUsageManagerin interfacePersistenceAdapter- Parameters:
usageManager- The UsageManager that is controlling the destination's memory usage.
-
getDestinations
public Set<org.apache.activemq.command.ActiveMQDestination> getDestinations()
- Specified by:
getDestinationsin interfacePersistenceAdapter
-
createQueueMessageStore
public MessageStore createQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination) throws IOException
- Specified by:
createQueueMessageStorein interfacePersistenceAdapter- Throws:
IOException
-
createTopicMessageStore
public TopicMessageStore createTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destinationName) throws IOException
- Specified by:
createTopicMessageStorein interfacePersistenceAdapter- Throws:
IOException
-
removeQueueMessageStore
public void removeQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination)
Cleanup method to remove any state associated with the given destination- Specified by:
removeQueueMessageStorein interfacePersistenceAdapter- Parameters:
destination- Destination to forget
-
removeTopicMessageStore
public void removeTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destination)
Cleanup method to remove any state associated with the given destination- Specified by:
removeTopicMessageStorein interfacePersistenceAdapter- Parameters:
destination- Destination to forget
-
createTransactionStore
public TransactionStore createTransactionStore() throws IOException
- Specified by:
createTransactionStorein interfacePersistenceAdapter- Throws:
IOException
-
getLastMessageBrokerSequenceId
public long getLastMessageBrokerSequenceId() throws IOException- Specified by:
getLastMessageBrokerSequenceIdin interfacePersistenceAdapter- Throws:
IOException
-
beginTransaction
public void beginTransaction(ConnectionContext context) throws IOException
- Specified by:
beginTransactionin interfacePersistenceAdapter- Throws:
IOException
-
commitTransaction
public void commitTransaction(ConnectionContext context) throws IOException
- Specified by:
commitTransactionin interfacePersistenceAdapter- Throws:
IOException
-
rollbackTransaction
public void rollbackTransaction(ConnectionContext context) throws IOException
- Specified by:
rollbackTransactionin interfacePersistenceAdapter- Throws:
IOException
-
start
public void start() throws Exception- Specified by:
startin interfaceorg.apache.activemq.Service- Throws:
Exception
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceorg.apache.activemq.Service- Throws:
Exception
-
getLongTermPersistence
public PersistenceAdapter getLongTermPersistence()
-
getWireFormat
public org.apache.activemq.wireformat.WireFormat getWireFormat()
- Returns:
- Returns the wireFormat.
-
overflowNotification
public void overflowNotification(org.apache.activeio.journal.RecordLocation safeLocation)
The Journal give us a call back so that we can move old data out of the journal. Taking a checkpoint does this for us.- Specified by:
overflowNotificationin interfaceorg.apache.activeio.journal.JournalEventListener- See Also:
org.apache.activemq.journal.JournalEventListener#overflowNotification(org.apache.activemq.journal.RecordLocation)
-
checkpoint
public void checkpoint(boolean sync, boolean fullCheckpoint)When we checkpoint we move all the journalled data to long term storage.
-
checkpoint
public void checkpoint(boolean sync)
- Specified by:
checkpointin interfacePersistenceAdapter
-
doCheckpoint
public boolean doCheckpoint()
This does the actual checkpoint.- Returns:
-
readCommand
public org.apache.activemq.command.DataStructure readCommand(org.apache.activeio.journal.RecordLocation location) throws IOException- Parameters:
location-- Returns:
- Throws:
IOException
-
createWriteException
protected IOException createWriteException(org.apache.activemq.command.DataStructure packet, Exception e)
-
createWriteException
protected IOException createWriteException(String command, Exception e)
-
createRecoveryFailedException
protected IOException createRecoveryFailedException(Exception e)
-
writeCommand
public org.apache.activeio.journal.RecordLocation writeCommand(org.apache.activemq.command.DataStructure command, boolean sync) throws IOException- Parameters:
command-sync-- Returns:
- Throws:
IOException
-
onUsageChanged
public void onUsageChanged(Usage usage, int oldPercentUsage, int newPercentUsage)
- Specified by:
onUsageChangedin interfaceUsageListener
-
getTransactionStore
public JournalTransactionStore getTransactionStore()
-
deleteAllMessages
public void deleteAllMessages() throws IOException- Specified by:
deleteAllMessagesin interfacePersistenceAdapter- Throws:
IOException
-
getUsageManager
public SystemUsage getUsageManager()
-
getMaxCheckpointMessageAddSize
public int getMaxCheckpointMessageAddSize()
-
setMaxCheckpointMessageAddSize
public void setMaxCheckpointMessageAddSize(int maxCheckpointMessageAddSize)
-
getMaxCheckpointWorkers
public int getMaxCheckpointWorkers()
-
setMaxCheckpointWorkers
public void setMaxCheckpointWorkers(int maxCheckpointWorkers)
-
getCheckpointInterval
public long getCheckpointInterval()
-
setCheckpointInterval
public void setCheckpointInterval(long checkpointInterval)
-
isUseExternalMessageReferences
public boolean isUseExternalMessageReferences()
-
setUseExternalMessageReferences
public void setUseExternalMessageReferences(boolean enable)
-
toPacket
public org.apache.activeio.packet.Packet toPacket(ByteSequence sequence)
-
toByteSequence
public ByteSequence toByteSequence(org.apache.activeio.packet.Packet packet)
-
setBrokerName
public void setBrokerName(String brokerName)
- Specified by:
setBrokerNamein interfacePersistenceAdapter
-
setDirectory
public void setDirectory(File dir)
- Specified by:
setDirectoryin interfacePersistenceAdapter
-
getDirectory
public File getDirectory()
- Specified by:
getDirectoryin interfacePersistenceAdapter
-
size
public long size()
- Specified by:
sizein interfacePersistenceAdapter
-
setBrokerService
public void setBrokerService(BrokerService brokerService)
- Specified by:
setBrokerServicein interfaceBrokerServiceAware
-
getLastProducerSequenceId
public long getLastProducerSequenceId(org.apache.activemq.command.ProducerId id)
- Specified by:
getLastProducerSequenceIdin interfacePersistenceAdapter
-
allowIOResumption
public void allowIOResumption()
- Specified by:
allowIOResumptionin interfacePersistenceAdapter
-
createJobSchedulerStore
public JobSchedulerStore createJobSchedulerStore() throws IOException, UnsupportedOperationException
- Specified by:
createJobSchedulerStorein interfacePersistenceAdapter- Throws:
IOExceptionUnsupportedOperationException
-
-