Class PagingStoreImpl
- java.lang.Object
-
- org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl
-
- All Implemented Interfaces:
RefCountMessageListener,PagingStore,ActiveMQComponent
public class PagingStoreImpl extends Object implements PagingStore
- See Also:
PagingStore
-
-
Constructor Summary
Constructors Constructor Description PagingStoreImpl(SimpleString address, ScheduledExecutorService scheduledExecutor, long syncTimeout, PagingManager pagingManager, StorageManager storageManager, SequentialFileFactory fileFactory, PagingStoreFactory storeFactory, SimpleString storeName, AddressSettings addressSettings, ArtemisExecutor executor, ArtemisExecutor ioExecutor, boolean syncNonTransactional)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSize(int size, boolean sizeOnly)voidapplySetting(AddressSettings addressSettings)voidblock()booleancheckMemory(boolean runOnFailure, Runnable runWhenAvailable, Runnable runWhenBlocking)booleancheckMemory(Runnable runWhenAvailable)booleancheckPageFileExists(long pageNumber)booleancheckReleasedMemory()It will return true if the destination is leaving blocking.StringcreateFileName(long pageID)Pagedepage()Returns a Page out of the Page System without reading it.voiddestroy()voiddisableCleanup()This method will disable cleanup of pages.voiddurableDown(Message message, int durableCount)voiddurableUp(Message message, int durableCount)voidenableCleanup()This method will re-enable cleanup of pages.voidexecute(Runnable run)voidflushExecutors()This is used mostly by tests.voidforceAnotherPage()protected voidforEachUsedPage(Consumer<Page> consumerPage)SimpleStringgetAddress()AddressFullMessagePolicygetAddressFullMessagePolicy()intgetAddressLimitPercent()longgetAddressSize()Collection<Integer>getCurrentIds()Files to synchronize with a remote backup.PagegetCurrentPage()longgetCurrentWritingPage()Returns the page id of the current page in which the system is writing files.PageCursorProvidergetCursorProvider()ArtemisExecutorgetExecutor()protected SequentialFileFactorygetFileFactory()longgetFirstPage()FilegetFolder()intgetMaxPageReadBytes()intgetMaxPageReadMessages()longgetMaxSize()intgetNumberOfFiles()longgetNumberOfPages()intgetPageSizeBytes()PagingManagergetPagingManager()SimpleStringgetStoreName()protected intgetUsedPagesSize()voidioSync()Performs a real sync on the current IO file.booleanisFull()booleanisPaging()This method will look if the current state of paging is not paging, without using a lock.booleanisRejectingMessages()booleanisStarted()booleanlock(long timeout)Write lock the PagingStore.PagenewPageObject(long pageNumber)booleanpage(Message message, Transaction tx, RouteContextList listCtx)Write message to page if we are paging.voidprocessReload()voidrefDown(Message message, int count)voidrefUp(Message message, int count)protected voidreloadLivePage(long pageId)PageremovePage(int pageId)Returns a Page out of the Page System without reading it.voidsendPages(ReplicationManager replicator, Collection<Integer> pageIds)Sends the pages with given IDs to theReplicationManager.voidstart()booleanstartPaging()voidstop()voidstopPaging()voidsync()Schedules sync to the file storage.StringtoString()voidunblock()voidunlock()Releases locks acquired withPagingStore.lock(long).PageusePage(long pageId)PageusePage(long pageId, boolean create)Use this method when you want to use the cache of used pages.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.core.server.ActiveMQComponent
asyncStop
-
Methods inherited from interface org.apache.activemq.artemis.core.paging.PagingStore
addSize
-
Methods inherited from interface org.apache.activemq.artemis.api.core.RefCountMessageListener
usageDown, usageUp
-
-
-
-
Constructor Detail
-
PagingStoreImpl
public PagingStoreImpl(SimpleString address, ScheduledExecutorService scheduledExecutor, long syncTimeout, PagingManager pagingManager, StorageManager storageManager, SequentialFileFactory fileFactory, PagingStoreFactory storeFactory, SimpleString storeName, AddressSettings addressSettings, ArtemisExecutor executor, ArtemisExecutor ioExecutor, boolean syncNonTransactional)
-
-
Method Detail
-
applySetting
public void applySetting(AddressSettings addressSettings)
- Specified by:
applySettingin interfacePagingStore- Parameters:
addressSettings-
-
lock
public boolean lock(long timeout)
Description copied from interface:PagingStoreWrite lock the PagingStore.- Specified by:
lockin interfacePagingStore- Parameters:
timeout- milliseconds to wait for the lock. If value is -1 then wait indefinitely.- Returns:
trueif the lock was obtained,falseotherwise
-
unlock
public void unlock()
Description copied from interface:PagingStoreReleases locks acquired withPagingStore.lock(long).- Specified by:
unlockin interfacePagingStore
-
getCursorProvider
public PageCursorProvider getCursorProvider()
- Specified by:
getCursorProviderin interfacePagingStore
-
getFirstPage
public long getFirstPage()
- Specified by:
getFirstPagein interfacePagingStore
-
getAddress
public SimpleString getAddress()
- Specified by:
getAddressin interfacePagingStore
-
getAddressSize
public long getAddressSize()
- Specified by:
getAddressSizein interfacePagingStore
-
getMaxSize
public long getMaxSize()
- Specified by:
getMaxSizein interfacePagingStore
-
getMaxPageReadBytes
public int getMaxPageReadBytes()
- Specified by:
getMaxPageReadBytesin interfacePagingStore
-
getMaxPageReadMessages
public int getMaxPageReadMessages()
- Specified by:
getMaxPageReadMessagesin interfacePagingStore
-
getAddressFullMessagePolicy
public AddressFullMessagePolicy getAddressFullMessagePolicy()
- Specified by:
getAddressFullMessagePolicyin interfacePagingStore
-
getPageSizeBytes
public int getPageSizeBytes()
- Specified by:
getPageSizeBytesin interfacePagingStore
-
getFolder
public File getFolder()
- Specified by:
getFolderin interfacePagingStore
-
isPaging
public boolean isPaging()
Description copied from interface:PagingStoreThis method will look if the current state of paging is not paging, without using a lock. For cases where you need absolutely atomic results, check it directly on the internal variables while requiring a readLock. It's ok to look for this with an estimate on starting a task or not, but you will need to recheck on actual paging operations.- Specified by:
isPagingin interfacePagingStore
-
getNumberOfPages
public long getNumberOfPages()
- Specified by:
getNumberOfPagesin interfacePagingStore
-
getCurrentWritingPage
public long getCurrentWritingPage()
Description copied from interface:PagingStoreReturns the page id of the current page in which the system is writing files.- Specified by:
getCurrentWritingPagein interfacePagingStore
-
getStoreName
public SimpleString getStoreName()
- Specified by:
getStoreNamein interfacePagingStore
-
sync
public void sync() throws ExceptionDescription copied from interface:PagingStoreSchedules sync to the file storage.- Specified by:
syncin interfacePagingStore- Throws:
Exception
-
ioSync
public void ioSync() throws ExceptionDescription copied from interface:PagingStorePerforms a real sync on the current IO file.- Specified by:
ioSyncin interfacePagingStore- Throws:
Exception
-
processReload
public void processReload() throws Exception- Specified by:
processReloadin interfacePagingStore- Throws:
Exception
-
getPagingManager
public PagingManager getPagingManager()
- Specified by:
getPagingManagerin interfacePagingStore
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceActiveMQComponent
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceActiveMQComponent- Throws:
Exception
-
getExecutor
public ArtemisExecutor getExecutor()
- Specified by:
getExecutorin interfacePagingStore
-
execute
public void execute(Runnable run)
- Specified by:
executein interfacePagingStore
-
flushExecutors
public void flushExecutors()
Description copied from interface:PagingStoreThis is used mostly by tests. We will wait any pending runnable to finish its execution- Specified by:
flushExecutorsin interfacePagingStore
-
start
public void start() throws Exception- Specified by:
startin interfaceActiveMQComponent- Throws:
Exception
-
stopPaging
public void stopPaging()
- Specified by:
stopPagingin interfacePagingStore
-
startPaging
public boolean startPaging()
- Specified by:
startPagingin interfacePagingStore- Returns:
- true if paging was started, or false if paging was already started before this call
-
getCurrentPage
public Page getCurrentPage()
- Specified by:
getCurrentPagein interfacePagingStore
-
checkPageFileExists
public boolean checkPageFileExists(long pageNumber)
- Specified by:
checkPageFileExistsin interfacePagingStore
-
newPageObject
public Page newPageObject(long pageNumber) throws Exception
- Specified by:
newPageObjectin interfacePagingStore- Throws:
Exception
-
usePage
public final Page usePage(long pageId)
- Specified by:
usePagein interfacePagingStore
-
usePage
public Page usePage(long pageId, boolean create)
Description copied from interface:PagingStoreUse this method when you want to use the cache of used pages. If you are just using offline (e.g. print-data), use the newPageObject method.- Specified by:
usePagein interfacePagingStore
-
getFileFactory
protected SequentialFileFactory getFileFactory() throws Exception
- Throws:
Exception
-
forceAnotherPage
public void forceAnotherPage() throws Exception- Specified by:
forceAnotherPagein interfacePagingStore- Throws:
Exception
-
removePage
public Page removePage(int pageId)
Returns a Page out of the Page System without reading it.The method calling this method will remove the page and will start reading it outside of any locks. This method could also replace the current file by a new file, and that process is done through acquiring a writeLock on currentPageLock.
Observation: This method is used internally as part of the regular depage process, but externally is used only on tests, and that's why this method is part of the Testable Interface
- Specified by:
removePagein interfacePagingStore
-
depage
public Page depage() throws Exception
Returns a Page out of the Page System without reading it.The method calling this method will remove the page and will start reading it outside of any locks. This method could also replace the current file by a new file, and that process is done through acquiring a writeLock on currentPageLock.
Observation: This method is used internally as part of the regular depage process, but externally is used only on tests, and that's why this method is part of the Testable Interface
- Specified by:
depagein interfacePagingStore- Throws:
Exception- Note: This should still be part of the interface, even though ActiveMQ Artemis only uses through the
-
checkMemory
public boolean checkMemory(Runnable runWhenAvailable)
- Specified by:
checkMemoryin interfacePagingStore
-
checkMemory
public boolean checkMemory(boolean runOnFailure, Runnable runWhenAvailable, Runnable runWhenBlocking)- Specified by:
checkMemoryin interfacePagingStore
-
addSize
public void addSize(int size, boolean sizeOnly)- Specified by:
addSizein interfacePagingStoresizeOnly- if false we won't increment the number of messages. (add references for example)
-
checkReleasedMemory
public boolean checkReleasedMemory()
Description copied from interface:PagingStoreIt will return true if the destination is leaving blocking.- Specified by:
checkReleasedMemoryin interfacePagingStore
-
page
public boolean page(Message message, Transaction tx, RouteContextList listCtx) throws Exception
Description copied from interface:PagingStoreWrite message to page if we are paging.- Specified by:
pagein interfacePagingStore- Returns:
trueif we are paging and have handled the data,falseif the data needs to be sent to the journal- Throws:
NullPointerException- ifreadLockis nullException
-
disableCleanup
public void disableCleanup()
This method will disable cleanup of pages. No page will be deleted after this call.- Specified by:
disableCleanupin interfacePagingStore
-
enableCleanup
public void enableCleanup()
This method will re-enable cleanup of pages. Notice that it will also start cleanup threads.- Specified by:
enableCleanupin interfacePagingStore
-
durableDown
public void durableDown(Message message, int durableCount)
- Specified by:
durableDownin interfaceRefCountMessageListener
-
durableUp
public void durableUp(Message message, int durableCount)
- Specified by:
durableUpin interfaceRefCountMessageListener
-
refUp
public void refUp(Message message, int count)
- Specified by:
refUpin interfaceRefCountMessageListener
-
refDown
public void refDown(Message message, int count)
- Specified by:
refDownin interfaceRefCountMessageListener
-
destroy
public void destroy() throws Exception- Specified by:
destroyin interfacePagingStore- Throws:
Exception
-
createFileName
public String createFileName(long pageID)
-
isFull
public boolean isFull()
- Specified by:
isFullin interfacePagingStore
-
getAddressLimitPercent
public int getAddressLimitPercent()
- Specified by:
getAddressLimitPercentin interfacePagingStore
-
block
public void block()
- Specified by:
blockin interfacePagingStore
-
unblock
public void unblock()
- Specified by:
unblockin interfacePagingStore
-
isRejectingMessages
public boolean isRejectingMessages()
- Specified by:
isRejectingMessagesin interfacePagingStore
-
getCurrentIds
public Collection<Integer> getCurrentIds() throws Exception
Description copied from interface:PagingStoreFiles to synchronize with a remote backup.- Specified by:
getCurrentIdsin interfacePagingStore- Returns:
- a collection of page IDs which must be synchronized with a replicating backup
- Throws:
Exception
-
sendPages
public void sendPages(ReplicationManager replicator, Collection<Integer> pageIds) throws Exception
Description copied from interface:PagingStoreSends the pages with given IDs to theReplicationManager.Sending is done here to avoid exposing the internal
SequentialFiles.- Specified by:
sendPagesin interfacePagingStore- Throws:
Exception
-
getUsedPagesSize
protected int getUsedPagesSize()
-
-