diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2008-08-07 15:37:36 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2008-08-07 15:37:36 +0000 |
| commit | c53cf3df85bb5a37ec7ec000667cba4012c35e85 (patch) | |
| tree | 1eeb3f4c1c663a1d1831bf0b794488d98a237c78 /java/broker/src/main | |
| parent | 87317fb32beea5c78506afce0be739c2a90b098e (diff) | |
| download | qpid-python-c53cf3df85bb5a37ec7ec000667cba4012c35e85.tar.gz | |
QPID-1195 , QPID-1193 Initial changes to allow bind and queue arguments to be stored and recovered from the MessageStore. Created a test to validate that the stored values can be recovered. DerbyStore hasn't fully been implemented. Surrounding work has been done and tested with BDBMessageStore.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@683632 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker/src/main')
14 files changed, 138 insertions, 65 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java index 88d5360f3e..6312aed5bf 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java +++ b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java @@ -180,7 +180,7 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr null); if (queue.isDurable() && !queue.isAutoDelete()) { - _messageStore.createQueue(queue); + _messageStore.createQueue(queue, null); } Configuration virtualHostDefaultQueueConfiguration = diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java index bd3e5b1f72..984106277f 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java @@ -197,7 +197,7 @@ public class VirtualHostConfiguration if (queue.isDurable()) { - messageStore.createQueue(queue); + messageStore.createQueue(queue, null); } queueRegistry.registerQueue(queue); diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java index 616f47bd24..e39c005750 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java +++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java @@ -166,11 +166,19 @@ public class DirectExchange extends AbstractExchange assert routingKey != null; if (!_index.add(routingKey, queue)) { - _logger.debug("Queue " + queue + " is already registered with routing key " + routingKey); + if (_logger.isDebugEnabled()) + { + _logger.debug("Queue (" + queue.getName() + ")" + queue + " is already registered with routing key " + routingKey); + } } else { - _logger.debug("Binding queue " + queue + " with routing key " + routingKey + " to exchange " + this); + if (_logger.isDebugEnabled()) + { + _logger.debug("Binding queue(" + queue.getName() + ") " + queue + " with routing key " + routingKey + + (args == null ? "" : " and arguments " + args.toString()) + + " to exchange " + this); + } } } diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java index 379ec7a7d6..447482ccf3 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java +++ b/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java @@ -117,7 +117,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar queue = createQueue(queueName, body, virtualHost, session); if (queue.isDurable() && !queue.isAutoDelete()) { - store.createQueue(queue); + store.createQueue(queue, body.getArguments()); } queueRegistry.registerQueue(queue); if (autoRegister) diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java index ba6b392d13..e14ed0f41d 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java @@ -39,6 +39,11 @@ public class AMQPriorityQueue extends SimpleAMQQueue super(name, durable, owner, autoDelete, virtualHost, new PriorityQueueList.Factory(priorities)); } + public int getPriorities() + { + return ((PriorityQueueList) _entries).getPriorities(); + } + @Override protected void checkSubscriptionsNotAheadOfDelivery(final QueueEntry entry) { @@ -63,5 +68,4 @@ public class AMQPriorityQueue extends SimpleAMQQueue } } - } diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java index f3e4e7c28b..f7bc2ddafa 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java @@ -52,6 +52,7 @@ public interface AMQQueue extends Managable, Comparable<AMQQueue> void unBind(Exchange exchange, AMQShortString routingKey, FieldTable arguments) throws AMQException; + List<ExchangeBinding> getExchangeBindings(); void registerSubscription(final Subscription subscription, final boolean exclusive) throws AMQException; diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java index 431b76754f..9dfc4449bb 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java @@ -28,7 +28,7 @@ import org.apache.qpid.AMQException; public class AMQQueueFactory { - private static final AMQShortString X_QPID_PRIORITIES = new AMQShortString("x-qpid-priorities"); + public static final AMQShortString X_QPID_PRIORITIES = new AMQShortString("x-qpid-priorities"); public static AMQQueue createAMQQueueImpl(AMQShortString name, boolean durable, diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java b/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java new file mode 100644 index 0000000000..a2fcab9e73 --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java @@ -0,0 +1,84 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.queue; + +import org.apache.qpid.server.exchange.Exchange; +import org.apache.qpid.framing.AMQShortString; +import org.apache.qpid.framing.FieldTable; +import org.apache.qpid.AMQException; + +public class ExchangeBinding +{ + private final Exchange _exchange; + private final AMQShortString _routingKey; + private final FieldTable _arguments; + + private static final FieldTable EMPTY_ARGUMENTS = new FieldTable(); + + ExchangeBinding(AMQShortString routingKey, Exchange exchange) + { + this(routingKey, exchange, EMPTY_ARGUMENTS); + } + + ExchangeBinding(AMQShortString routingKey, Exchange exchange, FieldTable arguments) + { + _routingKey = routingKey == null ? AMQShortString.EMPTY_STRING : routingKey; + _exchange = exchange; + _arguments = arguments == null ? EMPTY_ARGUMENTS : arguments; + } + + void unbind(AMQQueue queue) throws AMQException + { + _exchange.deregisterQueue(_routingKey, queue, _arguments); + } + + public Exchange getExchange() + { + return _exchange; + } + + public AMQShortString getRoutingKey() + { + return _routingKey; + } + + public FieldTable getArguments() + { + return _arguments; + } + + public int hashCode() + { + return (_exchange == null ? 0 : _exchange.hashCode()) + + (_routingKey == null ? 0 : _routingKey.hashCode()); + } + + public boolean equals(Object o) + { + if (!(o instanceof ExchangeBinding)) + { + return false; + } + ExchangeBinding eb = (ExchangeBinding) o; + return _exchange.equals(eb._exchange) + && _routingKey.equals(eb._routingKey); + } +}
\ No newline at end of file diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java b/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java index d2e5a02508..fb839c1783 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java @@ -36,59 +36,6 @@ import org.apache.qpid.server.exchange.Exchange; */ class ExchangeBindings { - private static final FieldTable EMPTY_ARGUMENTS = new FieldTable(); - - static class ExchangeBinding - { - private final Exchange _exchange; - private final AMQShortString _routingKey; - private final FieldTable _arguments; - - ExchangeBinding(AMQShortString routingKey, Exchange exchange) - { - this(routingKey, exchange, EMPTY_ARGUMENTS); - } - - ExchangeBinding(AMQShortString routingKey, Exchange exchange, FieldTable arguments) - { - _routingKey = routingKey == null ? AMQShortString.EMPTY_STRING : routingKey; - _exchange = exchange; - _arguments = arguments == null ? EMPTY_ARGUMENTS : arguments; - } - - void unbind(AMQQueue queue) throws AMQException - { - _exchange.deregisterQueue(_routingKey, queue, _arguments); - } - - public Exchange getExchange() - { - return _exchange; - } - - public AMQShortString getRoutingKey() - { - return _routingKey; - } - - public int hashCode() - { - return (_exchange == null ? 0 : _exchange.hashCode()) - + (_routingKey == null ? 0 : _routingKey.hashCode()); - } - - public boolean equals(Object o) - { - if (!(o instanceof ExchangeBinding)) - { - return false; - } - ExchangeBinding eb = (ExchangeBinding) o; - return _exchange.equals(eb._exchange) - && _routingKey.equals(eb._routingKey); - } - } - private final List<ExchangeBinding> _bindings = new CopyOnWriteArrayList<ExchangeBinding>(); private final AMQQueue _queue; diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java b/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java index e6628832cb..fd46a8a5ff 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java @@ -42,6 +42,11 @@ public class PriorityQueueList implements QueueEntryList } } + public int getPriorities() + { + return _priorities; + } + public AMQQueue getQueue() { return _queue; diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java index 4b7da30800..1674c26232 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java @@ -82,7 +82,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener private volatile Subscription _exclusiveSubscriber; - private final QueueEntryList _entries; + protected final QueueEntryList _entries; private final AMQQueueMBean _managedObject; private final Executor _asyncDelivery; @@ -223,6 +223,11 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener } } + public List<ExchangeBinding> getExchangeBindings() + { + return new ArrayList<ExchangeBinding>(_bindings.getExchangeBindings()); + } + // ------ Manage Subscriptions public synchronized void registerSubscription(final Subscription subscription, final boolean exclusive) throws AMQException diff --git a/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java b/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java index 9d22e2b929..bfbba8c00f 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java +++ b/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java @@ -728,7 +728,7 @@ public class DerbyMessageStore implements MessageStore } - public void createQueue(AMQQueue queue) throws AMQException + public void createQueue(AMQQueue queue, FieldTable arguments) throws AMQException { _logger.debug("public void createQueue(AMQQueue queue = " + queue + "): called"); @@ -1281,6 +1281,11 @@ public class DerbyMessageStore implements MessageStore } + public boolean isPersistent() + { + return true; + } + private void checkNotClosed() throws MessageStoreClosedException { if (_closed.get()) diff --git a/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java b/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java index b02eff957e..f8d8404b89 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java +++ b/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java @@ -121,7 +121,7 @@ public class MemoryMessageStore implements MessageStore } - public void createQueue(AMQQueue queue) throws AMQException + public void createQueue(AMQQueue queue, FieldTable arguments) throws AMQException { // Not required to do anything } @@ -213,7 +213,12 @@ public class MemoryMessageStore implements MessageStore return bodyList.get(index); } - private void checkNotClosed() throws MessageStoreClosedException + public boolean isPersistent() + { + return false; + } + + private void checkNotClosed() throws MessageStoreClosedException { if (_closed.get()) { diff --git a/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java b/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java index e15e69a414..9e855bcc09 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java +++ b/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java @@ -131,9 +131,10 @@ public interface MessageStore * * @param queue The queue to store. * + * @param arguments The additional arguments to the binding * @throws AMQException If the operation fails for any reason. */ - void createQueue(AMQQueue queue) throws AMQException; + void createQueue(AMQQueue queue, FieldTable arguments) throws AMQException; /** * Removes the specified queue from the persistent store. @@ -255,4 +256,12 @@ public interface MessageStore * @throws AMQException If the operation fails for any reason, or if the specified message does not exist. */ ContentChunk getContentBodyChunk(StoreContext context, Long messageId, int index) throws AMQException; + + /** + * Is this store capable of persisting the data + * + * @return true if this store is capable of persisting data + */ + boolean isPersistent(); + } |
