Class PageSubscriptionImpl
- java.lang.Object
-
- org.apache.activemq.artemis.core.paging.cursor.impl.PageSubscriptionImpl
-
- All Implemented Interfaces:
PageSubscription
public final class PageSubscriptionImpl extends Object implements PageSubscription
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classPageSubscriptionImpl.PageCursorInfoThis will hold information about the pending ACKs towards a page.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidack(PagedReference reference)voidackTx(Transaction tx, PagedReference reference)voidaddPendingDelivery(PagedMessage pagedMessage)voidbookmark(PagePosition position)voidcleanupEntries(boolean completeDelete)It will cleanup all the records for completed pagesvoidconfirmPosition(PagePosition position)voidconfirmPosition(Transaction tx, PagePosition position)booleancontains(PagedReference ref)voidcounterSnapshot()Save a snapshot of the current counter value in the journalvoiddestroy()All the data associated with the cursor should go away herevoiddisableAutoCleanup()voidenableAutoCleanup()voidforEachConsumedPage(Consumer<ConsumedPage> pageConsumer)PageSubscriptionCountergetCounter()longgetDeliveredCount()longgetDeliveredSize()longgetFirstPage()longgetId()longgetMessageCount()PageSubscriptionImpl.PageCursorInfogetPageInfo(long pageNr)PagingStoregetPagingStore()longgetPersistentSize()PageCursorProvidergetProvider()QueuegetQueue()AtomicIntegergetScheduledCleanupCount()for testsvoidincrementDeliveredSize(long size)booleanisComplete(long page)booleanisCounterPending()booleanisPaging()Used as a delegate method toPagingStore.isPaging()booleanisPersistent()PageIteratoriterator()PageIteratoriterator(boolean browsing)voidlateDeliveryRollback(PagePosition position)PageSubscriptionImpl.PageCursorInfolocatePageInfo(long pageNr)voidnotEmpty()This is a callback to inform the PageSubscription that something was routed, so the empty flag can be clearedvoidonDeletePage(Page deletedPage)voidonPageModeCleared(Transaction tx)voidpositionIgnored(PagePosition position)To be called when the cursor decided to ignore a position.voidprintDebug()voidprintDebug(String msg)voidprocessReload()PagedMessagequeryMessage(PagePosition pos)To be used to requery the referencevoidredeliver(PageIterator iterator, PagedReference pagedReference)voidreloadACK(PagePosition position)Theres no need to synchronize this method as it's only called from journal load on startupbooleanreloadPageCompletion(PagePosition position)A page marked as complete will be ignored until it's cleared.voidreloadPageInfo(long pageNr)voidreloadPreparedACK(Transaction tx, PagePosition position)To be used to avoid a redelivery of a prepared ACK after loadvoidremovePendingDelivery(PagedMessage pagedMessage)voidscanAck(BooleanSupplier retryBeforeScan, ToIntFunction<PagedReference> scanFunction, Runnable found, Runnable notFound)This method will schedule scanning over Paging, however a retry should be done before the scanning.voidscheduleCleanupCheck()voidsetQueue(Queue queue)voidstop()StringtoString()
-
-
-
Method Detail
-
getScheduledCleanupCount
public AtomicInteger getScheduledCleanupCount()
for tests
-
scanAck
public void scanAck(BooleanSupplier retryBeforeScan, ToIntFunction<PagedReference> scanFunction, Runnable found, Runnable notFound)
Description copied from interface:PageSubscriptionThis method will schedule scanning over Paging, however a retry should be done before the scanning.- Specified by:
scanAckin interfacePageSubscription- Parameters:
retryBeforeScan- if this function is called and returns true, the scan for this element will not be called. It would be caller's responsibility to call found.
-
getPagingStore
public PagingStore getPagingStore()
- Specified by:
getPagingStorein interfacePageSubscription
-
getQueue
public Queue getQueue()
- Specified by:
getQueuein interfacePageSubscription
-
isPaging
public boolean isPaging()
Description copied from interface:PageSubscriptionUsed as a delegate method toPagingStore.isPaging()- Specified by:
isPagingin interfacePageSubscription
-
setQueue
public void setQueue(Queue queue)
- Specified by:
setQueuein interfacePageSubscription
-
disableAutoCleanup
public void disableAutoCleanup()
- Specified by:
disableAutoCleanupin interfacePageSubscription
-
enableAutoCleanup
public void enableAutoCleanup()
- Specified by:
enableAutoCleanupin interfacePageSubscription
-
getProvider
public PageCursorProvider getProvider()
-
notEmpty
public void notEmpty()
Description copied from interface:PageSubscriptionThis is a callback to inform the PageSubscription that something was routed, so the empty flag can be cleared- Specified by:
notEmptyin interfacePageSubscription
-
bookmark
public void bookmark(PagePosition position) throws Exception
- Specified by:
bookmarkin interfacePageSubscription- Throws:
Exception
-
getMessageCount
public long getMessageCount()
- Specified by:
getMessageCountin interfacePageSubscription
-
isCounterPending
public boolean isCounterPending()
- Specified by:
isCounterPendingin interfacePageSubscription
-
getPersistentSize
public long getPersistentSize()
- Specified by:
getPersistentSizein interfacePageSubscription
-
getCounter
public PageSubscriptionCounter getCounter()
- Specified by:
getCounterin interfacePageSubscription
-
reloadPageCompletion
public boolean reloadPageCompletion(PagePosition position) throws Exception
A page marked as complete will be ignored until it's cleared.Usually paging is a stream of messages but in certain scenarios (such as a pending prepared TX) we may have big holes on the page streaming, and we will need to ignore such pages on the cursor/subscription.
- Specified by:
reloadPageCompletionin interfacePageSubscription- Throws:
Exception
-
scheduleCleanupCheck
public void scheduleCleanupCheck()
- Specified by:
scheduleCleanupCheckin interfacePageSubscription
-
onPageModeCleared
public void onPageModeCleared(Transaction tx) throws Exception
- Specified by:
onPageModeClearedin interfacePageSubscription- Throws:
Exception
-
cleanupEntries
public void cleanupEntries(boolean completeDelete) throws ExceptionIt will cleanup all the records for completed pages- Specified by:
cleanupEntriesin interfacePageSubscription- Throws:
Exception
-
iterator
public PageIterator iterator()
- Specified by:
iteratorin interfacePageSubscription
-
iterator
public PageIterator iterator(boolean browsing)
- Specified by:
iteratorin interfacePageSubscription
-
confirmPosition
public void confirmPosition(Transaction tx, PagePosition position) throws Exception
- Specified by:
confirmPositionin interfacePageSubscription- Throws:
Exception
-
ackTx
public void ackTx(Transaction tx, PagedReference reference) throws Exception
- Specified by:
ackTxin interfacePageSubscription- Throws:
Exception
-
ack
public void ack(PagedReference reference) throws Exception
- Specified by:
ackin interfacePageSubscription- Throws:
Exception
-
contains
public boolean contains(PagedReference ref) throws Exception
- Specified by:
containsin interfacePageSubscription- Throws:
Exception
-
confirmPosition
public void confirmPosition(PagePosition position) throws Exception
- Specified by:
confirmPositionin interfacePageSubscription- Throws:
Exception
-
getFirstPage
public long getFirstPage()
- Specified by:
getFirstPagein interfacePageSubscription- Returns:
- the first page in use or MAX_LONG if none is in use
-
addPendingDelivery
public void addPendingDelivery(PagedMessage pagedMessage)
- Specified by:
addPendingDeliveryin interfacePageSubscription
-
removePendingDelivery
public void removePendingDelivery(PagedMessage pagedMessage)
- Specified by:
removePendingDeliveryin interfacePageSubscription
-
redeliver
public void redeliver(PageIterator iterator, PagedReference pagedReference)
- Specified by:
redeliverin interfacePageSubscription
-
queryMessage
public PagedMessage queryMessage(PagePosition pos)
Description copied from interface:PageSubscriptionTo be used to requery the reference- Specified by:
queryMessagein interfacePageSubscription- Returns:
-
reloadACK
public void reloadACK(PagePosition position)
Theres no need to synchronize this method as it's only called from journal load on startup- Specified by:
reloadACKin interfacePageSubscription
-
reloadPreparedACK
public void reloadPreparedACK(Transaction tx, PagePosition position)
Description copied from interface:PageSubscriptionTo be used to avoid a redelivery of a prepared ACK after load- Specified by:
reloadPreparedACKin interfacePageSubscription
-
positionIgnored
public void positionIgnored(PagePosition position)
Description copied from interface:PageSubscriptionTo be called when the cursor decided to ignore a position.- Specified by:
positionIgnoredin interfacePageSubscription
-
lateDeliveryRollback
public void lateDeliveryRollback(PagePosition position)
- Specified by:
lateDeliveryRollbackin interfacePageSubscription
-
forEachConsumedPage
public void forEachConsumedPage(Consumer<ConsumedPage> pageConsumer)
- Specified by:
forEachConsumedPagein interfacePageSubscription
-
isComplete
public boolean isComplete(long page)
- Specified by:
isCompletein interfacePageSubscription- Returns:
-
destroy
public void destroy() throws ExceptionAll the data associated with the cursor should go away here- Specified by:
destroyin interfacePageSubscription- Throws:
Exception
-
getId
public long getId()
- Specified by:
getIdin interfacePageSubscription
-
isPersistent
public boolean isPersistent()
- Specified by:
isPersistentin interfacePageSubscription
-
processReload
public void processReload() throws Exception- Specified by:
processReloadin interfacePageSubscription- Throws:
Exception
-
stop
public void stop()
- Specified by:
stopin interfacePageSubscription
-
counterSnapshot
public void counterSnapshot()
Description copied from interface:PageSubscriptionSave a snapshot of the current counter value in the journal- Specified by:
counterSnapshotin interfacePageSubscription
-
printDebug
public void printDebug()
- Specified by:
printDebugin interfacePageSubscription
-
printDebug
public void printDebug(String msg)
-
onDeletePage
public void onDeletePage(Page deletedPage) throws Exception
- Specified by:
onDeletePagein interfacePageSubscription- Throws:
Exception
-
reloadPageInfo
public void reloadPageInfo(long pageNr)
- Specified by:
reloadPageInfoin interfacePageSubscription
-
locatePageInfo
public PageSubscriptionImpl.PageCursorInfo locatePageInfo(long pageNr)
- Specified by:
locatePageInfoin interfacePageSubscription
-
getPageInfo
public PageSubscriptionImpl.PageCursorInfo getPageInfo(long pageNr)
-
getDeliveredCount
public long getDeliveredCount()
- Specified by:
getDeliveredCountin interfacePageSubscription- Returns:
- the deliveredCount
-
getDeliveredSize
public long getDeliveredSize()
- Specified by:
getDeliveredSizein interfacePageSubscription- Returns:
- the deliveredSize
-
incrementDeliveredSize
public void incrementDeliveredSize(long size)
- Specified by:
incrementDeliveredSizein interfacePageSubscription
-
-