org.apache.activemq.artemis.core.paging.cursor.PageCache

Here are the examples of the java api class org.apache.activemq.artemis.core.paging.cursor.PageCache taken from open source projects.

1. PageCursorStressTest#testReadNextPage()

View license
@Test
public void testReadNextPage() throws Exception {
    final int NUM_MESSAGES = 1;
    int numberOfPages = addMessages(NUM_MESSAGES, 1024);
    System.out.println("NumberOfPages = " + numberOfPages);
    PageCursorProvider cursorProvider = lookupCursorProvider();
    PageCache cache = cursorProvider.getPageCache(2);
    assertNull(cache);
}

2. PageCursorProviderImpl#getMessage()

View license
@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());
}

3. PageCursorProviderImpl#printDebug()

View license
@Override
public void printDebug() {
    System.out.println("Debug information for PageCursorProviderImpl:");
    for (PageCache cache : softCache.values()) {
        System.out.println("Cache " + cache);
    }
}

4. PageSubscriptionImpl#internalGetNext()

View license
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;
        }
    }
}