You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ha...@apache.org on 2014/03/13 21:45:13 UTC
[19/21] 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
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/46d3a27e
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/46d3a27e
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/46d3a27e
Branch: refs/heads/activemq-5.9
Commit: 46d3a27ee1be4a0d8f2bd1c604b89d121c3e304d
Parents: dbb12cb
Author: gtully <ga...@gmail.com>
Authored: Fri Dec 20 14:39:45 2013 +0000
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Thu Mar 13 16:33:33 2014 -0400
----------------------------------------------------------------------
.../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/46d3a27e/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;) {