activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-4930 - fix regression in MBeanTest - need to page in up to max messages if they are present for a browse
Date Fri, 20 Dec 2013 14:42:08 GMT
Updated Branches:
  refs/heads/trunk c50b6c39b -> 14d24cca3


https://issues.apache.org/jira/browse/AMQ-4930 - fix regression in MBeanTest - need to page
in up to max messages if they are present for a browse


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/14d24cca
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/14d24cca
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/14d24cca

Branch: refs/heads/trunk
Commit: 14d24cca30bbbde9c515004fd72234c7a1fe3039
Parents: c50b6c3
Author: gtully <gary.tully@gmail.com>
Authored: Fri Dec 20 14:39:45 2013 +0000
Committer: gtully <gary.tully@gmail.com>
Committed: Fri Dec 20 14:39:45 2013 +0000

----------------------------------------------------------------------
 .../org/apache/activemq/broker/region/Queue.java | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/14d24cca/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
index 9b32500..52d7282 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
@@ -1150,8 +1150,11 @@ public class Queue extends BaseDestination implements Task, UsageListener
{
     public void doBrowse(List<Message> browseList, int max) {
         final ConnectionContext connectionContext = createConnectionContext();
         try {
-            // allow some page in even if we are full and producers are blocked on pfc
-            pageInMessages(!memoryUsage.isFull(110));
+
+            while (shouldPageInMoreForBrowse(max)) {
+                pageInMessages(!memoryUsage.isFull(110));
+            };
+
             List<MessageReference> toExpire = new ArrayList<MessageReference>();
 
             pagedInPendingDispatchLock.writeLock().lock();
@@ -1198,6 +1201,18 @@ public class Queue extends BaseDestination implements Task, UsageListener
{
         }
     }
 
+    private boolean shouldPageInMoreForBrowse(int max) {
+        pagedInMessagesLock.readLock().lock();
+        try {
+            int alreadyPagedIn = pagedInMessages.size();
+            return  alreadyPagedIn < max
+                    && alreadyPagedIn < getDestinationStatistics().getMessages().getCount()
+                    && !memoryUsage.isFull(110);
+        } finally {
+            pagedInMessagesLock.readLock().unlock();
+        }
+    }
+
     private void addAll(Collection<? extends MessageReference> refs, List<Message>
l, int max,
             List<MessageReference> toExpire) throws Exception {
         for (Iterator<? extends MessageReference> i = refs.iterator(); i.hasNext()
&& l.size() < max;) {


Mime
View raw message