ARTEMIS-2321 PageCache doesn't need a Page reference

This commit is contained in:
Francesco Nigro 2019-04-26 10:05:17 +02:00 committed by Clebert Suconic
parent 2b3341d882
commit 82898a8a3c
4 changed files with 14 additions and 16 deletions

View File

@ -18,7 +18,6 @@ package org.apache.activemq.artemis.core.paging.cursor.impl;
import org.apache.activemq.artemis.core.paging.PagedMessage;
import org.apache.activemq.artemis.core.paging.cursor.LivePageCache;
import org.apache.activemq.artemis.core.paging.impl.Page;
import org.apache.activemq.artemis.core.server.LargeServerMessage;
import org.apache.activemq.artemis.utils.collections.ConcurrentAppendOnlyChunkedList;
import org.jboss.logging.Logger;
@ -34,18 +33,18 @@ public final class LivePageCacheImpl implements LivePageCache {
private final ConcurrentAppendOnlyChunkedList<PagedMessage> messages;
private final Page page;
private final long pageId;
private volatile boolean isLive = true;
public LivePageCacheImpl(final Page page) {
this.page = page;
public LivePageCacheImpl(final long pageId) {
this.pageId = pageId;
this.messages = new ConcurrentAppendOnlyChunkedList<>(CHUNK_SIZE);
}
@Override
public long getPageId() {
return page.getPageId();
return pageId;
}
@Override
@ -92,6 +91,6 @@ public final class LivePageCacheImpl implements LivePageCache {
@Override
public String toString() {
return "LivePacheCacheImpl::page=" + page.getPageId() + " number of messages=" + getNumberOfMessages() + " isLive = " + isLive;
return "LivePacheCacheImpl::page=" + pageId + " number of messages=" + getNumberOfMessages() + " isLive = " + isLive;
}
}

View File

@ -18,7 +18,6 @@ package org.apache.activemq.artemis.core.paging.cursor.impl;
import org.apache.activemq.artemis.core.paging.PagedMessage;
import org.apache.activemq.artemis.core.paging.cursor.PageCache;
import org.apache.activemq.artemis.core.paging.impl.Page;
/**
* The caching associated to a single page.
@ -31,14 +30,14 @@ class PageCacheImpl implements PageCache {
private PagedMessage[] messages;
private final Page page;
private final long pageId;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
PageCacheImpl(final Page page) {
this.page = page;
PageCacheImpl(final long pageId) {
this.pageId = pageId;
}
// Public --------------------------------------------------------
@ -54,7 +53,7 @@ class PageCacheImpl implements PageCache {
@Override
public long getPageId() {
return page.getPageId();
return pageId;
}
@Override
@ -78,7 +77,7 @@ class PageCacheImpl implements PageCache {
@Override
public String toString() {
return "PageCacheImpl::page=" + page.getPageId() + " numberOfMessages = " + messages.length;
return "PageCacheImpl::page=" + pageId + " numberOfMessages = " + messages.length;
}
@Override

View File

@ -567,8 +567,8 @@ public class PageCursorProviderImpl implements PageCursorProvider {
// Protected -----------------------------------------------------
/* Protected as we may let test cases to instrument the test */
protected PageCacheImpl createPageCache(final long pageId) throws Exception {
return new PageCacheImpl(pagingStore.createPage((int) pageId));
protected PageCacheImpl createPageCache(final long pageId) {
return new PageCacheImpl(pageId);
}
// Private -------------------------------------------------------

View File

@ -445,7 +445,7 @@ public class PagingStoreImpl implements PagingStore {
List<PagedMessage> messages = currentPage.read(storageManager);
LivePageCache pageCache = new LivePageCacheImpl(currentPage);
LivePageCache pageCache = new LivePageCacheImpl(currentPageId);
for (PagedMessage msg : messages) {
pageCache.addLiveMessage(msg);
@ -1091,7 +1091,7 @@ public class PagingStoreImpl implements PagingStore {
currentPage = createPage(tmpCurrentPageId);
LivePageCache pageCache = new LivePageCacheImpl(currentPage);
LivePageCache pageCache = new LivePageCacheImpl(tmpCurrentPageId);
currentPage.setLiveCache(pageCache);