[ 
https://issues.apache.org/jira/browse/ARTEMIS-3850?focusedWorklogId=779061&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-779061
 ]

ASF GitHub Bot logged work on ARTEMIS-3850:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Jun/22 12:29
            Start Date: 07/Jun/22 12:29
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on code in PR #4101:
URL: https://github.com/apache/activemq-artemis/pull/4101#discussion_r891092466


##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XmlDataExporter.java:
##########
@@ -398,46 +399,50 @@ private void printPagedMessagesAsXML() {
                ActiveMQServerLogger.LOGGER.debug("Reading page store " + store 
+ " folder = " + folder);
 
                int pageId = (int) pageStore.getFirstPage();
-               for (int i = 0; i < pageStore.getNumberOfPages(); i++) {
+               for (long i = 0; i < pageStore.getNumberOfPages(); i++) {
                   ActiveMQServerLogger.LOGGER.debug("Reading page " + pageId);
-                  Page page = pageStore.createPage(pageId);
+                  Page page = pageStore.newPageObject(pageId);

Review Comment:
   The pageId variable above should be changed to _long_ as well, it is 
currently being truncated to _int_ on declaration and then widened back to 
_long_ here.



##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/EmptyList.java:
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.utils.collections;
+
+import java.util.function.Consumer;
+
+public class EmptyList<E> implements LinkedList<E> {
+
+
+   private static final LinkedList emptyList = new EmptyList();
+
+   public static final <T> LinkedList<T> getEmptyList() {
+      return (LinkedList<T>) emptyList;
+   }
+
+   private EmptyList() {
+   }
+
+
+
+
+   @Override
+   public void addHead(E e) {
+   }

Review Comment:
   Its usually nicer for unmodifiable lists to throw on attempts to change 
them, so that people who misuse them find it out pretty quickly, as opposed to 
having to investigate later where exactly things happened to unexpectedly get 
black-holed.
   
   (Same comment applies to all other manipulating methods)



##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SizeAwareMetric.java:
##########
@@ -59,6 +59,13 @@ public interface AddCallback {
 
    private Runnable underCallback;
 
+   /** To be used in a case where we just measure elements */
+   public SizeAwareMetric() {
+      this.sizeEnabled = false;
+      this.elementsEnabled = false;
+   }

Review Comment:
   So, a counter? Why use this rather than a basic/atomic numeric type?



##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/LinkedListImpl.java:
##########
@@ -102,6 +103,17 @@ public void addHead(E e) {
       size++;
    }
 
+   @Override
+   public E get(int position) {
+      Node<E> current = head.next;
+
+      for (int i = 0; i < position && current != null; i++) {
+         current = current.next;
+      }
+
+      return current.val();

Review Comment:
   This assumes current exists but it may not (which the for handles). Should 
throw index out of bounds rather than NPE?



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java:
##########
@@ -1261,6 +1265,14 @@ protected Pair<String, AddressSettings> 
parseAddressSettings(final Node node) {
             long pageSizeLong = 
ByteUtil.convertTextBytes(getTrimmedTextContent(child));
             Validators.POSITIVE_INT.validate(PAGE_SIZE_BYTES_NODE_NAME, 
pageSizeLong);
             addressSettings.setPageSizeBytes((int) pageSizeLong);
+         }  else if (MAX_READ_PAGE_MESSAGES_NODE_NAME.equalsIgnoreCase(name)) {
+            long maxReadPageMessages = 
Long.parseLong(getTrimmedTextContent(child));
+            Validators.POSITIVE_INT.validate(PAGE_SIZE_BYTES_NODE_NAME, 
maxReadPageMessages);
+            addressSettings.setMaxReadPageMessages((int)maxReadPageMessages);
+         }  else if (MAX_READ_PAGE_BYTES_NODE_NAME.equalsIgnoreCase(name)) {
+            long maxReadPageBytes = 
ByteUtil.convertTextBytes(getTrimmedTextContent(child));
+            Validators.POSITIVE_INT.validate(PAGE_SIZE_BYTES_NODE_NAME, 
maxReadPageBytes);

Review Comment:
   Both the validate calls pass the same wrong name.



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageSubscription.java:
##########
@@ -186,5 +169,5 @@ public interface PageSubscription {
 
    void incrementDeliveredSize(long size);
 
-   void removePendingDelivery(PagePosition position);
+   void removePendingDelivery(PagedMessage position);

Review Comment:
   Ditto



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java:
##########
@@ -327,17 +156,11 @@ public void stop() {
    }
 
    private void waitForFuture() {
-      if (!executor.flush(10, TimeUnit.SECONDS)) {
-         ActiveMQServerLogger.LOGGER.timedOutStoppingPagingCursor(executor);
-         ActiveMQServerLogger.LOGGER.threadDump(ThreadDumpUtil.threadDump(""));
-      }
+      pagingStore.flushExecutors();

Review Comment:
   seems odd for this private waitForFuture() method to exist when it doesnt 
actually wait for a future, and instead is flushing the executor, and is called 
from the flushExecutors() method...



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/ReaderContext.java:
##########
@@ -1,24 +1,49 @@
-/*
+/**

Review Comment:
   Ditto



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java:
##########
@@ -462,7 +285,12 @@ public void cleanup() {
                // Then we do some check on eventual pages that can be already 
removed but they are away from the streaming
                cleanupMiddleStream(depagedPages, depagedPagesSet, cursorList, 
minPage, firstPage);
 
-               if (pagingStore.getNumberOfPages() == 0 || 
pagingStore.getNumberOfPages() == 1 && 
pagingStore.getCurrentPage().getNumberOfMessages() == 0) {
+               if (pagingStore.getNumberOfPages() < 0) {
+                  new Exception("WHAT???").printStackTrace(System.out);

Review Comment:
   needs tidied up



##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/EmptyList.java:
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.utils.collections;
+
+import java.util.function.Consumer;
+
+public class EmptyList<E> implements LinkedList<E> {
+
+
+   private static final LinkedList emptyList = new EmptyList();

Review Comment:
   uppercase for constant?



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageIterator.java:
##########
@@ -21,8 +21,13 @@
 
 public interface PageIterator extends LinkedListIterator<PagedReference> {
 
-   void redeliver(PagePosition reference);
+   enum NextResult {
+      noElements,
+      hasElements,
+      retry
+   }
+   void redeliver(PagedReference reference);
 
    // return 0 if no elements, 1 if having more elements, 2 if taking too long 
to find
-   int tryNext();
+   NextResult tryNext();

Review Comment:
   Comment is inaccurate now it doesnt return int.



##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/EmptyList.java:
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.utils.collections;
+
+import java.util.function.Consumer;
+
+public class EmptyList<E> implements LinkedList<E> {
+
+
+   private static final LinkedList emptyList = new EmptyList();
+
+   public static final <T> LinkedList<T> getEmptyList() {
+      return (LinkedList<T>) emptyList;
+   }
+
+   private EmptyList() {
+   }
+
+
+
+
+   @Override
+   public void addHead(E e) {
+   }
+
+   @Override
+   public void addTail(E e) {
+   }
+
+   @Override
+   public E get(int position) {
+      return null;
+   }
+
+   @Override
+   public E poll() {
+      return null;
+   }
+
+   LinkedListIterator<E> emptyIterator = new LinkedListIterator<E>() {

Review Comment:
   Could be private static final also?



##########
artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml:
##########
@@ -141,6 +141,13 @@ 
${cluster-security.settings}${cluster.settings}${replicated.settings}${shared-st
             <max-size-bytes>-1</max-size-bytes>
             <!

Issue Time Tracking
-------------------

    Worklog Id:     (was: 779061)
    Time Spent: 40m  (was: 0.5h)

> Add Option to read messages into paging based on sizing and eliminate caching
> -----------------------------------------------------------------------------
>
>                 Key: ARTEMIS-3850
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3850
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>    Affects Versions: 2.22.0
>            Reporter: Clebert Suconic
>            Assignee: Clebert Suconic
>            Priority: Major
>             Fix For: 2.23.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to