summaryrefslogtreecommitdiff
path: root/java/broker/src/main
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2010-09-18 21:17:32 +0000
committerRobert Gemmell <robbie@apache.org>2010-09-18 21:17:32 +0000
commitb2ddfb386b3cd8b4f595a0fe3f77da94807282b1 (patch)
tree7598dfa7c2eb0af3f3e95ce802f5b967a63f4845 /java/broker/src/main
parentf532031f02b5f9b03ec40cd81a13e2df091a79f0 (diff)
downloadqpid-python-b2ddfb386b3cd8b4f595a0fe3f77da94807282b1.tar.gz
QPID-2704: simplify the implementation of SQEL scavenge() ability and add test.
Incorporates changes for QPID-2597 from 0.5.x-dev branch revisions 943240, 943534, 943576, and 943845. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@998543 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker/src/main')
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java65
1 files changed, 14 insertions, 51 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java b/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
index 334b7f4ea9..b97c2c55c5 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
@@ -45,7 +45,9 @@ public class SimpleQueueEntryList implements QueueEntryList
_nextUpdater =
AtomicReferenceFieldUpdater.newUpdater
(QueueEntryImpl.class, QueueEntryImpl.class, "_next");
- private AtomicLong _deletes = new AtomicLong(0L);
+
+ private AtomicLong _scavenges = new AtomicLong(0L);
+ private final long _scavengeCount = Integer.getInteger("qpid.queue.scavenge_count", 50);
public SimpleQueueEntryList(AMQQueue queue)
@@ -55,71 +57,32 @@ public class SimpleQueueEntryList implements QueueEntryList
_tail = _head;
}
-
-
void advanceHead()
{
- _deletes.incrementAndGet();
- QueueEntryImpl head = _head.nextNode();
- while(head._next != null && head.isDeleted())
- {
+ QueueEntryImpl next = _head.nextNode();
+ QueueEntryImpl newNext = _head.getNext();
- final QueueEntryImpl newhead = head.nextNode();
- if(newhead != null)
+ if (next == newNext)
+ {
+ if (_scavenges.incrementAndGet() > _scavengeCount)
{
- if(_nextUpdater.compareAndSet(_head,head, newhead))
- {
- _deletes.decrementAndGet();
- }
+ _scavenges.set(0L);
+ scavenge();
}
- head = _head.nextNode();
- }
-
- if(_deletes.get() > 1000L)
- {
- _deletes.set(0L);
- scavenge();
}
}
void scavenge()
{
- QueueEntryImpl root = _head;
- QueueEntryImpl next = root.nextNode();
+ QueueEntryImpl next = _head.getNext();
- do
+ while (next != null)
{
-
-
- while(next._next != null && next.isDeleted())
- {
-
- final QueueEntryImpl newhead = next.nextNode();
- if(newhead != null)
- {
- _nextUpdater.compareAndSet(root,next, newhead);
- }
- next = root.nextNode();
- }
- if(next._next != null)
- {
- if(!next.isDeleted())
- {
- root = next;
- next = root.nextNode();
- }
- }
- else
- {
- break;
- }
-
- } while (next != null && next._next != null);
-
+ next = next.getNext();
+ }
}
-
public AMQQueue getQueue()
{
return _queue;