Class PagingStoreImpl
- All Implemented Interfaces:
RefCountMessageListener,PagingStore,ActiveMQComponent
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPagingStoreImpl(SimpleString address, ScheduledExecutorService scheduledExecutor, long syncTimeout, PagingManager pagingManager, StorageManager storageManager, SequentialFileFactory fileFactory, PagingStoreFactory storeFactory, SimpleString storeName, AddressSettings addressSettings, ArtemisExecutor executor, boolean syncNonTransactional) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSize(int size, boolean sizeOnly, boolean affectGlobal) Add size to thisPageStore.voidapplySetting(AddressSettings addressSettings) voidblock()booleancheckMemory(boolean runOnFailure, Runnable runWhenAvailableParameter, Runnable runWhenBlocking, Consumer<AtomicRunnable> blockedCallback) booleancheckMemory(Runnable runWhenAvailable, Consumer<AtomicRunnable> blockedCallback) booleancheckPageFileExists(long pageNumber) voidcheckPageLimit(long numberOfMessages) booleanIt will return true if the destination is leaving blocking.voidSave snapshots on the counterscreateFileName(long pageID) protected PageTimedWritercreatePageTimedWriter(ScheduledExecutorService scheduledExecutor, long syncTimeout) depage()Returns a Page out of the Page System without reading it.voiddestroy()protected voiddirectWritePage(PagedMessage pagedMessage, boolean lineUp, boolean originalReplicated) voidThis method will disable cleanup of pages.voiddurableDown(Message message, int durableCount) voidvoidThis method will re-enable cleanup of pages.enforceAddressFullMessagePolicy(AddressFullMessagePolicy enforcedAddressFullMessagePolicy) voidvoidThis is used mostly by tests.voidvoidforceAnotherPage(boolean useExecutor) protected voidforEachUsedPage(Consumer<Page> consumerPage) longintlongFiles to synchronize with a remote backup.longReturns the page id of the current page in which the system is writing files.protected SequentialFileFactorylongintintlongintlongintintintprotected intbooleanvoidioSync()Performs a real sync on the current IO file.booleanisFull()booleanbooleanisPaging()This method will look if the current state of paging is not paging, without using a lock.booleanbooleannewPageObject(long pageNumber) booleanpage(Message message, Transaction tx, RouteContextList listCtx) Write message to page if we are paging.intpage(Message message, Transaction tx, RouteContextList listCtx, Function<Message, Message> pageDecorator, boolean useFlowControl) voidpageFull(PageSubscription subscription) Callback to be used by a counter when the Page is full for that countervoidvoidreadLock()booleanreadLock(long timeout) voidvoidvoidprotected voidreloadLivePage(long pageId) removePage(int pageId) Returns a Page out of the Page System without reading it.protected voidvoidsendPages(ReplicationManager replicator, Collection<Integer> pageIds) Sends the pages with given IDs to theReplicationManager.voidstart()booleanReturns true if paging was started, or false if paging was already started before this call.voidstop()voidtoString()voidunblock()final PageusePage(long pageId) usePage(long pageId, boolean create) Use this method when you want to use the cache of used pages.usePage(long pageId, boolean createEntry, boolean createFile) voidwriteFlowControl(int credits) voidbooleanwriteLock(long timeout) Write lock the PagingStore.voidReleases locks acquired withPagingStore.writeLock(long).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.activemq.artemis.core.server.ActiveMQComponent
asyncStopMethods inherited from interface org.apache.activemq.artemis.core.paging.PagingStore
addSize, addSizeMethods inherited from interface org.apache.activemq.artemis.api.core.RefCountMessageListener
usageDown, usageUp
-
Constructor Details
-
PagingStoreImpl
public PagingStoreImpl(SimpleString address, ScheduledExecutorService scheduledExecutor, long syncTimeout, PagingManager pagingManager, StorageManager storageManager, SequentialFileFactory fileFactory, PagingStoreFactory storeFactory, SimpleString storeName, AddressSettings addressSettings, ArtemisExecutor executor, boolean syncNonTransactional)
-
-
Method Details
-
createPageTimedWriter
protected PageTimedWriter createPageTimedWriter(ScheduledExecutorService scheduledExecutor, long syncTimeout) -
replacePagedTimedWriter
-
applySetting
- Specified by:
applySettingin interfacePagingStore
-
toString
-
getPageFullMessagePolicy
- Specified by:
getPageFullMessagePolicyin interfacePagingStore
-
getPageLimitMessages
- Specified by:
getPageLimitMessagesin interfacePagingStore
-
getPageLimitBytes
- Specified by:
getPageLimitBytesin interfacePagingStore
-
pageFull
Description copied from interface:PagingStoreCallback to be used by a counter when the Page is full for that counter- Specified by:
pageFullin interfacePagingStore
-
isPageFull
public boolean isPageFull()- Specified by:
isPageFullin interfacePagingStore
-
checkPageLimit
public void checkPageLimit(long numberOfMessages) - Specified by:
checkPageLimitin interfacePagingStore
-
readLock
public void readLock()- Specified by:
readLockin interfacePagingStore
-
readLock
public boolean readLock(long timeout) - Specified by:
readLockin interfacePagingStore
-
readUnlock
public void readUnlock()- Specified by:
readUnlockin interfacePagingStore
-
writeLock
public void writeLock()- Specified by:
writeLockin interfacePagingStore
-
writeLock
public boolean writeLock(long timeout) Description copied from interface:PagingStoreWrite lock the PagingStore.- Specified by:
writeLockin interfacePagingStore- Parameters:
timeout- milliseconds to wait for the lock. If value is -1 then wait indefinitely.- Returns:
trueif the lock was obtained,falseotherwise
-
writeUnlock
public void writeUnlock()Description copied from interface:PagingStoreReleases locks acquired withPagingStore.writeLock(long).- Specified by:
writeUnlockin interfacePagingStore
-
getCursorProvider
- Specified by:
getCursorProviderin interfacePagingStore
-
getFirstPage
public long getFirstPage()- Specified by:
getFirstPagein interfacePagingStore
-
getAddress
- Specified by:
getAddressin interfacePagingStore
-
getAddressSize
public long getAddressSize()- Specified by:
getAddressSizein interfacePagingStore
-
getAddressElements
public long getAddressElements()- Specified by:
getAddressElementsin interfacePagingStore
-
getMaxSize
public long getMaxSize()- Specified by:
getMaxSizein interfacePagingStore
-
getMaxPageReadBytes
public int getMaxPageReadBytes()- Specified by:
getMaxPageReadBytesin interfacePagingStore
-
getPrefetchPageBytes
public int getPrefetchPageBytes()- Specified by:
getPrefetchPageBytesin interfacePagingStore
-
getMaxPageReadMessages
public int getMaxPageReadMessages()- Specified by:
getMaxPageReadMessagesin interfacePagingStore
-
getPrefetchPageMessages
public int getPrefetchPageMessages()- Specified by:
getPrefetchPageMessagesin interfacePagingStore
-
getAddressFullMessagePolicy
- Specified by:
getAddressFullMessagePolicyin interfacePagingStore
-
enforceAddressFullMessagePolicy
public PagingStoreImpl enforceAddressFullMessagePolicy(AddressFullMessagePolicy enforcedAddressFullMessagePolicy) - Specified by:
enforceAddressFullMessagePolicyin interfacePagingStore
-
getPageSizeBytes
public int getPageSizeBytes()- Specified by:
getPageSizeBytesin interfacePagingStore
-
getFolder
- Specified by:
getFolderin interfacePagingStore
-
getFolderName
- Specified by:
getFolderNamein 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- Returns:
- the page id of the current page in which the system is writing files
-
getStoreName
- Specified by:
getStoreNamein interfacePagingStore
-
ioSync
Description copied from interface:PagingStorePerforms a real sync on the current IO file.- Specified by:
ioSyncin interfacePagingStore- Throws:
Exception
-
processReload
- Specified by:
processReloadin interfacePagingStore- Throws:
Exception
-
getPagingManager
- Specified by:
getPagingManagerin interfacePagingStore
-
isStarted
public boolean isStarted()- Specified by:
isStartedin interfaceActiveMQComponent
-
counterSnapshot
public void counterSnapshot()Description copied from interface:PagingStoreSave snapshots on the counters- Specified by:
counterSnapshotin interfacePagingStore
-
stop
- Specified by:
stopin interfaceActiveMQComponent- Throws:
Exception
-
getExecutor
- Specified by:
getExecutorin interfacePagingStore
-
execute
- 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
-
getNumberOfFiles
- Throws:
Exception
-
start
- Specified by:
startin interfaceActiveMQComponent- Throws:
Exception
-
reloadLivePage
- Throws:
Exception
-
stopPaging
public void stopPaging()- Specified by:
stopPagingin interfacePagingStore
-
startPaging
public boolean startPaging()Description copied from interface:PagingStoreReturns true if paging was started, or false if paging was already started before this call.- Specified by:
startPagingin interfacePagingStore- Returns:
- true if paging was started, or false if paging was already started before this call
-
getCurrentPage
- Specified by:
getCurrentPagein interfacePagingStore
-
checkPageFileExists
public boolean checkPageFileExists(long pageNumber) - Specified by:
checkPageFileExistsin interfacePagingStore
-
newPageObject
- Specified by:
newPageObjectin interfacePagingStore- Throws:
Exception
-
usePage
- Specified by:
usePagein interfacePagingStore
-
usePage
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
-
usePage
- Specified by:
usePagein interfacePagingStore
-
getFileFactory
- Throws:
Exception
-
forceAnotherPage
- Specified by:
forceAnotherPagein interfacePagingStore- Throws:
Exception
-
forceAnotherPage
- Specified by:
forceAnotherPagein interfacePagingStore- Throws:
Exception
-
removePage
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
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
- Specified by:
checkMemoryin interfacePagingStore
-
checkMemory
public boolean checkMemory(boolean runOnFailure, Runnable runWhenAvailableParameter, Runnable runWhenBlocking, Consumer<AtomicRunnable> blockedCallback) - Specified by:
checkMemoryin interfacePagingStore
-
addSize
public void addSize(int size, boolean sizeOnly, boolean affectGlobal) Description copied from interface:PagingStoreAdd size to thisPageStore.- Specified by:
addSizein interfacePagingStoresizeOnly- iffalsewe 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
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
-
page
public int page(Message message, Transaction tx, RouteContextList listCtx, Function<Message, Message> pageDecorator, boolean useFlowControl) throws Exception- Specified by:
pagein interfacePagingStore- Throws:
Exception
-
writeFlowControl
public void writeFlowControl(int credits) - Specified by:
writeFlowControlin interfacePagingStore
-
directWritePage
protected void directWritePage(PagedMessage pagedMessage, boolean lineUp, boolean originalReplicated) throws Exception - Throws:
Exception
-
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
- Specified by:
durableDownin interfaceRefCountMessageListener
-
durableUp
- Specified by:
durableUpin interfaceRefCountMessageListener
-
refUp
- Specified by:
refUpin interfaceRefCountMessageListener
-
refDown
- Specified by:
refDownin interfaceRefCountMessageListener
-
hasPendingIO
public boolean hasPendingIO()- Specified by:
hasPendingIOin interfacePagingStore
-
getPageTimedWriter
-
destroy
- Specified by:
destroyin interfacePagingStore- Throws:
Exception
-
createFileName
-
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
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
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() -
forEachUsedPage
-
getStorageManager
- Specified by:
getStorageManagerin interfacePagingStore
-