This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 82898a8a3c4938ab86ae0f08b85ad59222b3a2b1
Author: Francesco Nigro <nigro....@gmail.com>
AuthorDate: Fri Apr 26 10:05:17 2019 +0200

    ARTEMIS-2321 PageCache doesn't need a Page reference
---
 .../artemis/core/paging/cursor/impl/LivePageCacheImpl.java    | 11 +++++------
 .../artemis/core/paging/cursor/impl/PageCacheImpl.java        | 11 +++++------
 .../core/paging/cursor/impl/PageCursorProviderImpl.java       |  4 ++--
 .../activemq/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 6b55439..9d3fa72 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<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;
    }
 }
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 5925caf..3874e4f 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 5ca9568..5d9fb06 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 213ff2b..6fb32b2 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<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);
 

Reply via email to