You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "clebertsuconic (via GitHub)" <gi...@apache.org> on 2023/01/27 21:45:26 UTC

[GitHub] [activemq-artemis] clebertsuconic opened a new pull request, #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

clebertsuconic opened a new pull request, #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349

   I am adding three attributes to Address-settings:
   
   page-limit-bytes: Number of bytes. We will convert this metric into max number of pages internally by dividing max-bytes / page-size. It will allow a max based on an estimate. page-limit-messages: Number of messages
   page-full-message-policy: fail : drop
   
   We will now allow paging, until these max values and then fail or drop messages.
   
   Once these values are retracted, the address will remain full until a period where cleanup is kicked in by paging. So these values may have a certain delay on being applied, but they should always be cleared once cleanup happened.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090981753


##########
artemis-server/src/main/resources/schema/artemis-configuration.xsd:
##########
@@ -4000,6 +4000,23 @@
                </xsd:annotation>
             </xsd:element>
 
+            <xsd:element name="page-limit-bytes" type="xsd:string" default="-1" maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     After the address entering into page mode, this attribute will configure how many pages can be written into page before activating the page-full-policy.

Review Comment:
   thanks Tim



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] tabish121 commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090963438


##########
artemis-server/src/main/resources/schema/artemis-configuration.xsd:
##########
@@ -4000,6 +4000,23 @@
                </xsd:annotation>
             </xsd:element>
 
+            <xsd:element name="page-limit-bytes" type="xsd:string" default="-1" maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     After the address entering into page mode, this attribute will configure how many pages can be written into page before activating the page-full-policy.

Review Comment:
   This reads a bit funny, should it be "After the address enters into page mode...."  same for the below comment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] tabish121 commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090906925


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java:
##########
@@ -179,11 +182,13 @@ public void close(PageSubscription cursor) {
    }
 
    @Override
