@Override public void bookmark(PagePosition position) throws Exception { PageCursorInfo cursorInfo = getPageInfo(position); if (position.getMessageNr() > 0) { cursorInfo.confirmed.addAndGet(position.getMessageNr()); } confirmPosition(position); }
public void loadACK(final PagePosition posACK) { if (internalAddACK(posACK) && posACK.getMessageNr() >= 0) { confirmed.incrementAndGet(); } }
public void addACK(final PagePosition posACK) { if (logger.isTraceEnabled()) { try { logger.trace("numberOfMessages = " + getNumberOfMessages() + " confirmed = " + (confirmed.get() + 1) + " pendingTX = " + pendingTX + ", pageNr = " + pageId + " posACK = " + posACK); } catch (Throwable ignored) { logger.debug(ignored.getMessage(), ignored); } } boolean added = internalAddACK(posACK); // Negative could mean a bookmark on the first element for the page (example -1) if (added && posACK.getMessageNr() >= 0) { confirmed.incrementAndGet(); checkDone(); } }
@Override public PagedMessage getMessage(final PagePosition pos) { PageCache cache = getPageCache(pos.getPageNr()); if (cache == null || pos.getMessageNr() >= cache.getNumberOfMessages()) { // sanity check, this should never happen unless there's a bug throw new NonExistentPage("Invalid messageNumber passed = " + pos + " on " + cache); } return cache.getMessage(pos.getMessageNr()); }
@Override public void encode(ActiveMQBuffer buffer) { buffer.writeLong(queueID); buffer.writeLong(position.getPageNr()); buffer.writeInt(position.getMessageNr()); }
/** * A page marked as complete will be ignored until it's cleared. * <p> * 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. */ @Override public boolean reloadPageCompletion(PagePosition position) throws Exception { if (!pageStore.checkPageFileExists((int)position.getPageNr())) { return false; } // if the current page is complete, we must move it out of the way if (pageStore.getCurrentPage() != null && pageStore.getCurrentPage().getPageId() == position.getPageNr()) { pageStore.forceAnotherPage(); } PageCursorInfo info = new PageCursorInfo(position.getPageNr(), position.getMessageNr(), null); info.setCompleteInfo(position); synchronized (consumedPages) { consumedPages.put(Long.valueOf(position.getPageNr()), info); } return true; }
if (cache != null && !cache.isLive() && retPos.getMessageNr() >= cache.getNumberOfMessages()) { emptyCache = cache; saveEmptyPageAsConsumedPage(emptyCache); PagedMessage serverMessage = cache.getMessage(retPos.getMessageNr());
size = getPersistentSize(cache.getMessage(position.getMessageNr())); } else { size = persistentSize;