org.apache.activemq.store.rapid
Class RapidPersistenceAdapter

java.lang.Object
  extended by org.apache.activemq.store.rapid.RapidPersistenceAdapter
All Implemented Interfaces:
org.apache.activeio.journal.JournalEventListener, UsageListener, Service, PersistenceAdapter

public class RapidPersistenceAdapter
extends java.lang.Object
implements PersistenceAdapter, org.apache.activeio.journal.JournalEventListener, UsageListener

An implementation of PersistenceAdapter designed for use with a Journal and then check pointing asynchronously on a timeout with some other long term persistent storage.

Version:
$Revision: 1.17 $

Constructor Summary
RapidPersistenceAdapter(org.apache.activeio.journal.Journal journal, TaskRunnerFactory taskRunnerFactory)
           
 
Method Summary
 void beginTransaction(ConnectionContext context)
          This method starts a transaction on the persistent storage - which is nothing to do with JMS or XA transactions - its purely a mechanism to perform multiple writes to a persistent store in 1 transaction as a performance optimization.
 void checkpoint(boolean sync, boolean fullCheckpoint)
          When we checkpoint we move all the journalled data to long term storage.
 void commitTransaction(ConnectionContext context)
          Commit a persistence transaction
 MessageStore createQueueMessageStore(ActiveMQQueue destination)
          Factory method to create a new queue message store with the given destination name
protected  java.io.IOException createRecoveryFailedException(java.lang.Exception e)
           
 TopicMessageStore createTopicMessageStore(ActiveMQTopic destination)
          Factory method to create a new topic message store with the given destination name
 TransactionStore createTransactionStore()
          Factory method to create a new persistent prepared transaction store for XA recovery
protected  java.io.IOException createWriteException(DataStructure packet, java.lang.Exception e)
           
protected  java.io.IOException createWriteException(java.lang.String command, java.lang.Exception e)
           
 void deleteAllMessages()
          Delete's all the messages in the persistent store.
 boolean doCheckpoint()
          This does the actual checkpoint.
 java.util.Set getDestinations()
          Returns a set of all the ActiveMQDestination objects that the persistence store is aware exist.
 long getLastMessageBrokerSequenceId()
           
protected  MapContainer getMapContainer(java.lang.Object id, java.lang.String containerName)
           
 int getMaxCheckpointMessageAddSize()
           
 int getMaxCheckpointWorkers()
           
 Store getStore()
           
 RapidTransactionStore getTransactionStore()
           
 WireFormat getWireFormat()
           
 boolean isUseExternalMessageReferences()
           
 void onMemoryUseChanged(UsageManager memoryManager, int oldPercentUsage, int newPercentUsage)
           
 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.
 DataStructure readCommand(org.apache.activeio.journal.RecordLocation location)
           
 void rollbackTransaction(ConnectionContext context)
          Rollback a persistence transaction
 void setMaxCheckpointMessageAddSize(int maxCheckpointMessageAddSize)
           
 void setMaxCheckpointWorkers(int maxCheckpointWorkers)
           
 void setUsageManager(UsageManager usageManager)
           
 void setUseExternalMessageReferences(boolean enable)
           
 void start()
           
 void stop()
           
 ByteSequence toByteSequence(org.apache.activeio.packet.Packet packet)
           
 org.apache.activeio.packet.Packet toPacket(ByteSequence sequence)
           
 org.apache.activeio.journal.RecordLocation writeCommand(DataStructure command, boolean sync)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RapidPersistenceAdapter

public RapidPersistenceAdapter(org.apache.activeio.journal.Journal journal,
                               TaskRunnerFactory taskRunnerFactory)
                        throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getDestinations

public java.util.Set getDestinations()
Description copied from interface: PersistenceAdapter
Returns a set of all the ActiveMQDestination objects that the persistence store is aware exist.

Specified by:
getDestinations in interface PersistenceAdapter
Returns:

createQueueMessageStore

public MessageStore createQueueMessageStore(ActiveMQQueue destination)
                                     throws java.io.IOException
Description copied from interface: PersistenceAdapter
Factory method to create a new queue message store with the given destination name

Specified by:
createQueueMessageStore in interface PersistenceAdapter
Throws:
java.io.IOException

getMapContainer

protected MapContainer getMapContainer(java.lang.Object id,
                                       java.lang.String containerName)
                                throws java.io.IOException
Throws:
java.io.IOException

createTopicMessageStore

public TopicMessageStore createTopicMessageStore(ActiveMQTopic destination)
                                          throws java.io.IOException
Description copied from interface: PersistenceAdapter
Factory method to create a new topic message store with the given destination name

Specified by:
createTopicMessageStore in interface PersistenceAdapter
Throws:
java.io.IOException