-   public void scheduleCleanup() {
+   public Future<Boolean> scheduleCleanup() {
+      final SimpleFutureImpl<Boolean> future = new SimpleFutureImpl<>();
       if (!cleanupEnabled || scheduledCleanup.intValue() > 2) {
          // Scheduled cleanup was already scheduled before.. never mind!
          // or we have cleanup disabled
-         return;
+         pagingStore.execute(() -> future.set(true));

Review Comment:
   Is there a reason why you need to fire off a task into the executor just to return a completed future?  Seems simpler to just return CompletableFuture.completedFuture or just complete this one and return it directly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic merged pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic merged PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090982660


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();

Review Comment:
   added validation



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090928630


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java:
##########
@@ -179,11 +182,13 @@ public void close(PageSubscription cursor) {
    }
 
    @Override
-   public void scheduleCleanup() {
+   public Future<Boolean> scheduleCleanup() {
+      final SimpleFutureImpl<Boolean> future = new SimpleFutureImpl<>();
       if (!cleanupEnabled || scheduledCleanup.intValue() > 2) {
          // Scheduled cleanup was already scheduled before.. never mind!
          // or we have cleanup disabled
-         return;
+         pagingStore.execute(() -> future.set(true));

Review Comment:
   I am amending the comment before future.set call as:
   
            // Scheduled cleanup was already scheduled before.
            // On that case just flush the executor returning the future.set(true) 
            // after any previous scheduled cleanup is finished.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090927064


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java:
##########
@@ -179,11 +182,13 @@ public void close(PageSubscription cursor) {
    }
 
    @Override
-   public void scheduleCleanup() {
+   public Future<Boolean> scheduleCleanup() {
+      final SimpleFutureImpl<Boolean> future = new SimpleFutureImpl<>();
       if (!cleanupEnabled || scheduledCleanup.intValue() > 2) {
          // Scheduled cleanup was already scheduled before.. never mind!
          // or we have cleanup disabled
-         return;
+         pagingStore.execute(() -> future.set(true));

Review Comment:
   Yes... I wanted to make sure any previous call to cleanup was finished. Say you called scheduleCleanup a couple of times.. then you call scheduleCleanup again...
   
   
    I don't need to schedule another one as I already have a call scheduled, but I want to return a Future that will be released after these calls have finished.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#issuecomment-1409508303

   thanks for the reviews!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090987006


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -1029,6 +1131,25 @@ public boolean page(Message message,
          lock.readLock().unlock();
       }
 
+      if (pageFull && pageFullMessagePolicy != null) {

Review Comment:
   Probably. It feels wrong not doing the redundant check though! :) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1091087583


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -1029,6 +1131,25 @@ public boolean page(Message message,
          lock.readLock().unlock();
       }
 
+      if (pageFull && pageFullMessagePolicy != null) {

Review Comment:
   My OCD wants to keep it, but I will remove it :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090980994


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();
+
+      if (pageLimitBytes != null && pageSize > 0) {
+         estimatedMaxPages = pageLimitBytes / pageSize;
+         logger.debug("Address {} should not allow more than {} pages", storeName, estimatedMaxPages);
+      }

Review Comment:
   I'm changing the constructor to make any -1 as null.
   
   
   I won't just change the File parser as the same could be set through properties.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#issuecomment-1407108809

   I need to finish docs, and add testing for dropping.. which I should finish Monday morning.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090929324


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java:
##########
@@ -179,11 +182,13 @@ public void close(PageSubscription cursor) {
    }
 
    @Override
-   public void scheduleCleanup() {
+   public Future<Boolean> scheduleCleanup() {
+      final SimpleFutureImpl<Boolean> future = new SimpleFutureImpl<>();
       if (!cleanupEnabled || scheduledCleanup.intValue() > 2) {
          // Scheduled cleanup was already scheduled before.. never mind!
          // or we have cleanup disabled
-         return;
+         pagingStore.execute(() -> future.set(true));

Review Comment:
   marking it as resolved.. please unresolved it if you find any issues with my comments please?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] gemmellr commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090865601


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java:
##########
@@ -60,6 +62,19 @@ public interface PagingStore extends ActiveMQComponent, RefCountMessageListener
 
    AddressFullMessagePolicy getAddressFullMessagePolicy();
 
+   PageFullMessagePolicy getPageFullMessagePolicy();
+
+   Long getPageLimitMessages();

Review Comment:
   Presumably this is being null checked somewhere given the Long usage. Since the config setting is defined as having default -1, might it be nicer to just use that for the checks? Since a non-null value would also have to be checked for being >0 anyway, in case someone excplicitly sets it to the -1 default?



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java:
##########
@@ -241,6 +249,23 @@ public void resumeCleanup() {
       scheduleCleanup();
    }
 
+   private long getNumberOfMessagesOnSubscriptions() {
+      AtomicLong largerCounter = new AtomicLong();
+      activeCursors.forEach((id, sub) -> {
+         long value = sub.getCounter().getValue();
+         if (value > largerCounter.get()) {
+            largerCounter.set(value);
+         }
+      });
+
+      return largerCounter.get();
+   }
+
+   void checkClearPageLimit() {
+

Review Comment:
   Superfluous newline



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();
+
+      if (pageLimitBytes != null && pageSize > 0) {
+         estimatedMaxPages = pageLimitBytes / pageSize;
+         logger.debug("Address {} should not allow more than {} pages", storeName, estimatedMaxPages);
+      }
    }
 
    @Override
    public String toString() {
       return "PagingStoreImpl(" + this.address + ")";
    }
 
+   @Override
+   public PageFullMessagePolicy getPageFullMessagePolicy() {
+      return pageFullMessagePolicy;
+   }
+
+   @Override
+   public Long getPageLimitMessages() {
+      return pageLimitMessages;
+   }
+
+   @Override
+   public Long getPageLimitBytes() {
+      return pageLimitBytes;
+   }
+
+   @Override
+   public void pageFull(PageSubscription subscription) {
+      this.pageFull = true;
+      try {
+         ActiveMQServerLogger.LOGGER.pageFull(subscription.getQueue().getName(), subscription.getQueue().getAddress(), pageLimitMessages, subscription.getCounter().getValue());
+      } catch (Throwable e) {
+         // I don't think subscription would ever have a null queue. I'm being cautious here for tests
+         logger.warn(e.getMessage(), e);
+      }
+   }
+
+   @Override
+   public boolean isPageFull() {
+      return pageFull;
+   }
+
+   private boolean isBellowPageLimitBytes() {
+      if (estimatedMaxPages != null) {
+         return (numberOfPages <= estimatedMaxPages.longValue());
+      }  else {
+         return true;
+      }
+   }
+
+   private void checkNumberOfPages() {
+      if (!isBellowPageLimitBytes()) {
+         this.pageFull = true;
+         ActiveMQServerLogger.LOGGER.pageFullMaxBytes(storeName, numberOfPages, estimatedMaxPages, pageLimitBytes, pageSize);
+      }
+   }
+
+   @Override
+   public void checkPageLimit(long numberOfMessages) {
+
+

Review Comment:
   Superfluous newlines



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();
+
+      if (pageLimitBytes != null && pageSize > 0) {
+         estimatedMaxPages = pageLimitBytes / pageSize;
+         logger.debug("Address {} should not allow more than {} pages", storeName, estimatedMaxPages);
+      }
    }
 
    @Override
    public String toString() {
       return "PagingStoreImpl(" + this.address + ")";
    }
 
+   @Override
+   public PageFullMessagePolicy getPageFullMessagePolicy() {
+      return pageFullMessagePolicy;
+   }
+
+   @Override
+   public Long getPageLimitMessages() {
+      return pageLimitMessages;
+   }
+
+   @Override
+   public Long getPageLimitBytes() {
+      return pageLimitBytes;
+   }
+
+   @Override
+   public void pageFull(PageSubscription subscription) {
+      this.pageFull = true;
+      try {
+         ActiveMQServerLogger.LOGGER.pageFull(subscription.getQueue().getName(), subscription.getQueue().getAddress(), pageLimitMessages, subscription.getCounter().getValue());
+      } catch (Throwable e) {
+         // I don't think subscription would ever have a null queue. I'm being cautious here for tests
+         logger.warn(e.getMessage(), e);
+      }
+   }
+
+   @Override
+   public boolean isPageFull() {
+      return pageFull;
+   }
+
+   private boolean isBellowPageLimitBytes() {

Review Comment:
   typo, Below



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -1029,6 +1131,25 @@ public boolean page(Message message,
          lock.readLock().unlock();
       }
 
+      if (pageFull && pageFullMessagePolicy != null) {

Review Comment:
   Related to earlier comment, if it validates you have a policy, can this then just simply check "if (pageFull)" ?



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();

Review Comment:
   Should it validate you have actually set a policy if setting one or both of the others to enforcing values? That way you cant accidentally think you have a limit when you dont.



##########
artemis-server/src/main/resources/schema/artemis-configuration.xsd:
##########
@@ -4062,6 +4079,20 @@
                </xsd:simpleType>
             </xsd:element>
 
+            <xsd:element name="page-full-policy" maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     After entering page mode, a second limit will be set by page-limit-bytes, page-limit-messages. page-full-policy will configure what to do when that limit is reach.

Review Comment:
   page-limit-bytes and/or page-limit-messages. The page-full-policy...
   
   ...when that limit is reach**ed.**



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java:
##########
@@ -60,6 +62,19 @@ public interface PagingStore extends ActiveMQComponent, RefCountMessageListener
 
    AddressFullMessagePolicy getAddressFullMessagePolicy();
 
+   PageFullMessagePolicy getPageFullMessagePolicy();
+
+   Long getPageLimitMessages();
+
+   Long getPageLimitBytes();

Review Comment:
   ditto



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();
+
+      if (pageLimitBytes != null && pageSize > 0) {
+         estimatedMaxPages = pageLimitBytes / pageSize;
+         logger.debug("Address {} should not allow more than {} pages", storeName, estimatedMaxPages);
+      }

Review Comment:
   What if someone explicitly set pageLimitBytes to -1, which is noted as the default and allowed by the validators. This would still look to calculate a [incorrect] value for the max?



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();
+
+      if (pageLimitBytes != null && pageSize > 0) {
+         estimatedMaxPages = pageLimitBytes / pageSize;
+         logger.debug("Address {} should not allow more than {} pages", storeName, estimatedMaxPages);
+      }
    }
 
    @Override
    public String toString() {
       return "PagingStoreImpl(" + this.address + ")";
    }
 
+   @Override
+   public PageFullMessagePolicy getPageFullMessagePolicy() {
+      return pageFullMessagePolicy;
+   }
+
+   @Override
+   public Long getPageLimitMessages() {
+      return pageLimitMessages;
+   }
+
+   @Override
+   public Long getPageLimitBytes() {
+      return pageLimitBytes;
+   }
+
+   @Override
+   public void pageFull(PageSubscription subscription) {
+      this.pageFull = true;
+      try {
+         ActiveMQServerLogger.LOGGER.pageFull(subscription.getQueue().getName(), subscription.getQueue().getAddress(), pageLimitMessages, subscription.getCounter().getValue());
+      } catch (Throwable e) {
+         // I don't think subscription would ever have a null queue. I'm being cautious here for tests
+         logger.warn(e.getMessage(), e);
+      }
+   }
+
+   @Override
+   public boolean isPageFull() {
+      return pageFull;
+   }
+
+   private boolean isBellowPageLimitBytes() {
+      if (estimatedMaxPages != null) {
+         return (numberOfPages <= estimatedMaxPages.longValue());
+      }  else {
+         return true;
+      }
+   }
+
+   private void checkNumberOfPages() {
+      if (!isBellowPageLimitBytes()) {
+         this.pageFull = true;
+         ActiveMQServerLogger.LOGGER.pageFullMaxBytes(storeName, numberOfPages, estimatedMaxPages, pageLimitBytes, pageSize);
+      }
+   }
+
+   @Override
+   public void checkPageLimit(long numberOfMessages) {
+
+
+      boolean pageMessageMessagesClear = true;
+      Long pageLimitMessages = getPageLimitMessages();
+
+      if (pageLimitMessages != null) {
+         if (logger.isDebugEnabled()) { // gate to avoid boxing of msgCount
+            logger.debug("Address {} has {} messages on the larger queue", storeName, numberOfMessages);
+         }
+
+         pageMessageMessagesClear = (numberOfMessages < pageLimitMessages.longValue());
+      }
+
+      boolean pageMessageBytesClear = isBellowPageLimitBytes();
+
+

Review Comment:
   Superfluous newline



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -225,13 +237,100 @@ public void applySetting(final AddressSettings addressSettings) {
       addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();
 
       rejectThreshold = addressSettings.getMaxSizeBytesRejectThreshold();
+
+      pageFullMessagePolicy = addressSettings.getPageFullMessagePolicy();
+
+      pageLimitBytes = addressSettings.getPageLimitBytes();
+
+      pageLimitMessages = addressSettings.getPageLimitMessages();
+
+      if (pageLimitBytes != null && pageSize > 0) {
+         estimatedMaxPages = pageLimitBytes / pageSize;
+         logger.debug("Address {} should not allow more than {} pages", storeName, estimatedMaxPages);
+      }
    }
 
    @Override
    public String toString() {
       return "PagingStoreImpl(" + this.address + ")";
    }
 
+   @Override
+   public PageFullMessagePolicy getPageFullMessagePolicy() {
+      return pageFullMessagePolicy;
+   }
+
+   @Override
+   public Long getPageLimitMessages() {
+      return pageLimitMessages;
+   }
+
+   @Override
+   public Long getPageLimitBytes() {
+      return pageLimitBytes;
+   }
+
+   @Override
+   public void pageFull(PageSubscription subscription) {
+      this.pageFull = true;
+      try {
+         ActiveMQServerLogger.LOGGER.pageFull(subscription.getQueue().getName(), subscription.getQueue().getAddress(), pageLimitMessages, subscription.getCounter().getValue());
+      } catch (Throwable e) {
+         // I don't think subscription would ever have a null queue. I'm being cautious here for tests
+         logger.warn(e.getMessage(), e);
+      }
+   }
+
+   @Override
+   public boolean isPageFull() {
+      return pageFull;
+   }
+
+   private boolean isBellowPageLimitBytes() {
+      if (estimatedMaxPages != null) {
+         return (numberOfPages <= estimatedMaxPages.longValue());
+      }  else {
+         return true;
+      }
+   }
+
+   private void checkNumberOfPages() {
+      if (!isBellowPageLimitBytes()) {
+         this.pageFull = true;
+         ActiveMQServerLogger.LOGGER.pageFullMaxBytes(storeName, numberOfPages, estimatedMaxPages, pageLimitBytes, pageSize);
+      }
+   }
+
+   @Override
+   public void checkPageLimit(long numberOfMessages) {
+
+
+      boolean pageMessageMessagesClear = true;
+      Long pageLimitMessages = getPageLimitMessages();
+
+      if (pageLimitMessages != null) {
+         if (logger.isDebugEnabled()) { // gate to avoid boxing of msgCount

Review Comment:
   msgCount should be numberOfMessages.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] gemmellr commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090918150


##########
artemis-server/src/main/resources/schema/artemis-configuration.xsd:
##########
@@ -4062,6 +4079,20 @@
                </xsd:simpleType>
             </xsd:element>
 
+            <xsd:element name="page-full-policy" maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     After entering page mode, a second limit will be set by page-limit-bytes, page-limit-messages. page-full-policy will configure what to do when that limit is reach.

Review Comment:
   page-limit-bytes _and/or_ page-limit-messages. _The_ page-full-policy...
   
   ...when that limit is reach**ed**.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#issuecomment-1409508147

   all the comments are resolved.. tests are 100%... I'm merging this...
   
   
   if anyone sees anything else wrong I will send a new PR.. (or feel free to send any adjustments yourself of course).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4349: ARTEMIS-3178 Page Limitting (max messages and max bytes)

Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4349:
URL: https://github.com/apache/activemq-artemis/pull/4349#discussion_r1090961491


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java:
##########
@@ -60,6 +62,19 @@ public interface PagingStore extends ActiveMQComponent, RefCountMessageListener
 
    AddressFullMessagePolicy getAddressFullMessagePolicy();
 
+   PageFullMessagePolicy getPageFullMessagePolicy();
+
+   Long getPageLimitMessages();

Review Comment:
   I was going against the -1 usage here. and just keep it as null.
   
   I can edit the default on the XSD to state null



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org