Package org.apache.activemq.store.kahadb
Class KahaDBStore
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.store.kahadb.MessageDatabase
-
- org.apache.activemq.store.kahadb.KahaDBStore
-
- All Implemented Interfaces:
BrokerServiceAware,Service,NoLocalSubscriptionAware,PersistenceAdapter
public class KahaDBStore extends MessageDatabase implements PersistenceAdapter, NoLocalSubscriptionAware
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classKahaDBStore.KahaDBMessageStorestatic interfaceKahaDBStore.StoreTaskclassKahaDBStore.StoreTaskExecutor-
Nested classes/interfaces inherited from class org.apache.activemq.store.kahadb.MessageDatabase
MessageDatabase.LastAckMarshaller, MessageDatabase.MessageKeysMarshaller, MessageDatabase.MessageStoreStatisticsMarshaller, MessageDatabase.Metadata, MessageDatabase.PurgeRecoveredXATransactionStrategy, MessageDatabase.StoredDestinationMarshaller
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Map<org.apache.activemq.store.kahadb.KahaDBStore.AsyncJobKey,KahaDBStore.StoreTask>>asyncQueueMapsprotected List<Map<org.apache.activemq.store.kahadb.KahaDBStore.AsyncJobKey,KahaDBStore.StoreTask>>asyncTopicMapsstatic intcancelledTaskModMetricstatic StringPROPERTY_ASYNC_EXECUTOR_MAX_THREADSstatic StringPROPERTY_CANCELED_TASK_MOD_METRICprotected ExecutorServicequeueExecutorprotected ExecutorServicetopicExecutor-
Fields inherited from class org.apache.activemq.store.kahadb.MessageDatabase
archiveDataLogs, brokerService, DEFAULT_DIRECTORY, deleteAllMessages, directory, directoryArchive, failIfDatabaseIsLocked, forceRecoverIndex, indexDirectory, indexLock, journal, journalDiskSyncStrategy, journalSize, lastAsyncJournalUpdate, LOG_SLOW_ACCESS_TIME, metadata, metadataMarshaller, opened, pageFile, persistenceAdapterStatistics, preparedTransactions, PROPERTY_LOG_SLOW_ACCESS_TIME, purgeRecoveredXATransactionStrategy, scheduler, storeCache, storedDestinations, UNMATCHED
-
-
Constructor Summary
Constructors Constructor Description KahaDBStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddQueueTask(KahaDBStore.KahaDBMessageStore store, org.apache.activemq.store.kahadb.KahaDBStore.StoreQueueTask task)protected voidaddTopicTask(org.apache.activemq.store.kahadb.KahaDBStore.KahaDBTopicMessageStore store, org.apache.activemq.store.kahadb.KahaDBStore.StoreTopicTask task)voidbeginTransaction(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.voidcheckpoint(boolean sync)checkpoint anyvoidcommitTransaction(ConnectionContext context)Commit a persistence transactionprotected voidconfigureMetadata()JobSchedulerStorecreateJobSchedulerStore()Creates and returns a new Job Scheduler store instance.MessageStorecreateQueueMessageStore(ActiveMQQueue destination)Factory method to create a new queue message store with the given destination nameTopicMessageStorecreateTopicMessageStore(ActiveMQTopic destination)Factory method to create a new topic message store with the given destination nameTransactionStorecreateTransactionStore()Factory method to create a new persistent prepared transaction store for XA recoveryvoiddeleteAllMessages()Delete's all the messages in the persistent store.voiddoStart()voiddoStop(ServiceStopper stopper)voidforgetRecoveredAcks(ArrayList<MessageAck> preparedAcks, boolean isRollback)Set<ActiveMQDestination>getDestinations()Returns a set of all theActiveMQDestinationobjects that the persistence store is aware exist.booleangetForceRecoverIndex()longgetLastMessageBrokerSequenceId()longgetLastProducerSequenceId(ProducerId id)return the last stored producer sequenceId for this producer Id used to suppress duplicate sends on failover reconnect at the transport when a reconnect occursintgetMaxAsyncJobs()TransactionIdTransformergetTransactionIdTransformer()SystemUsagegetUsageManager()booleanisConcurrentStoreAndDispatchQueues()booleanisConcurrentStoreAndDispatchTopics()booleanisConcurrentStoreAndDispatchTransactions()booleanisPersistNoLocal()voidremoveQueueMessageStore(ActiveMQQueue destination)Cleanup method to remove any state associated with the given destination.protected org.apache.activemq.store.kahadb.KahaDBStore.StoreQueueTaskremoveQueueTask(KahaDBStore.KahaDBMessageStore store, MessageId id)voidremoveTopicMessageStore(ActiveMQTopic destination)Cleanup method to remove any state associated with the given destination This method does not stop the message store (it might not be cached).protected org.apache.activemq.store.kahadb.KahaDBStore.StoreTopicTaskremoveTopicTask(org.apache.activemq.store.kahadb.KahaDBStore.KahaDBTopicMessageStore store, MessageId id)voidrollbackTransaction(ConnectionContext context)Rollback a persistence transactionvoidsetBrokerName(String brokerName)Set the name of the broker using the adaptervoidsetConcurrentStoreAndDispatchQueues(boolean concurrentStoreAndDispatch)voidsetConcurrentStoreAndDispatchTopics(boolean concurrentStoreAndDispatch)voidsetForceRecoverIndex(boolean forceRecoverIndex)voidsetMaxAsyncJobs(int maxAsyncJobs)voidsetTransactionIdTransformer(TransactionIdTransformer transactionIdTransformer)voidsetUsageManager(SystemUsage usageManager)longsize()A hint to return the size of the store on diskStringtoString()voidtrackRecoveredAcks(ArrayList<MessageAck> preparedAcks)-
Methods inherited from class org.apache.activemq.store.kahadb.MessageDatabase
allowIOResumption, checkpointCleanup, clearStoreStats, close, createJournal, decrementAndSubSizeToStoreStat, decrementAndSubSizeToStoreStat, decrementAndSubSizeToStoreStat, decrementAndSubSizeToStoreStat, getCheckpointInterval, getCleanupInterval, getCleanupOnStop, getCompactAcksAfterNoGC, getDirectory, getDirectoryArchive, getExistingStoredDestination, getFailoverProducersAuditDepth, getIndexCacheSize, getIndexDirectory, getIndexLFUEvictionFactor, getIndexWriteBatchSize, getInProgressTxLocationRange, getJournal, getJournalDiskSyncInterval, getJournalDiskSyncStrategy, getJournalDiskSyncStrategyEnum, getJournalFilesBeingReplicated, getJournalMaxFileLength, getJournalMaxWriteBatchSize, getLastAck, getLastUpdatePosition, getMaxFailoverProducersToTrack, getMetadata, getPageFile, getPersistenceAdapterStatistics, getPreallocationScope, getPreallocationStrategy, getPreparedTransaction, getPurgeRecoveredXATransactionStrategy, getPurgeRecoveredXATransactionStrategyEnum, getSequenceSet, getStoredDestination, getStoredMessageCount, getStoredMessageSize, getStoredMessageSize, getStoredMessageStoreStatistics, getStoreStats, getSubStats, getTransactions, incrementalRecover, incrementAndAddSizeToStoreStat, incrementAndAddSizeToStoreStat, incrementAndAddSizeToStoreStat, incrementAndAddSizeToStoreStat, isArchiveCorruptedIndex, isArchiveDataLogs, isCheckForCorruptJournalFiles, isChecksumJournalFiles, isCompactAcksIgnoresStoreGrowth, isDeleteAllMessages, isEnableAckCompaction, isEnableIndexDiskSyncs, isEnableIndexPageCaching, isEnableIndexRecoveryFile, isEnableJournalDiskSyncs, isEnableSubscriptionStatistics, isFailIfDatabaseIsLocked, isIgnoreMissingJournalfiles, isUseIndexLFRUEviction, key, load, load, matchType, open, process, process, process, process, process, process, process, process, process, processLocation, recoverIndex, setArchiveCorruptedIndex, setArchiveDataLogs, setBrokerService, setCheckForCorruptJournalFiles, setCheckpointInterval, setChecksumJournalFiles, setCleanupInterval, setCleanupOnStop, setCompactAcksAfterNoGC, setCompactAcksIgnoresStoreGrowth, setDeleteAllMessages, setDirectory, setDirectoryArchive, setEnableAckCompaction, setEnableIndexDiskSyncs, setEnableIndexPageCaching, setEnableIndexRecoveryFile, setEnableIndexWriteAsync, setEnableJournalDiskSyncs, setEnableSubscriptionStatistics, setFailIfDatabaseIsLocked, setFailoverProducersAuditDepth, setIgnoreMissingJournalfiles, setIndexCacheSize, setIndexDirectory, setIndexLFUEvictionFactor, setIndexWriteBatchSize, setJournalDiskSyncInterval, setJournalDiskSyncStrategy, setJournalMaxFileLength, setJournalMaxWriteBatchSize, setMaxFailoverProducersToTrack, setPreallocationScope, setPreallocationStrategy, setPurgeRecoveredXATransactionStrategy, setUseIndexLFRUEviction, store, store, store, store, toByteSequence, unload
-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.store.PersistenceAdapter
allowIOResumption, getDirectory, setDirectory
-
-
-
-
Field Detail
-
PROPERTY_CANCELED_TASK_MOD_METRIC
public static final String PROPERTY_CANCELED_TASK_MOD_METRIC
- See Also:
- Constant Field Values
-
cancelledTaskModMetric
public static final int cancelledTaskModMetric
-
PROPERTY_ASYNC_EXECUTOR_MAX_THREADS
public static final String PROPERTY_ASYNC_EXECUTOR_MAX_THREADS
- See Also:
- Constant Field Values
-
queueExecutor
protected ExecutorService queueExecutor
-
topicExecutor
protected ExecutorService topicExecutor
-
asyncQueueMaps
protected final List<Map<org.apache.activemq.store.kahadb.KahaDBStore.AsyncJobKey,KahaDBStore.StoreTask>> asyncQueueMaps
-
asyncTopicMaps
protected final List<Map<org.apache.activemq.store.kahadb.KahaDBStore.AsyncJobKey,KahaDBStore.StoreTask>> asyncTopicMaps
-
-
Method Detail
-
setBrokerName
public void setBrokerName(String brokerName)
Description copied from interface:PersistenceAdapterSet the name of the broker using the adapter- Specified by:
setBrokerNamein interfacePersistenceAdapter
-
setUsageManager
public void setUsageManager(SystemUsage usageManager)
- Specified by:
setUsageManagerin interfacePersistenceAdapter- Parameters:
usageManager- The UsageManager that is controlling the broker's memory usage.
-
getUsageManager
public SystemUsage getUsageManager()
-
isConcurrentStoreAndDispatchQueues
public boolean isConcurrentStoreAndDispatchQueues()
- Returns:
- the concurrentStoreAndDispatch
-
setConcurrentStoreAndDispatchQueues
public void setConcurrentStoreAndDispatchQueues(boolean concurrentStoreAndDispatch)
- Parameters:
concurrentStoreAndDispatch- the concurrentStoreAndDispatch to set
-
isConcurrentStoreAndDispatchTopics
public boolean isConcurrentStoreAndDispatchTopics()
- Returns:
- the concurrentStoreAndDispatch
-
setConcurrentStoreAndDispatchTopics
public void setConcurrentStoreAndDispatchTopics(boolean concurrentStoreAndDispatch)
- Parameters:
concurrentStoreAndDispatch- the concurrentStoreAndDispatch to set
-
isConcurrentStoreAndDispatchTransactions
public boolean isConcurrentStoreAndDispatchTransactions()
-
getMaxAsyncJobs
public int getMaxAsyncJobs()
- Returns:
- the maxAsyncJobs
-
setMaxAsyncJobs
public void setMaxAsyncJobs(int maxAsyncJobs)
- Parameters:
maxAsyncJobs- the maxAsyncJobs to set
-
configureMetadata
protected void configureMetadata()
- Specified by:
configureMetadatain classMessageDatabase
-
doStart
public void doStart() throws Exception- Overrides:
doStartin classMessageDatabase- Throws:
Exception
-
doStop
public void doStop(ServiceStopper stopper) throws Exception
- Overrides:
doStopin classMessageDatabase- Throws:
Exception
-
removeQueueTask
protected org.apache.activemq.store.kahadb.KahaDBStore.StoreQueueTask removeQueueTask(KahaDBStore.KahaDBMessageStore store, MessageId id)
-
addQueueTask
protected void addQueueTask(KahaDBStore.KahaDBMessageStore store, org.apache.activemq.store.kahadb.KahaDBStore.StoreQueueTask task) throws IOException
- Throws:
IOException
-
removeTopicTask
protected org.apache.activemq.store.kahadb.KahaDBStore.StoreTopicTask removeTopicTask(org.apache.activemq.store.kahadb.KahaDBStore.KahaDBTopicMessageStore store, MessageId id)
-
addTopicTask
protected void addTopicTask(org.apache.activemq.store.kahadb.KahaDBStore.KahaDBTopicMessageStore store, org.apache.activemq.store.kahadb.KahaDBStore.StoreTopicTask task) throws IOException- Throws:
IOException
-
createTransactionStore
public TransactionStore createTransactionStore() throws IOException
Description copied from interface:PersistenceAdapterFactory method to create a new persistent prepared transaction store for XA recovery- Specified by:
createTransactionStorein interfacePersistenceAdapter- Returns:
- transaction store
- Throws:
IOException
-
getForceRecoverIndex
public boolean getForceRecoverIndex()
-
setForceRecoverIndex
public void setForceRecoverIndex(boolean forceRecoverIndex)
-
forgetRecoveredAcks
public void forgetRecoveredAcks(ArrayList<MessageAck> preparedAcks, boolean isRollback) throws IOException
- Throws:
IOException
-
trackRecoveredAcks
public void trackRecoveredAcks(ArrayList<MessageAck> preparedAcks) throws IOException
- Throws:
IOException
-
createQueueMessageStore
public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException
Description copied from interface:PersistenceAdapterFactory method to create a new queue message store with the given destination name- Specified by:
createQueueMessageStorein interfacePersistenceAdapter- Returns:
- the message store
- Throws:
IOException
-
createTopicMessageStore
public TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException
Description copied from interface:PersistenceAdapterFactory method to create a new topic message store with the given destination name- Specified by:
createTopicMessageStorein interfacePersistenceAdapter- Returns:
- the topic message store
- Throws:
IOException
-
removeQueueMessageStore
public void removeQueueMessageStore(ActiveMQQueue destination)
Cleanup method to remove any state associated with the given destination. This method does not stop the message store (it might not be cached).- Specified by:
removeQueueMessageStorein interfacePersistenceAdapter- Parameters:
destination- Destination to forget
-
removeTopicMessageStore
public void removeTopicMessageStore(ActiveMQTopic destination)
Cleanup method to remove any state associated with the given destination This method does not stop the message store (it might not be cached).- Specified by:
removeTopicMessageStorein interfacePersistenceAdapter- Parameters:
destination- Destination to forget
-
deleteAllMessages
public void deleteAllMessages() throws IOExceptionDescription copied from interface:PersistenceAdapterDelete's all the messages in the persistent store.- Specified by:
deleteAllMessagesin interfacePersistenceAdapter- Throws:
IOException
-
getDestinations
public Set<ActiveMQDestination> getDestinations()
Description copied from interface:PersistenceAdapterReturns a set of all theActiveMQDestinationobjects that the persistence store is aware exist.- Specified by:
getDestinationsin interfacePersistenceAdapter- Returns:
- active destinations
-
getLastMessageBrokerSequenceId
public long getLastMessageBrokerSequenceId() throws IOException- Specified by:
getLastMessageBrokerSequenceIdin interfacePersistenceAdapter- Returns:
- last broker sequence
- Throws:
IOException
-
getLastProducerSequenceId
public long getLastProducerSequenceId(ProducerId id)
Description copied from interface:PersistenceAdapterreturn the last stored producer sequenceId for this producer Id used to suppress duplicate sends on failover reconnect at the transport when a reconnect occurs- Specified by:
getLastProducerSequenceIdin interfacePersistenceAdapter- Parameters:
id- the producerId to find a sequenceId for- Returns:
- the last stored sequence id or -1 if no suppression needed
-
size
public long size()
Description copied from interface:PersistenceAdapterA hint to return the size of the store on disk- Specified by:
sizein interfacePersistenceAdapter- Returns:
- disk space used in bytes of 0 if not implemented
-
beginTransaction
public void beginTransaction(ConnectionContext context) throws IOException
Description copied from interface:PersistenceAdapterThis 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:
beginTransactionin interfacePersistenceAdapter- Throws:
IOException
-
commitTransaction
public void commitTransaction(ConnectionContext context) throws IOException
Description copied from interface:PersistenceAdapterCommit a persistence transaction- Specified by:
commitTransactionin interfacePersistenceAdapter- Throws:
IOException- See Also:
PersistenceAdapter.beginTransaction(ConnectionContext context)
-
rollbackTransaction
public void rollbackTransaction(ConnectionContext context) throws IOException
Description copied from interface:PersistenceAdapterRollback a persistence transaction- Specified by:
rollbackTransactionin interfacePersistenceAdapter- Throws:
IOException- See Also:
PersistenceAdapter.beginTransaction(ConnectionContext context)
-
checkpoint
public void checkpoint(boolean sync) throws IOExceptionDescription copied from interface:PersistenceAdaptercheckpoint any- Specified by:
checkpointin interfacePersistenceAdapter- Throws:
IOException
-
getTransactionIdTransformer
public TransactionIdTransformer getTransactionIdTransformer()
-
setTransactionIdTransformer
public void setTransactionIdTransformer(TransactionIdTransformer transactionIdTransformer)
-
createJobSchedulerStore
public JobSchedulerStore createJobSchedulerStore() throws IOException, UnsupportedOperationException
Description copied from interface:PersistenceAdapterCreates and returns a new Job Scheduler store instance.- Specified by:
createJobSchedulerStorein interfacePersistenceAdapter- Returns:
- a new JobSchedulerStore instance if this Persistence adapter provides its own.
- Throws:
IOException- If an error occurs while creating the new JobSchedulerStore.UnsupportedOperationException- If this adapter does not provide its own scheduler store implementation.
-
isPersistNoLocal
public boolean isPersistNoLocal()
- Specified by:
isPersistNoLocalin interfaceNoLocalSubscriptionAware
-
-