From 82898a8a3c4938ab86ae0f08b85ad59222b3a2b1 Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Fri, 26 Apr 2019 10:05:17 +0200 Subject: [PATCH] ARTEMIS-2321 PageCache doesn't need a Page reference --- .../core/paging/cursor/impl/LivePageCacheImpl.java | 11 +++++------ .../core/paging/cursor/impl/PageCacheImpl.java | 11 +++++------ .../paging/cursor/impl/PageCursorProviderImpl.java | 4 ++-- .../artemis/core/paging/impl/PagingStoreImpl.java | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java index 6b55439b05..9d3fa723c6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java @@ -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 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; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java index 5925caf620..3874e4f303 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java @@ -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 diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java index 5ca95681e4..5d9fb0685d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java @@ -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 ------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java index 213ff2b948..6fb32b2833 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java @@ -445,7 +445,7 @@ public class PagingStoreImpl implements PagingStore { List 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);