ARTEMIS-2321 PageCache doesn't need a Page reference
This commit is contained in:
parent
2b3341d882
commit
82898a8a3c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 -------------------------------------------------------
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue