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.PagedMessage;
import org.apache.activemq.artemis.core.paging.cursor.LivePageCache; 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.core.server.LargeServerMessage;
import org.apache.activemq.artemis.utils.collections.ConcurrentAppendOnlyChunkedList; import org.apache.activemq.artemis.utils.collections.ConcurrentAppendOnlyChunkedList;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -34,18 +33,18 @@ public final class LivePageCacheImpl implements LivePageCache {
private final ConcurrentAppendOnlyChunkedList<PagedMessage> messages; private final ConcurrentAppendOnlyChunkedList<PagedMessage> messages;
private final Page page; private final long pageId;
private volatile boolean isLive = true; private volatile boolean isLive = true;
public LivePageCacheImpl(final Page page) { public LivePageCacheImpl(final long pageId) {
this.page = page; this.pageId = pageId;
this.messages = new ConcurrentAppendOnlyChunkedList<>(CHUNK_SIZE); this.messages = new ConcurrentAppendOnlyChunkedList<>(CHUNK_SIZE);
} }
@Override @Override
public long getPageId() { public long getPageId() {
return page.getPageId(); return pageId;
} }
@Override @Override
@ -92,6 +91,6 @@ public final class LivePageCacheImpl implements LivePageCache {
@Override @Override
public String toString() { 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.PagedMessage;
import org.apache.activemq.artemis.core.paging.cursor.PageCache; 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. * The caching associated to a single page.
@ -31,14 +30,14 @@ class PageCacheImpl implements PageCache {
private PagedMessage[] messages; private PagedMessage[] messages;
private final Page page; private final long pageId;
// Static -------------------------------------------------------- // Static --------------------------------------------------------
// Constructors -------------------------------------------------- // Constructors --------------------------------------------------
PageCacheImpl(final Page page) { PageCacheImpl(final long pageId) {
this.page = page; this.pageId = pageId;
} }
// Public -------------------------------------------------------- // Public --------------------------------------------------------
@ -54,7 +53,7 @@ class PageCacheImpl implements PageCache {
@Override @Override
public long getPageId() { public long getPageId() {
return page.getPageId(); return pageId;
} }
@Override @Override
@ -78,7 +77,7 @@ class PageCacheImpl implements PageCache {
@Override @Override
public String toString() { public String toString() {
return "PageCacheImpl::page=" + page.getPageId() + " numberOfMessages = " + messages.length; return "PageCacheImpl::page=" + pageId + " numberOfMessages = " + messages.length;
} }
@Override @Override

View File

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

View File

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