From b2ddfb386b3cd8b4f595a0fe3f77da94807282b1 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Sat, 18 Sep 2010 21:17:32 +0000 Subject: 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 --- .../qpid/server/queue/SimpleQueueEntryList.java | 65 +++++----------------- 1 file changed, 14 insertions(+), 51 deletions(-) (limited to 'java/broker/src/main') 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; -- cgit v1.2.1