createTransactionStore

public TransactionStore createTransactionStore()
                                        throws java.io.IOException
Description copied from interface: PersistenceAdapter
Factory method to create a new persistent prepared transaction store for XA recovery

Specified by:
createTransactionStore in interface PersistenceAdapter
Throws:
java.io.IOException

getLastMessageBrokerSequenceId

public long getLastMessageBrokerSequenceId()
                                    throws java.io.IOException
Specified by:
getLastMessageBrokerSequenceId in interface PersistenceAdapter
Returns:
Throws:
java.io.IOException

beginTransaction

public void beginTransaction(ConnectionContext context)
                      throws java.io.IOException
Description copied from interface: PersistenceAdapter
This method starts a transaction on the persistent storage - which is nothing to do with JMS or XA transactions - its purely a mechanism to perform multiple writes to a persistent store in 1 transaction as a performance optimization.

Typically one transaction will require one disk synchronization point and so for real high performance its usually faster to perform many writes within the same transaction to minimize latency caused by disk synchronization. This is especially true when using tools like Berkeley Db or embedded JDBC servers.

Specified by:
beginTransaction in interface PersistenceAdapter
Throws:
java.io.IOException

commitTransaction

public void commitTransaction(ConnectionContext context)
                       throws java.io.IOException
Description copied from interface: PersistenceAdapter
Commit a persistence transaction

Specified by:
commitTransaction in interface PersistenceAdapter
Throws:
java.io.IOException
See Also:
PersistenceAdapter#beginTransaction()

rollbackTransaction

public void rollbackTransaction(ConnectionContext context)
                         throws java.io.IOException
Description copied from interface: PersistenceAdapter
Rollback a persistence transaction

Specified by:
rollbackTransaction in interface PersistenceAdapter
Throws:
java.io.IOException
See Also:
PersistenceAdapter#beginTransaction()

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Service
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Service
Throws:
java.lang.Exception

getWireFormat

public 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:
overflowNotification in interface org.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.

Parameters:
stopping -
b -

doCheckpoint

public boolean doCheckpoint()
This does the actual checkpoint.

Returns:

readCommand

public DataStructure readCommand(org.apache.activeio.journal.RecordLocation location)
                          throws java.io.IOException
Parameters:
location -
Returns:
Throws:
java.io.IOException

createWriteException

protected java.io.IOException createWriteException(DataStructure packet,
                                                   java.lang.Exception e)

createWriteException

protected java.io.IOException createWriteException(java.lang.String command,
                                                   java.lang.Exception e)

createRecoveryFailedException

protected java.io.IOException createRecoveryFailedException(java.lang.Exception e)

writeCommand

public org.apache.activeio.journal.RecordLocation writeCommand(DataStructure command,
                                                               boolean sync)
                                                        throws java.io.IOException
Parameters:
command -
sync -
Returns:
Throws:
java.io.IOException

onMemoryUseChanged

public void onMemoryUseChanged(UsageManager memoryManager,
                               int oldPercentUsage,
                               int newPercentUsage)
Specified by:
onMemoryUseChanged in interface UsageListener

getTransactionStore

public RapidTransactionStore getTransactionStore()

deleteAllMessages

public void deleteAllMessages()
                       throws java.io.IOException
Description copied from interface: PersistenceAdapter
Delete's all the messages in the persistent store.

Specified by:
deleteAllMessages in interface PersistenceAdapter
Throws:
java.io.IOException

getMaxCheckpointMessageAddSize

public int getMaxCheckpointMessageAddSize()

setMaxCheckpointMessageAddSize

public void setMaxCheckpointMessageAddSize(int maxCheckpointMessageAddSize)

getMaxCheckpointWorkers

public int getMaxCheckpointWorkers()

setMaxCheckpointWorkers

public void setMaxCheckpointWorkers(int maxCheckpointWorkers)

isUseExternalMessageReferences

public boolean isUseExternalMessageReferences()
Specified by:
isUseExternalMessageReferences in interface PersistenceAdapter

setUseExternalMessageReferences

public void setUseExternalMessageReferences(boolean enable)
Specified by:
setUseExternalMessageReferences in interface PersistenceAdapter

setUsageManager

public void setUsageManager(UsageManager usageManager)
Specified by:
setUsageManager in interface PersistenceAdapter
Parameters:
usageManager - The UsageManager that is controlling the broker's memory usage.

getStore

public Store getStore()

toPacket

public org.apache.activeio.packet.Packet toPacket(ByteSequence sequence)

toByteSequence

public ByteSequence toByteSequence(org.apache.activeio.packet.Packet packet)


Copyright © 2009 Apache Software Foundation. All Rights Reserved.