use of org.apache.activemq.artemis.core.paging.cursor.PagePosition in project activemq-artemis by apache.
the class PageSubscriptionImpl method internalGetNext.
private PagedReference internalGetNext(final PagePosition pos) {
PagePosition retPos = pos.nextMessage();
PageCache cache = cursorProvider.getPageCache(pos.getPageNr());
if (cache != null && !cache.isLive() && retPos.getMessageNr() >= cache.getNumberOfMessages()) {
// The next message is beyond what's available at the current page, so we need to move to the next page
cache = null;
}
// it will scan for the next available page
while ((cache == null && retPos.getPageNr() <= pageStore.getCurrentWritingPage()) || (cache != null && retPos.getPageNr() <= pageStore.getCurrentWritingPage() && cache.getNumberOfMessages() == 0)) {
retPos = moveNextPage(retPos);
cache = cursorProvider.getPageCache(retPos.getPageNr());
}
if (cache == null) {
// it will be null in the case of the current writing page
return null;
} else {
PagedMessage serverMessage = cache.getMessage(retPos.getMessageNr());
if (serverMessage != null) {
return cursorProvider.newReference(retPos, serverMessage, this);
} else {
return null;
}
}
}
use of org.apache.activemq.artemis.core.paging.cursor.PagePosition in project activemq-artemis by apache.
the class PageSubscriptionImpl method processReload.
@Override
public void processReload() throws Exception {
if (recoveredACK != null) {
if (logger.isTraceEnabled()) {
logger.trace("********** processing reload!!!!!!!");
}
Collections.sort(recoveredACK);
long txDeleteCursorOnReload = -1;
for (PagePosition pos : recoveredACK) {
lastAckedPosition = pos;
PageCursorInfo pageInfo = getPageInfo(pos);
if (pageInfo == null) {
ActiveMQServerLogger.LOGGER.pageNotFound(pos);
if (txDeleteCursorOnReload == -1) {
txDeleteCursorOnReload = store.generateID();
}
store.deleteCursorAcknowledgeTransactional(txDeleteCursorOnReload, pos.getRecordID());
} else {
pageInfo.loadACK(pos);
}
}
if (txDeleteCursorOnReload >= 0) {
store.commit(txDeleteCursorOnReload);
}
recoveredACK.clear();
recoveredACK = null;
}
}
use of org.apache.activemq.artemis.core.paging.cursor.PagePosition in project activemq-artemis by apache.
the class PageSubscriptionImpl method onDeletePage.
@Override
public void onDeletePage(Page deletedPage) throws Exception {
PageCursorInfo info;
synchronized (consumedPages) {
info = consumedPages.remove(Long.valueOf(deletedPage.getPageId()));
}
if (info != null) {
PagePosition completeInfo = info.getCompleteInfo();
if (completeInfo != null) {
try {
store.deletePageComplete(completeInfo.getRecordID());
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.errorDeletingPageCompleteRecord(e);
}
info.setCompleteInfo(null);
}
for (PagePosition deleteInfo : info.acks) {
if (deleteInfo.getRecordID() >= 0) {
try {
store.deleteCursorAcknowledge(deleteInfo.getRecordID());
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.errorDeletingPageCompleteRecord(e);
}
}
}
info.acks.clear();
}
}
Aggregations