You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/02/08 18:52:07 UTC
svn commit: r1566069 [1/4] - in
/qpid/branches/java-broker-amqp-1-0-management/java:
broker-core/src/main/java/org/apache/qpid/server/exchange/
broker-core/src/main/java/org/apache/qpid/server/message/
broker-core/src/main/java/org/apache/qpid/server/m...
Author: rgodfrey
Date: Sat Feb 8 17:52:05 2014
New Revision: 1566069
URL: http://svn.apache.org/r1566069
Log:
Modify queue classes to use generics
Added:
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntry.java
- copied, changed from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntryList.java
- copied, changed from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java
- copied, changed from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueEntry.java
- copied, changed from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryImpl.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueEntry.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueEntryList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java
- copied, changed from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueTest.java
- copied, changed from r1565024, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java
- copied, changed from r1565124, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java
- copied, changed from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryImplTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java
- copied, changed from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
Removed:
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryImpl.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryImplTest.java
Modified:
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageDestination.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefinedGroupMessageGroupManager.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/MessageGroupManager.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueContext.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntry.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryIterator.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryListFactory.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryVisitor.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryListFactory.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/txn/AutoCommitTransactionTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/txn/LocalTransactionTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java
qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageContentServlet.java
qpid/branches/java-broker-amqp-1-0-management/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
qpid/branches/java-broker-amqp-1-0-management/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java
qpid/branches/java-broker-amqp-1-0-management/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/QueueManagementTest.java
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java Sat Feb 8 17:52:05 2014
@@ -43,6 +43,7 @@ import org.apache.qpid.server.queue.AMQQ
import org.apache.qpid.server.queue.BaseQueue;
import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.DurableConfigurationStoreHelper;
+import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.Action;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -428,10 +429,10 @@ public abstract class AbstractExchange i
return queues;
}
- public final int send(final ServerMessage message,
+ public final <M extends ServerMessage<? extends StorableMessageMetaData>> int send(final M message,
final InstanceProperties instanceProperties,
final ServerTransaction txn,
- final Action<MessageInstance<? extends Consumer>> postEnqueueAction)
+ final Action<? super MessageInstance<?, ? extends Consumer>> postEnqueueAction)
{
List<? extends BaseQueue> queues = route(message, instanceProperties);
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java Sat Feb 8 17:52:05 2014
@@ -46,6 +46,7 @@ import org.apache.qpid.server.queue.AMQQ
import org.apache.qpid.server.queue.BaseQueue;
import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.queue.QueueRegistry;
+import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.Action;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -335,10 +336,10 @@ public class DefaultExchange implements
return _id;
}
- public final int send(final ServerMessage message,
+ public final <M extends ServerMessage<? extends StorableMessageMetaData>> int send(final M message,
final InstanceProperties instanceProperties,
final ServerTransaction txn,
- final Action<MessageInstance<? extends Consumer>> postEnqueueAction)
+ final Action<? super MessageInstance<?, ? extends Consumer>> postEnqueueAction)
{
final AMQQueue q = _virtualHost.getQueue(message.getRoutingKey());
if(q == null)
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageDestination.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageDestination.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageDestination.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageDestination.java Sat Feb 8 17:52:05 2014
@@ -21,6 +21,7 @@
package org.apache.qpid.server.message;
import org.apache.qpid.server.consumer.Consumer;
+import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.Action;
@@ -37,8 +38,8 @@ public interface MessageDestination exte
* @param postEnqueueAction action to perform on the result of every enqueue (may be null)
* @return the number of queues in which the message was enqueued performed
*/
- int send(ServerMessage message,
+ <M extends ServerMessage<? extends StorableMessageMetaData>> int send(M message,
InstanceProperties instanceProperties,
ServerTransaction txn,
- Action<MessageInstance<? extends Consumer>> postEnqueueAction);
+ Action<? super MessageInstance<?,? extends Consumer>> postEnqueueAction);
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java Sat Feb 8 17:52:05 2014
@@ -30,7 +30,7 @@ import org.apache.qpid.server.txn.Server
import org.apache.qpid.server.util.Action;
import org.apache.qpid.server.util.StateChangeListener;
-public interface MessageInstance<C extends Consumer>
+public interface MessageInstance<M extends MessageInstance<M,C>, C extends Consumer>
{
@@ -45,9 +45,9 @@ public interface MessageInstance<C exten
void decrementDeliveryCount();
- void addStateChangeListener(StateChangeListener<MessageInstance<C>, State> listener);
+ void addStateChangeListener(StateChangeListener<? super M,State> listener);
- boolean removeStateChangeListener(StateChangeListener<MessageInstance<C>, State> listener);
+ boolean removeStateChangeListener(StateChangeListener<? super M, State> listener);
boolean acquiredByConsumer();
@@ -71,7 +71,7 @@ public interface MessageInstance<C exten
int getMaximumDeliveryCount();
- int routeToAlternate(Action<MessageInstance<? extends Consumer>> action, ServerTransaction txn);
+ int routeToAlternate(Action<? super MessageInstance<?, ? extends Consumer>> action, ServerTransaction txn);
Filterable asFilterable();
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java Sat Feb 8 17:52:05 2014
@@ -32,17 +32,17 @@ import org.apache.qpid.server.store.Tran
import java.util.Collection;
import java.util.EnumSet;
-public interface MessageSource<C extends Consumer> extends TransactionLogResource, MessageNode
+public interface MessageSource<C extends Consumer, S extends MessageSource<C,S>> extends TransactionLogResource, MessageNode
{
- C addConsumer(ConsumerTarget target, FilterManager filters,
+ <T extends ConsumerTarget> C addConsumer(T target, FilterManager filters,
Class<? extends ServerMessage> messageClass,
String consumerName, EnumSet<Consumer.Option> options) throws AMQException;
Collection<C> getConsumers();
- void addConsumerRegistrationListener(ConsumerRegistrationListener listener);
+ void addConsumerRegistrationListener(ConsumerRegistrationListener<S> listener);
- void removeConsumerRegistrationListener(ConsumerRegistrationListener listener);
+ void removeConsumerRegistrationListener(ConsumerRegistrationListener<S> listener);
AuthorizationHolder getAuthorizationHolder();
@@ -54,10 +54,10 @@ public interface MessageSource<C extends
boolean isExclusive();
- interface ConsumerRegistrationListener
+ interface ConsumerRegistrationListener<Q extends MessageSource<? extends Consumer,Q>>
{
- void consumerAdded(AMQQueue queue, Consumer consumer);
- void consumerRemoved(AMQQueue queue, Consumer consumer);
+ void consumerAdded(Q source, Consumer consumer);
+ void consumerRemoved(Q queue, Consumer consumer);
}
/**
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java Sat Feb 8 17:52:05 2014
@@ -33,6 +33,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.message.MessageSource;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectFinder;
import org.apache.qpid.server.model.Exchange;
@@ -49,8 +50,9 @@ import org.apache.qpid.server.store.Dura
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.util.MapValueConverter;
-final class QueueAdapter extends AbstractAdapter implements Queue,
- AMQQueue.ConsumerRegistrationListener, AMQQueue.NotificationListener
+final class QueueAdapter<Q extends AMQQueue<?,Q,?>> extends AbstractAdapter implements Queue,
+ MessageSource.ConsumerRegistrationListener<Q>,
+ AMQQueue.NotificationListener
{
@SuppressWarnings("serial")
static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{
@@ -66,10 +68,11 @@ final class QueueAdapter extends Abstrac
put(DESCRIPTION, String.class);
}});
- private final AMQQueue _queue;
+ private final AMQQueue<?,Q,?> _queue;
+
private final Map<Binding, BindingAdapter> _bindingAdapters =
new HashMap<Binding, BindingAdapter>();
- private Map<Consumer, ConsumerAdapter> _consumerAdapters =
+ private final Map<Consumer, ConsumerAdapter> _consumerAdapters =
new HashMap<Consumer, ConsumerAdapter>();
@@ -77,7 +80,7 @@ final class QueueAdapter extends Abstrac
private QueueStatisticsAdapter _statistics;
private QueueNotificationListener _queueNotificationListener;
- public QueueAdapter(final VirtualHostAdapter virtualHostAdapter, final AMQQueue queue)
+ public QueueAdapter(final VirtualHostAdapter virtualHostAdapter, final AMQQueue<?,Q,?> queue)
{
super(queue.getId(), virtualHostAdapter.getTaskExecutor());
_vhost = virtualHostAdapter;
@@ -124,11 +127,10 @@ final class QueueAdapter extends Abstrac
private void populateConsumers()
{
- Collection<Consumer> actualConsumers = _queue.getConsumers();
+ Collection<? extends Consumer> actualConsumers = _queue.getConsumers();
synchronized (_consumerAdapters)
{
- Iterator<Consumer> iter = _consumerAdapters.keySet().iterator();
for(Consumer consumer : actualConsumers)
{
if(!_consumerAdapters.containsKey(consumer))
@@ -396,9 +398,10 @@ final class QueueAdapter extends Abstrac
}
else if(LVQ_KEY.equals(name))
{
- if(_queue instanceof ConflationQueue)
+ AMQQueue queue = _queue;
+ if(queue instanceof ConflationQueue)
{
- return ((ConflationQueue)_queue).getConflationKey();
+ return ((ConflationQueue)queue).getConflationKey();
}
}
else if(MAXIMUM_DELIVERY_ATTEMPTS.equals(name))
@@ -427,22 +430,24 @@ final class QueueAdapter extends Abstrac
}
else if(SORT_KEY.equals(name))
{
- if(_queue instanceof SortedQueue)
+ AMQQueue queue = _queue;
+ if(queue instanceof SortedQueue)
{
- return ((SortedQueue)_queue).getSortedPropertyName();
+ return ((SortedQueue)queue).getSortedPropertyName();
}
}
else if(TYPE.equals(name))
{
- if(_queue instanceof SortedQueue)
+ AMQQueue queue = _queue;
+ if(queue instanceof SortedQueue)
{
return "sorted";
}
- if(_queue instanceof ConflationQueue)
+ if(queue instanceof ConflationQueue)
{
return "lvq";
}
- if(_queue instanceof AMQPriorityQueue)
+ if(queue instanceof PriorityQueue)
{
return "priority";
}
@@ -486,9 +491,10 @@ final class QueueAdapter extends Abstrac
}
else if(PRIORITIES.equals(name))
{
- if(_queue instanceof AMQPriorityQueue)
+ AMQQueue queue = _queue;
+ if(queue instanceof PriorityQueue)
{
- return ((AMQPriorityQueue)_queue).getPriorities();
+ return ((PriorityQueue)queue).getPriorities();
}
}
return super.getAttribute(name);
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java Sat Feb 8 17:52:05 2014
@@ -27,12 +27,11 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.SimpleAMQQueue;
/**
* Session model interface.
* Extends {@link Comparable} to allow objects to be inserted into a {@link ConcurrentSkipListSet}
- * when monitoring the blocking and blocking of queues/sessions in {@link SimpleAMQQueue}.
+ * when monitoring the blocking and blocking of queues/sessions in {@link AMQQueue}.
*/
public interface AMQSessionModel extends Comparable<AMQSessionModel>
{
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java Sat Feb 8 17:52:05 2014
@@ -37,8 +37,8 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
-public interface AMQQueue<C extends Consumer> extends Comparable<AMQQueue<C>>, ExchangeReferrer, BaseQueue,
- MessageSource<C>, CapacityChecker, MessageDestination
+public interface AMQQueue<E extends QueueEntry<E,Q,C>, Q extends AMQQueue<E,Q,C>, C extends Consumer>
+ extends Comparable<Q>, ExchangeReferrer, BaseQueue<C>, MessageSource<C,Q>, CapacityChecker, MessageDestination
{
public interface NotificationListener
@@ -87,41 +87,35 @@ public interface AMQQueue<C extends Cons
int getMessageCount();
- int getUndeliveredMessageCount();
-
long getQueueDepth();
- long getReceivedMessageCount();
-
long getOldestMessageArrivalTime();
boolean isDeleted();
int delete() throws AMQException;
- void requeue(QueueEntry entry);
+ void requeue(E entry);
- void dequeue(QueueEntry entry, Consumer sub);
+ void dequeue(E entry);
- void decrementUnackedMsgCount(QueueEntry queueEntry);
+ void decrementUnackedMsgCount(E queueEntry);
- boolean resend(final QueueEntry entry, final Consumer consumer) throws AMQException;
+ boolean resend(final E entry, final C consumer) throws AMQException;
void addQueueDeleteTask(Action<AMQQueue> task);
void removeQueueDeleteTask(Action<AMQQueue> task);
- List<QueueEntry> getMessagesOnTheQueue();
-
- List<QueueEntry> getMessagesOnTheQueue(long fromMessageId, long toMessageId);
+ List<E> getMessagesOnTheQueue();
List<Long> getMessagesOnTheQueue(int num);
List<Long> getMessagesOnTheQueue(int num, int offset);
- QueueEntry getMessageOnTheQueue(long messageId);
+ E getMessageOnTheQueue(long messageId);
/**
* Returns a list of QueEntries from a given range of queue positions, eg messages 5 to 10 on the queue.
@@ -132,9 +126,9 @@ public interface AMQQueue<C extends Cons
* @param toPosition
* @return
*/
- public List<QueueEntry> getMessagesRangeOnTheQueue(final long fromPosition, final long toPosition);
+ public List<E> getMessagesRangeOnTheQueue(final long fromPosition, final long toPosition);
- void visit(QueueEntryVisitor visitor);
+ void visit(QueueEntryVisitor<E> visitor);
long getMaximumMessageSize();
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java Sat Feb 8 17:52:05 2014
@@ -288,11 +288,11 @@ public class AMQQueueFactory implements
}
else if(priorities > 1)
{
- q = new AMQPriorityQueue(id, queueName, durable, owner, autoDelete, exclusive, _virtualHost, arguments, priorities);
+ q = new PriorityQueue(id, queueName, durable, owner, autoDelete, exclusive, _virtualHost, arguments, priorities);
}
else
{
- q = new SimpleAMQQueue(id, queueName, durable, owner, autoDelete, exclusive, _virtualHost, arguments);
+ q = new StandardQueue(id, queueName, durable, owner, autoDelete, exclusive, _virtualHost, arguments);
}
q.setDeleteOnNoConsumers(deleteOnNoConsumer);
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java Sat Feb 8 17:52:05 2014
@@ -28,7 +28,7 @@ import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
-public class AssignedConsumerMessageGroupManager implements MessageGroupManager
+public class AssignedConsumerMessageGroupManager<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends SimpleQueueEntryList<E,Q,L>> implements MessageGroupManager<E,Q,L>
{
private static final Logger _logger = LoggerFactory.getLogger(AssignedConsumerMessageGroupManager.class);
@@ -53,25 +53,18 @@ public class AssignedConsumerMessageGrou
return val;
}
- public QueueConsumer getAssignedConsumer(final QueueEntry entry)
+ public QueueConsumer getAssignedConsumer(final E entry)
{
Object groupVal = entry.getMessage().getMessageHeader().getHeader(_groupId);
return groupVal == null ? null : _groupMap.get(groupVal.hashCode() & _groupMask);
}
- public boolean acceptMessage(QueueConsumer sub, QueueEntry entry)
+ public boolean acceptMessage(QueueConsumer<?,E,Q,L> sub, E entry)
{
- if(assignMessage(sub, entry))
- {
- return entry.acquire(sub);
- }
- else
- {
- return false;
- }
+ return assignMessage(sub, entry) && entry.acquire(sub);
}
- private boolean assignMessage(QueueConsumer sub, QueueEntry entry)
+ private boolean assignMessage(QueueConsumer sub, E entry)
{
Object groupVal = entry.getMessage().getMessageHeader().getHeader(_groupId);
if(groupVal == null)
@@ -105,16 +98,16 @@ public class AssignedConsumerMessageGrou
}
}
- public QueueEntry findEarliestAssignedAvailableEntry(QueueConsumer sub)
+ public E findEarliestAssignedAvailableEntry(QueueConsumer sub)
{
EntryFinder visitor = new EntryFinder(sub);
sub.getQueue().visit(visitor);
return visitor.getEntry();
}
- private class EntryFinder implements QueueEntryVisitor
+ private class EntryFinder implements QueueEntryVisitor<E>
{
- private QueueEntry _entry;
+ private E _entry;
private QueueConsumer _sub;
public EntryFinder(final QueueConsumer sub)
@@ -122,7 +115,7 @@ public class AssignedConsumerMessageGrou
_sub = sub;
}
- public boolean visit(final QueueEntry entry)
+ public boolean visit(final E entry)
{
if(!entry.isAvailable())
{
@@ -148,7 +141,7 @@ public class AssignedConsumerMessageGrou
}
}
- public QueueEntry getEntry()
+ public E getEntry()
{
return _entry;
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java Sat Feb 8 17:52:05 2014
@@ -28,9 +28,9 @@ import org.apache.qpid.server.message.Se
import org.apache.qpid.server.store.TransactionLogResource;
import org.apache.qpid.server.util.Action;
-public interface BaseQueue extends TransactionLogResource
+public interface BaseQueue<C extends Consumer> extends TransactionLogResource
{
- void enqueue(ServerMessage message, Action<MessageInstance<? extends Consumer>> action) throws AMQException;
+ void enqueue(ServerMessage message, Action<? super MessageInstance<?,C>> action) throws AMQException;
boolean isDurable();
boolean isDeleted();
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java Sat Feb 8 17:52:05 2014
@@ -26,7 +26,7 @@ import java.util.UUID;
import org.apache.qpid.server.virtualhost.VirtualHost;
-public class ConflationQueue extends SimpleAMQQueue
+public class ConflationQueue extends SimpleAMQQueue<ConflationQueueList.ConflationQueueEntry, ConflationQueue, ConflationQueueList>
{
protected ConflationQueue(UUID id,
String name,
@@ -42,7 +42,7 @@ public class ConflationQueue extends Sim
public String getConflationKey()
{
- return ((ConflationQueueList) getEntries()).getConflationKey();
+ return getEntries().getConflationKey();
}
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java Sat Feb 8 17:52:05 2014
@@ -32,23 +32,38 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
-public class ConflationQueueList extends SimpleQueueEntryList
+public class ConflationQueueList extends OrderedQueueEntryList<ConflationQueueList.ConflationQueueEntry, ConflationQueue, ConflationQueueList>
{
private static final Logger LOGGER = LoggerFactory.getLogger(ConflationQueueList.class);
+ private static final HeadCreator<ConflationQueueList.ConflationQueueEntry, ConflationQueue, ConflationQueueList> HEAD_CREATOR = new HeadCreator<ConflationQueueList.ConflationQueueEntry, ConflationQueue, ConflationQueueList>()
+ {
+
+ @Override
+ public ConflationQueueEntry createHead(final ConflationQueueList list)
+ {
+ return list.createHead();
+ }
+ };
+
private final String _conflationKey;
- private final ConcurrentHashMap<Object, AtomicReference<QueueEntry>> _latestValuesMap =
- new ConcurrentHashMap<Object, AtomicReference<QueueEntry>>();
+ private final ConcurrentHashMap<Object, AtomicReference<ConflationQueueEntry>> _latestValuesMap =
+ new ConcurrentHashMap<Object, AtomicReference<ConflationQueueEntry>>();
- private final QueueEntry _deleteInProgress = new SimpleQueueEntryImpl(this);
- private final QueueEntry _newerEntryAlreadyBeenAndGone = new SimpleQueueEntryImpl(this);
+ private final ConflationQueueEntry _deleteInProgress = new ConflationQueueEntry(this);
+ private final ConflationQueueEntry _newerEntryAlreadyBeenAndGone = new ConflationQueueEntry(this);
- public ConflationQueueList(AMQQueue<QueueConsumer> queue, String conflationKey)
+ public ConflationQueueList(ConflationQueue queue, String conflationKey)
{
- super(queue);
+ super(queue, HEAD_CREATOR);
_conflationKey = conflationKey;
}
+ private ConflationQueueEntry createHead()
+ {
+ return new ConflationQueueEntry(this);
+ }
+
public String getConflationKey()
{
return _conflationKey;
@@ -66,7 +81,7 @@ public class ConflationQueueList extends
@Override
public ConflationQueueEntry add(final ServerMessage message)
{
- final ConflationQueueEntry addedEntry = (ConflationQueueEntry) (super.add(message));
+ final ConflationQueueEntry addedEntry = super.add(message);
final Object keyValue = message.getMessageHeader().getHeader(_conflationKey);
if (keyValue != null)
@@ -76,14 +91,14 @@ public class ConflationQueueList extends
LOGGER.debug("Adding entry " + addedEntry + " for message " + message.getMessageNumber() + " with conflation key " + keyValue);
}
- final AtomicReference<QueueEntry> referenceToEntry = new AtomicReference<QueueEntry>(addedEntry);
- AtomicReference<QueueEntry> entryReferenceFromMap = null;
- QueueEntry entryFromMap;
+ final AtomicReference<ConflationQueueEntry> referenceToEntry = new AtomicReference<ConflationQueueEntry>(addedEntry);
+ AtomicReference<ConflationQueueEntry> entryReferenceFromMap;
+ ConflationQueueEntry entryFromMap;
// Iterate until we have got a valid atomic reference object and either the referent is newer than the current
// entry, or the current entry has replaced it in the reference. Note that the _deletedEntryPlaceholder is a special value
// indicating that the reference object is no longer valid (it is being removed from the map).
- boolean keepTryingToUpdateEntryReference = true;
+ boolean keepTryingToUpdateEntryReference;
do
{
do
@@ -139,16 +154,16 @@ public class ConflationQueueList extends
* adds and removes during execution of this method.</li>
* </ul>
*/
- private AtomicReference<QueueEntry> getOrPutIfAbsent(final Object key, final AtomicReference<QueueEntry> referenceToAddedValue)
+ private AtomicReference<ConflationQueueEntry> getOrPutIfAbsent(final Object key, final AtomicReference<ConflationQueueEntry> referenceToAddedValue)
{
- AtomicReference<QueueEntry> latestValueReference = _latestValuesMap.putIfAbsent(key, referenceToAddedValue);
+ AtomicReference<ConflationQueueEntry> latestValueReference = _latestValuesMap.putIfAbsent(key, referenceToAddedValue);
if(latestValueReference == null)
{
latestValueReference = _latestValuesMap.get(key);
if(latestValueReference == null)
{
- return new AtomicReference<QueueEntry>(_newerEntryAlreadyBeenAndGone);
+ return new AtomicReference<ConflationQueueEntry>(_newerEntryAlreadyBeenAndGone);
}
}
return latestValueReference;
@@ -177,12 +192,17 @@ public class ConflationQueueList extends
}
}
- private final class ConflationQueueEntry extends SimpleQueueEntryImpl
+ final class ConflationQueueEntry extends OrderedQueueEntry<ConflationQueueEntry, ConflationQueue, ConflationQueueList>
{
- private AtomicReference<QueueEntry> _latestValueReference;
+ private AtomicReference<ConflationQueueEntry> _latestValueReference;
+
+ private ConflationQueueEntry(final ConflationQueueList queueEntryList)
+ {
+ super(queueEntryList);
+ }
- public ConflationQueueEntry(SimpleQueueEntryList queueEntryList, ServerMessage message)
+ public ConflationQueueEntry(ConflationQueueList queueEntryList, ServerMessage message)
{
super(queueEntryList, message);
}
@@ -206,7 +226,7 @@ public class ConflationQueueList extends
}
- public void setLatestValueReference(final AtomicReference<QueueEntry> latestValueReference)
+ public void setLatestValueReference(final AtomicReference<ConflationQueueEntry> latestValueReference)
{
_latestValueReference = latestValueReference;
}
@@ -227,12 +247,12 @@ public class ConflationQueueList extends
/**
* Exposed purposes of unit test only.
*/
- Map<Object, AtomicReference<QueueEntry>> getLatestValuesMap()
+ Map<Object, AtomicReference<ConflationQueueEntry>> getLatestValuesMap()
{
return Collections.unmodifiableMap(_latestValuesMap);
}
- static class Factory implements QueueEntryListFactory
+ static class Factory implements QueueEntryListFactory<ConflationQueueList.ConflationQueueEntry, ConflationQueue, ConflationQueueList>
{
private final String _conflationKey;
@@ -241,7 +261,8 @@ public class ConflationQueueList extends
_conflationKey = conflationKey;
}
- public ConflationQueueList createQueueEntryList(AMQQueue queue)
+ @Override
+ public ConflationQueueList createQueueEntryList(final ConflationQueue queue)
{
return new ConflationQueueList(queue, _conflationKey);
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefinedGroupMessageGroupManager.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefinedGroupMessageGroupManager.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefinedGroupMessageGroupManager.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefinedGroupMessageGroupManager.java Sat Feb 8 17:52:05 2014
@@ -32,22 +32,22 @@ import org.apache.qpid.server.message.Se
import java.util.HashMap;
import java.util.Map;
-public class DefinedGroupMessageGroupManager implements MessageGroupManager
+public class DefinedGroupMessageGroupManager<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends SimpleQueueEntryList<E,Q,L>> implements MessageGroupManager<E,Q,L>
{
private static final Logger _logger = LoggerFactory.getLogger(DefinedGroupMessageGroupManager.class);
private final String _groupId;
private final String _defaultGroup;
private final Map<Object, Group> _groupMap = new HashMap<Object, Group>();
- private final ConsumerResetHelper _resetHelper;
+ private final ConsumerResetHelper<E,Q,L> _resetHelper;
private final class Group
{
private final Object _group;
- private QueueConsumer _consumer;
+ private QueueConsumer<?,E,Q,L> _consumer;
private int _activeCount;
- private Group(final Object key, final QueueConsumer consumer)
+ private Group(final Object key, final QueueConsumer<?,E,Q,L> consumer)
{
_group = key;
_consumer = consumer;
@@ -104,7 +104,7 @@ public class DefinedGroupMessageGroupMan
return !(_consumer == null || (_activeCount == 0 && _consumer.isClosed()));
}
- public QueueConsumer getConsumer()
+ public QueueConsumer<?,E,Q,L> getConsumer()
{
return _consumer;
}
@@ -120,14 +120,14 @@ public class DefinedGroupMessageGroupMan
}
}
- public DefinedGroupMessageGroupManager(final String groupId, String defaultGroup, ConsumerResetHelper resetHelper)
+ public DefinedGroupMessageGroupManager(final String groupId, String defaultGroup, ConsumerResetHelper<E,Q,L> resetHelper)
{
_groupId = groupId;
_defaultGroup = defaultGroup;
_resetHelper = resetHelper;
}
- public synchronized QueueConsumer getAssignedConsumer(final QueueEntry entry)
+ public synchronized QueueConsumer<?,E,Q,L> getAssignedConsumer(final E entry)
{
Object groupId = getKey(entry);
@@ -135,19 +135,12 @@ public class DefinedGroupMessageGroupMan
return group == null || !group.isValid() ? null : group.getConsumer();
}
- public synchronized boolean acceptMessage(final QueueConsumer sub, final QueueEntry entry)
+ public synchronized boolean acceptMessage(final QueueConsumer<?,E,Q,L> sub, final E entry)
{
- if(assignMessage(sub, entry))
- {
- return entry.acquire(sub);
- }
- else
- {
- return false;
- }
+ return assignMessage(sub, entry) && entry.acquire(sub);
}
- private boolean assignMessage(final QueueConsumer sub, final QueueEntry entry)
+ private boolean assignMessage(final QueueConsumer<?,E,Q,L> sub, final E entry)
{
Object groupId = getKey(entry);
Group group = _groupMap.get(groupId);
@@ -171,7 +164,7 @@ public class DefinedGroupMessageGroupMan
if(assignedSub == sub)
{
- entry.addStateChangeListener(new GroupStateChangeListener(group, entry));
+ entry.addStateChangeListener(new GroupStateChangeListener(group));
return true;
}
else
@@ -180,16 +173,16 @@ public class DefinedGroupMessageGroupMan
}
}
- public synchronized QueueEntry findEarliestAssignedAvailableEntry(final QueueConsumer sub)
+ public synchronized E findEarliestAssignedAvailableEntry(final QueueConsumer<?,E,Q,L> sub)
{
EntryFinder visitor = new EntryFinder(sub);
sub.getQueue().visit(visitor);
return visitor.getEntry();
}
- private class EntryFinder implements QueueEntryVisitor
+ private class EntryFinder implements QueueEntryVisitor<E>
{
- private QueueEntry _entry;
+ private E _entry;
private QueueConsumer _sub;
public EntryFinder(final QueueConsumer sub)
@@ -197,7 +190,7 @@ public class DefinedGroupMessageGroupMan
_sub = sub;
}
- public boolean visit(final QueueEntry entry)
+ public boolean visit(final E entry)
{
if(!entry.isAvailable())
{
@@ -218,7 +211,7 @@ public class DefinedGroupMessageGroupMan
}
}
- public QueueEntry getEntry()
+ public E getEntry()
{
return _entry;
}
@@ -229,7 +222,7 @@ public class DefinedGroupMessageGroupMan
{
}
- private Object getKey(QueueEntry entry)
+ private Object getKey(E entry)
{
ServerMessage message = entry.getMessage();
AMQMessageHeader messageHeader = message == null ? null : message.getMessageHeader();
@@ -241,17 +234,16 @@ public class DefinedGroupMessageGroupMan
return groupVal;
}
- private class GroupStateChangeListener implements StateChangeListener<MessageInstance<QueueConsumer>, QueueEntry.State>
+ private class GroupStateChangeListener implements StateChangeListener<MessageInstance<?, ? extends QueueConsumer>, QueueEntry.State>
{
private final Group _group;
- public GroupStateChangeListener(final Group group,
- final MessageInstance<QueueConsumer> entry)
+ public GroupStateChangeListener(final Group group)
{
_group = group;
}
- public void stateChanged(final MessageInstance<QueueConsumer> entry,
+ public void stateChanged(final MessageInstance<?, ? extends QueueConsumer> entry,
final MessageInstance.State oldState,
final MessageInstance.State newState)
{
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/MessageGroupManager.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/MessageGroupManager.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/MessageGroupManager.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/MessageGroupManager.java Sat Feb 8 17:52:05 2014
@@ -20,20 +20,20 @@
*/
package org.apache.qpid.server.queue;
-public interface MessageGroupManager
+public interface MessageGroupManager<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends SimpleQueueEntryList<E,Q,L>>
{
- public interface ConsumerResetHelper
+ public interface ConsumerResetHelper<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends SimpleQueueEntryList<E,Q,L>>
{
- public void resetSubPointersForGroups(QueueConsumer consumer, boolean clearAssignments);
+ public void resetSubPointersForGroups(QueueConsumer<?,E,Q,L> consumer, boolean clearAssignments);
- boolean isEntryAheadOfConsumer(QueueEntry entry, QueueConsumer sub);
+ boolean isEntryAheadOfConsumer(E entry, QueueConsumer<?,E,Q,L> sub);
}
- QueueConsumer getAssignedConsumer(QueueEntry entry);
+ QueueConsumer getAssignedConsumer(E entry);
- boolean acceptMessage(QueueConsumer sub, QueueEntry entry);
+ boolean acceptMessage(QueueConsumer<?,E,Q,L> sub, E entry);
- QueueEntry findEarliestAssignedAvailableEntry(QueueConsumer sub);
+ E findEarliestAssignedAvailableEntry(QueueConsumer<?,E,Q,L> sub);
void clearAssignments(QueueConsumer sub);
}
Copied: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntry.java (from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntry.java?p2=qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntry.java&p1=qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java&r1=1565732&r2=1566069&rev=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntry.java Sat Feb 8 17:52:05 2014
@@ -24,46 +24,46 @@ import org.apache.qpid.server.message.Se
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-public class SimpleQueueEntryImpl extends QueueEntryImpl
+public abstract class OrderedQueueEntry<E extends OrderedQueueEntry<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends OrderedQueueEntryList<E,Q,L>> extends QueueEntryImpl<E,Q,L>
{
- static final AtomicReferenceFieldUpdater<SimpleQueueEntryImpl, SimpleQueueEntryImpl>
+ static final AtomicReferenceFieldUpdater<OrderedQueueEntry, OrderedQueueEntry>
_nextUpdater =
AtomicReferenceFieldUpdater.newUpdater
- (SimpleQueueEntryImpl.class, SimpleQueueEntryImpl.class, "_next");
+ (OrderedQueueEntry.class, OrderedQueueEntry.class, "_next");
- private volatile SimpleQueueEntryImpl _next;
+ private volatile E _next;
- public SimpleQueueEntryImpl(SimpleQueueEntryList queueEntryList)
+ public OrderedQueueEntry(L queueEntryList)
{
super(queueEntryList);
}
- public SimpleQueueEntryImpl(SimpleQueueEntryList queueEntryList, ServerMessage message, final long entryId)
+ public OrderedQueueEntry(L queueEntryList, ServerMessage message, final long entryId)
{
super(queueEntryList, message, entryId);
}
- public SimpleQueueEntryImpl(SimpleQueueEntryList queueEntryList, ServerMessage message)
+ public OrderedQueueEntry(L queueEntryList, ServerMessage message)
{
super(queueEntryList, message);
}
- public SimpleQueueEntryImpl getNextNode()
+ public E getNextNode()
{
return _next;
}
- public SimpleQueueEntryImpl getNextValidEntry()
+ public E getNextValidEntry()
{
- SimpleQueueEntryImpl next = getNextNode();
+ E next = getNextNode();
while(next != null && next.isDeleted())
{
- final SimpleQueueEntryImpl newNext = next.getNextNode();
+ final E newNext = next.getNextNode();
if(newNext != null)
{
- SimpleQueueEntryList._nextUpdater.compareAndSet(this,next, newNext);
+ OrderedQueueEntryList._nextUpdater.compareAndSet(this,next, newNext);
next = getNextNode();
}
else
Copied: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntryList.java (from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntryList.java?p2=qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntryList.java&p1=qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java&r1=1565732&r2=1566069&rev=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OrderedQueueEntryList.java Sat Feb 8 17:52:05 2014
@@ -26,40 +26,40 @@ import java.util.concurrent.atomic.Atomi
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-public class SimpleQueueEntryList implements QueueEntryList<SimpleQueueEntryImpl>
+public abstract class OrderedQueueEntryList<E extends OrderedQueueEntry<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends OrderedQueueEntryList<E,Q,L>> implements SimpleQueueEntryList<E,Q,L>
{
- private final SimpleQueueEntryImpl _head;
+ private final E _head;
- private volatile SimpleQueueEntryImpl _tail;
+ private volatile E _tail;
- static final AtomicReferenceFieldUpdater<SimpleQueueEntryList, SimpleQueueEntryImpl>
+ static final AtomicReferenceFieldUpdater<OrderedQueueEntryList, OrderedQueueEntry>
_tailUpdater =
AtomicReferenceFieldUpdater.newUpdater
- (SimpleQueueEntryList.class, SimpleQueueEntryImpl.class, "_tail");
+ (OrderedQueueEntryList.class, OrderedQueueEntry.class, "_tail");
- private final AMQQueue<QueueConsumer> _queue;
+ private final Q _queue;
- static final AtomicReferenceFieldUpdater<SimpleQueueEntryImpl, SimpleQueueEntryImpl>
- _nextUpdater = SimpleQueueEntryImpl._nextUpdater;
+ static final AtomicReferenceFieldUpdater<OrderedQueueEntry, OrderedQueueEntry>
+ _nextUpdater = OrderedQueueEntry._nextUpdater;
private AtomicLong _scavenges = new AtomicLong(0L);
private final long _scavengeCount = Integer.getInteger("qpid.queue.scavenge_count", 50);
- private final AtomicReference<SimpleQueueEntryImpl> _unscavengedHWM = new AtomicReference<SimpleQueueEntryImpl>();
+ private final AtomicReference<E> _unscavengedHWM = new AtomicReference<E>();
- public SimpleQueueEntryList(AMQQueue<QueueConsumer> queue)
+ public OrderedQueueEntryList(Q queue, HeadCreator<E,Q,L> headCreator)
{
_queue = queue;
- _head = new SimpleQueueEntryImpl(this);
+ _head = headCreator.createHead((L)this);
_tail = _head;
}
void scavenge()
{
- SimpleQueueEntryImpl hwm = _unscavengedHWM.getAndSet(null);
- SimpleQueueEntryImpl next = _head.getNextValidEntry();
+ E hwm = _unscavengedHWM.getAndSet(null);
+ E next = _head.getNextValidEntry();
if(hwm != null)
{
@@ -71,19 +71,19 @@ public class SimpleQueueEntryList implem
}
- public AMQQueue<QueueConsumer> getQueue()
+ public Q getQueue()
{
return _queue;
}
- public SimpleQueueEntryImpl add(ServerMessage message)
+ public E add(ServerMessage message)
{
- SimpleQueueEntryImpl node = createQueueEntry(message);
+ E node = createQueueEntry(message);
for (;;)
{
- SimpleQueueEntryImpl tail = _tail;
- SimpleQueueEntryImpl next = tail.getNextNode();
+ OrderedQueueEntry tail = _tail;
+ OrderedQueueEntry next = tail.getNextNode();
if (tail == _tail)
{
if (next == null)
@@ -104,21 +104,23 @@ public class SimpleQueueEntryList implem
}
}
- protected SimpleQueueEntryImpl createQueueEntry(ServerMessage<?> message)
+ abstract protected E createQueueEntry(ServerMessage<?> message);
+
+ public E next(E node)
{
- return new SimpleQueueEntryImpl(this, message);
+ return node.getNextValidEntry();
}
- public SimpleQueueEntryImpl next(SimpleQueueEntryImpl node)
+ public static interface HeadCreator<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends SimpleQueueEntryList<E,Q,L>>
{
- return node.getNextValidEntry();
+ E createHead(L list);
}
- public static class QueueEntryIteratorImpl implements QueueEntryIterator<SimpleQueueEntryImpl>
+ public static class QueueEntryIteratorImpl<E extends OrderedQueueEntry<E,Q,L>, Q extends SimpleAMQQueue<E,Q,L>, L extends OrderedQueueEntryList<E,Q,L>> implements QueueEntryIterator<E,Q,L,QueueConsumer<?,E,Q,L>>
{
- private SimpleQueueEntryImpl _lastNode;
+ private E _lastNode;
- QueueEntryIteratorImpl(SimpleQueueEntryImpl startNode)
+ QueueEntryIteratorImpl(E startNode)
{
_lastNode = startNode;
}
@@ -128,14 +130,14 @@ public class SimpleQueueEntryList implem
return _lastNode.getNextValidEntry() == null;
}
- public SimpleQueueEntryImpl getNode()
+ public E getNode()
{
return _lastNode;
}
public boolean advance()
{
- SimpleQueueEntryImpl nextValidNode = _lastNode.getNextValidEntry();
+ E nextValidNode = _lastNode.getNextValidEntry();
if(nextValidNode != null)
{
@@ -146,26 +148,26 @@ public class SimpleQueueEntryList implem
}
}
- public QueueEntryIteratorImpl iterator()
+ public QueueEntryIterator<E,Q,L,QueueConsumer<?,E,Q,L>> iterator()
{
- return new QueueEntryIteratorImpl(_head);
+ return new QueueEntryIteratorImpl<E,Q,L>(_head);
}
- public SimpleQueueEntryImpl getHead()
+ public E getHead()
{
return _head;
}
- public void entryDeleted(SimpleQueueEntryImpl queueEntry)
+ public void entryDeleted(E queueEntry)
{
- SimpleQueueEntryImpl next = _head.getNextNode();
- SimpleQueueEntryImpl newNext = _head.getNextValidEntry();
+ E next = _head.getNextNode();
+ E newNext = _head.getNextValidEntry();
// the head of the queue has not been deleted, hence the deletion must have been mid queue.
if (next == newNext)
{
- SimpleQueueEntryImpl unscavengedHWM = _unscavengedHWM.get();
+ E unscavengedHWM = _unscavengedHWM.get();
while(unscavengedHWM == null || unscavengedHWM.compareTo(queueEntry)<0)
{
_unscavengedHWM.compareAndSet(unscavengedHWM, queueEntry);
@@ -179,7 +181,7 @@ public class SimpleQueueEntryList implem
}
else
{
- SimpleQueueEntryImpl unscavengedHWM = _unscavengedHWM.get();
+ E unscavengedHWM = _unscavengedHWM.get();
if(unscavengedHWM != null && (next == null || unscavengedHWM.compareTo(next) < 0))
{
_unscavengedHWM.compareAndSet(unscavengedHWM, null);
@@ -192,14 +194,5 @@ public class SimpleQueueEntryList implem
return 0;
}
- static class Factory implements QueueEntryListFactory
- {
-
- public SimpleQueueEntryList createQueueEntryList(AMQQueue queue)
- {
- return new SimpleQueueEntryList(queue);
- }
- }
-
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java Sat Feb 8 17:52:05 2014
@@ -25,30 +25,30 @@ import org.apache.qpid.server.virtualhos
import java.util.Map;
import java.util.UUID;
-public abstract class OutOfOrderQueue extends SimpleAMQQueue
+public abstract class OutOfOrderQueue<E extends QueueEntryImpl<E,Q,L>, Q extends OutOfOrderQueue<E,Q,L>, L extends SimpleQueueEntryList<E,Q,L>> extends SimpleAMQQueue<E,Q,L>
{
protected OutOfOrderQueue(UUID id, String name, boolean durable,
String owner, boolean autoDelete, boolean exclusive,
- VirtualHost virtualHost, QueueEntryListFactory entryListFactory, Map<String, Object> arguments)
+ VirtualHost virtualHost, QueueEntryListFactory<E,Q,L> entryListFactory, Map<String, Object> arguments)
{
super(id, name, durable, owner, autoDelete, exclusive, virtualHost, entryListFactory, arguments);
}
@Override
- protected void checkConsumersNotAheadOfDelivery(final QueueEntry entry)
+ protected void checkConsumersNotAheadOfDelivery(final E entry)
{
// check that all consumers are not in advance of the entry
- QueueConsumerList.ConsumerNodeIterator subIter = getConsumerList().iterator();
+ QueueConsumerList.ConsumerNodeIterator<E,Q,L> subIter = getConsumerList().iterator();
while(subIter.advance() && !entry.isAcquired())
{
- final QueueConsumer consumer = subIter.getNode().getConsumer();
+ final QueueConsumer<?,E,Q,L> consumer = subIter.getNode().getConsumer();
if(!consumer.isClosed())
{
- QueueContext context = consumer.getQueueContext();
+ QueueContext<E,Q,L> context = consumer.getQueueContext();
if(context != null)
{
- QueueEntry released = context.getReleasedEntry();
+ E released = context.getReleasedEntry();
while(!entry.isAcquired() && (released == null || released.compareTo(entry) > 0))
{
if(QueueContext._releasedUpdater.compareAndSet(context,released,entry))
Copied: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java (from r1565732, qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java?p2=qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java&p1=qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java&r1=1565732&r2=1566069&rev=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java Sat Feb 8 17:52:05 2014
@@ -25,22 +25,22 @@ import org.apache.qpid.server.virtualhos
import java.util.Map;
import java.util.UUID;
-public class AMQPriorityQueue extends OutOfOrderQueue
+public class PriorityQueue extends OutOfOrderQueue<PriorityQueueList.PriorityQueueEntry, PriorityQueue, PriorityQueueList>
{
- protected AMQPriorityQueue(UUID id,
- final String name,
- final boolean durable,
- final String owner,
- final boolean autoDelete,
- boolean exclusive,
- final VirtualHost virtualHost,
- Map<String, Object> arguments, int priorities)
+ protected PriorityQueue(UUID id,
+ final String name,
+ final boolean durable,
+ final String owner,
+ final boolean autoDelete,
+ boolean exclusive,
+ final VirtualHost virtualHost,
+ Map<String, Object> arguments, int priorities)
{
super(id, name, durable, owner, autoDelete, exclusive, virtualHost, new PriorityQueueList.Factory(priorities), arguments);
}
public int getPriorities()
{
- return ((PriorityQueueList) getEntries()).getPriorities();
+ return getEntries().getPriorities();
}
}
Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java?rev=1566069&r1=1566068&r2=1566069&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java Sat Feb 8 17:52:05 2014
@@ -22,132 +22,162 @@ package org.apache.qpid.server.queue;
import org.apache.qpid.server.message.ServerMessage;
-public class PriorityQueueList implements QueueEntryList<SimpleQueueEntryImpl>
+abstract public class PriorityQueueList extends OrderedQueueEntryList<PriorityQueueList.PriorityQueueEntry, PriorityQueue, PriorityQueueList>
{
- private final AMQQueue<QueueConsumer> _queue;
- private final PriorityQueueEntrySubList[] _priorityLists;
- private final int _priorities;
- private final int _priorityOffset;
- public PriorityQueueList(AMQQueue queue, int priorities)
- {
- _queue = queue;
- _priorityLists = new PriorityQueueEntrySubList[priorities];
- _priorities = priorities;
- _priorityOffset = 5-((priorities + 1)/2);
- for(int i = 0; i < priorities; i++)
- {
- _priorityLists[i] = new PriorityQueueEntrySubList(queue, i);
- }
- }
- public int getPriorities()
+ public PriorityQueueList(final PriorityQueue queue,
+ final HeadCreator<PriorityQueueEntry, PriorityQueue, PriorityQueueList> headCreator)
{
- return _priorities;
+ super(queue, headCreator);
}
- public AMQQueue<QueueConsumer> getQueue()
+ static class PriorityQueueMasterList extends PriorityQueueList
{
- return _queue;
- }
+ private static final HeadCreator<PriorityQueueEntry, PriorityQueue, PriorityQueueList> DUMMY_HEAD_CREATOR =
+ new HeadCreator<PriorityQueueEntry, PriorityQueue, PriorityQueueList>()
+ {
+ @Override
+ public PriorityQueueEntry createHead(final PriorityQueueList list)
+ {
+ return null;
+ }
+ };
+ private final PriorityQueue _queue;
+ private final PriorityQueueEntrySubList[] _priorityLists;
+ private final int _priorities;
+ private final int _priorityOffset;
- public SimpleQueueEntryImpl add(ServerMessage message)
- {
- int index = message.getMessageHeader().getPriority() - _priorityOffset;
- if(index >= _priorities)
+ public PriorityQueueMasterList(PriorityQueue queue, int priorities)
{
- index = _priorities-1;
+ super(queue, DUMMY_HEAD_CREATOR);
+ _queue = queue;
+ _priorityLists = new PriorityQueueEntrySubList[priorities];
+ _priorities = priorities;
+ _priorityOffset = 5-((priorities + 1)/2);
+ for(int i = 0; i < priorities; i++)
+ {
+ _priorityLists[i] = new PriorityQueueEntrySubList(queue, i);
+ }
}
- else if(index < 0)
+
+ public int getPriorities()
{
- index = 0;
+ return _priorities;
}
- return _priorityLists[index].add(message);
-
- }
-
- public SimpleQueueEntryImpl next(SimpleQueueEntryImpl node)
- {
- SimpleQueueEntryImpl next = node.getNextValidEntry();
- if(next == null)
+ public PriorityQueue getQueue()
{
- final QueueEntryList<?> nodeEntryList = node.getQueueEntryList();
- int index;
- for(index = _priorityLists.length-1; _priorityLists[index] != nodeEntryList; index--) {};
+ return _queue;
+ }
- while(next == null && index != 0)
+ public PriorityQueueEntry add(ServerMessage message)
+ {
+ int index = message.getMessageHeader().getPriority() - _priorityOffset;
+ if(index >= _priorities)
+ {
+ index = _priorities-1;
+ }
+ else if(index < 0)
{
- index--;
- next = _priorityLists[index].getHead().getNextValidEntry();
+ index = 0;
}
+ return _priorityLists[index].add(message);
}
- return next;
- }
- private final class PriorityQueueEntryListIterator implements QueueEntryIterator<SimpleQueueEntryImpl>
- {
- private final SimpleQueueEntryList.QueueEntryIteratorImpl[] _iterators = new SimpleQueueEntryList.QueueEntryIteratorImpl[ _priorityLists.length ];
- private SimpleQueueEntryImpl _lastNode;
+ @Override
+ protected PriorityQueueEntry createQueueEntry(final ServerMessage<?> message)
+ {
+ throw new UnsupportedOperationException();
+ }
- PriorityQueueEntryListIterator()
+ public PriorityQueueEntry next(PriorityQueueEntry node)
{
- for(int i = 0; i < _priorityLists.length; i++)
+ PriorityQueueEntry next = node.getNextValidEntry();
+
+ if(next == null)
{
- _iterators[i] = _priorityLists[i].iterator();
+ final PriorityQueueList nodeEntryList = node.getQueueEntryList();
+ int index;
+ for(index = _priorityLists.length-1; _priorityLists[index] != nodeEntryList; index--)
+ {
+ // do nothing loop is just to find the index
+ }
+
+ while(next == null && index != 0)
+ {
+ index--;
+ next = _priorityLists[index].getHead().getNextValidEntry();
+ }
+
}
- _lastNode = _iterators[_iterators.length - 1].getNode();
+ return next;
}
-
- public boolean atTail()
+ private final class PriorityQueueEntryListIterator implements QueueEntryIterator<PriorityQueueEntry, PriorityQueue, PriorityQueueList, QueueConsumer<?,PriorityQueueEntry, PriorityQueue, PriorityQueueList>>
{
- for(int i = 0; i < _iterators.length; i++)
+ private final QueueEntryIterator<PriorityQueueEntry, PriorityQueue, PriorityQueueList,QueueConsumer<?,PriorityQueueEntry, PriorityQueue, PriorityQueueList>>[] _iterators = new QueueEntryIterator[ _priorityLists.length ];
+ private PriorityQueueEntry _lastNode;
+
+ PriorityQueueEntryListIterator()
{
- if(!_iterators[i].atTail())
+ for(int i = 0; i < _priorityLists.length; i++)
{
- return false;
+ _iterators[i] = _priorityLists[i].iterator();
}
+ _lastNode = _iterators[_iterators.length - 1].getNode();
}
- return true;
- }
- public SimpleQueueEntryImpl getNode()
- {
- return _lastNode;
- }
- public boolean advance()
- {
- for(int i = _iterators.length-1; i >= 0; i--)
+ public boolean atTail()
{
- if(_iterators[i].advance())
+ for(int i = 0; i < _iterators.length; i++)
{
- _lastNode = _iterators[i].getNode();
- return true;
+ if(!_iterators[i].atTail())
+ {
+ return false;
+ }
}
+ return true;
+ }
+
+ public PriorityQueueEntry getNode()
+ {
+ return _lastNode;
+ }
+
+ public boolean advance()
+ {
+ for(int i = _iterators.length-1; i >= 0; i--)
+ {
+ if(_iterators[i].advance())
+ {
+ _lastNode = _iterators[i].getNode();
+ return true;
+ }
+ }
+ return false;
}
- return false;
}
- }
- public PriorityQueueEntryListIterator iterator()
- {
- return new PriorityQueueEntryListIterator();
- }
+ public PriorityQueueEntryListIterator iterator()
+ {
- public SimpleQueueEntryImpl getHead()
- {
- return _priorityLists[_priorities-1].getHead();
- }
+ return new PriorityQueueEntryListIterator();
+ }
- public void entryDeleted(final SimpleQueueEntryImpl queueEntry)
- {
+ public PriorityQueueEntry getHead()
+ {
+ return _priorityLists[_priorities-1].getHead();
+ }
- }
+ public void entryDeleted(final PriorityQueueEntry queueEntry)
+ {
- static class Factory implements QueueEntryListFactory
+ }
+ }
+ static class Factory implements QueueEntryListFactory<PriorityQueueEntry, PriorityQueue, PriorityQueueList>
{
private final int _priorities;
@@ -156,26 +186,34 @@ public class PriorityQueueList implement
_priorities = priorities;
}
- public PriorityQueueList createQueueEntryList(AMQQueue queue)
+ public PriorityQueueList createQueueEntryList(PriorityQueue queue)
{
- return new PriorityQueueList(queue, _priorities);
+ return new PriorityQueueMasterList(queue, _priorities);
}
}
- private static class PriorityQueueEntrySubList extends SimpleQueueEntryList
+ static class PriorityQueueEntrySubList extends PriorityQueueList
{
+ private static final HeadCreator<PriorityQueueEntry, PriorityQueue, PriorityQueueList> HEAD_CREATOR = new HeadCreator<PriorityQueueEntry, PriorityQueue, PriorityQueueList>()
+ {
+ @Override
+ public PriorityQueueEntry createHead(final PriorityQueueList list)
+ {
+ return new PriorityQueueEntry(list);
+ }
+ };
private int _listPriority;
- public PriorityQueueEntrySubList(AMQQueue<QueueConsumer> queue, int listPriority)
+ public PriorityQueueEntrySubList(PriorityQueue queue, int listPriority)
{
- super(queue);
+ super(queue, HEAD_CREATOR);
_listPriority = listPriority;
}
@Override
- protected PriorityQueueEntryImpl createQueueEntry(ServerMessage<?> message)
+ protected PriorityQueueEntry createQueueEntry(ServerMessage<?> message)
{
- return new PriorityQueueEntryImpl(this, message);
+ return new PriorityQueueEntry(this, message);
}
public int getListPriority()
@@ -184,17 +222,22 @@ public class PriorityQueueList implement
}
}
- private static class PriorityQueueEntryImpl extends SimpleQueueEntryImpl
+ static class PriorityQueueEntry extends OrderedQueueEntry<PriorityQueueEntry, PriorityQueue, PriorityQueueList>
{
- public PriorityQueueEntryImpl(PriorityQueueEntrySubList queueEntryList, ServerMessage<?> message)
+ private PriorityQueueEntry(final PriorityQueueList queueEntryList)
+ {
+ super(queueEntryList);
+ }
+
+ public PriorityQueueEntry(PriorityQueueEntrySubList queueEntryList, ServerMessage<?> message)
{
super(queueEntryList, message);
}
@Override
- public int compareTo(final QueueEntry o)
+ public int compareTo(final PriorityQueueEntry o)
{
- PriorityQueueEntrySubList pqel = (PriorityQueueEntrySubList)((PriorityQueueEntryImpl)o).getQueueEntryList();
+ PriorityQueueEntrySubList pqel = (PriorityQueueEntrySubList)o.getQueueEntryList();
int otherPriority = pqel.getListPriority();
int thisPriority = ((PriorityQueueEntrySubList) getQueueEntryList()).getListPriority();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org