diff options
author | Gordon Sim <gsim@apache.org> | 2014-01-20 21:19:04 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2014-01-20 21:19:04 +0000 |
commit | 3767d0f39c2903c38cb20222e97b9e8efa38f0e1 (patch) | |
tree | 518bc52314914a03594c5a686e2b51ba9c03293c | |
parent | bbfc9d1b5b1af45f963e3ee907063a03c1a92491 (diff) | |
download | qpid-python-3767d0f39c2903c38cb20222e97b9e8efa38f0e1.tar.gz |
QPID-5463: make dynamic nodes auto deleted by default
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.26@1559830 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/NodeProperties.cpp | 13 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/NodeProperties.h | 6 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/Session.cpp | 2 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/Session.h | 1 |
4 files changed, 18 insertions, 4 deletions
diff --git a/qpid/cpp/src/qpid/broker/amqp/NodeProperties.cpp b/qpid/cpp/src/qpid/broker/amqp/NodeProperties.cpp index f1d29fe00e..50e3b081c7 100644 --- a/qpid/cpp/src/qpid/broker/amqp/NodeProperties.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/NodeProperties.cpp @@ -103,7 +103,8 @@ bool getLifetimeDescriptorSymbol(QueueSettings::LifetimePolicy policy, pn_bytes_ } -NodeProperties::NodeProperties() : received(false), queue(true), durable(false), autoDelete(false), exclusive(false), exchangeType("topic"), lifetime(QueueSettings::DELETE_IF_UNUSED) {} +NodeProperties::NodeProperties(bool isDynamic) : received(false), queue(true), durable(false), autoDelete(false), exclusive(false), + dynamic(isDynamic), exchangeType("topic"), lifetime(QueueSettings::DELETE_IF_UNUSED) {} void NodeProperties::read(pn_data_t* data) { @@ -111,6 +112,11 @@ void NodeProperties::read(pn_data_t* data) reader.read(data); } +bool NodeProperties::wasSpecified(const std::string& key) const +{ + return specified.find(key) != specified.end(); +} + void NodeProperties::write(pn_data_t* data, boost::shared_ptr<Queue> node) { if (received) { @@ -202,6 +208,7 @@ void NodeProperties::process(const std::string& key, const qpid::types::Variant& { received = true; QPID_LOG(debug, "Processing node property " << key << " = " << value); + specified.insert(key); if (key == SUPPORTED_DIST_MODES) { if (value == MOVE) queue = true; else if (value == COPY) queue = false; @@ -317,7 +324,9 @@ void NodeProperties::onSymbolValue(const CharSequence& key, const CharSequence& QueueSettings NodeProperties::getQueueSettings() { - QueueSettings settings(durable, autoDelete); + //assume autodelete for dynamic nodes unless explicitly requested + //otherwise or unless durability is requested + QueueSettings settings(durable, autoDelete || (dynamic && !wasSpecified(AUTO_DELETE) && !durable)); qpid::types::Variant::Map unused; settings.populate(properties, unused); settings.lifetime = lifetime; diff --git a/qpid/cpp/src/qpid/broker/amqp/NodeProperties.h b/qpid/cpp/src/qpid/broker/amqp/NodeProperties.h index 4ac3aa8a0f..c56dd55f64 100644 --- a/qpid/cpp/src/qpid/broker/amqp/NodeProperties.h +++ b/qpid/cpp/src/qpid/broker/amqp/NodeProperties.h @@ -24,6 +24,7 @@ #include "qpid/amqp/MapReader.h" #include "qpid/types/Variant.h" #include "qpid/broker/QueueSettings.h" +#include <set> #include <boost/shared_ptr.hpp> struct pn_data_t; @@ -37,7 +38,7 @@ namespace amqp { class NodeProperties : public qpid::amqp::MapReader { public: - NodeProperties(); + NodeProperties(bool isDynamic); void read(pn_data_t*); void write(pn_data_t*,boost::shared_ptr<Queue>); void write(pn_data_t*,boost::shared_ptr<Exchange>); @@ -73,12 +74,15 @@ class NodeProperties : public qpid::amqp::MapReader bool durable; bool autoDelete; bool exclusive; + bool dynamic; std::string exchangeType; std::string alternateExchange; qpid::types::Variant::Map properties; QueueSettings::LifetimePolicy lifetime; + std::set<std::string> specified; void process(const std::string&, const qpid::types::Variant&, const qpid::amqp::Descriptor*); + bool wasSpecified(const std::string& key) const; }; }}} // namespace qpid::broker::amqp diff --git a/qpid/cpp/src/qpid/broker/amqp/Session.cpp b/qpid/cpp/src/qpid/broker/amqp/Session.cpp index ab677faac3..6c3fb613d2 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Session.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Session.cpp @@ -216,7 +216,7 @@ Session::ResolvedNode Session::resolve(const std::string name, pn_terminus_t* te } //check whether user is even allowed access to queues/topics before resolving authorise.access(name, isQueueRequested, isTopicRequested); - ResolvedNode node; + ResolvedNode node(pn_terminus_is_dynamic(terminus)); if (isTopicRequested || !isQueueRequested) { node.topic = connection.getTopics().get(name); if (node.topic) node.exchange = node.topic->getExchange(); diff --git a/qpid/cpp/src/qpid/broker/amqp/Session.h b/qpid/cpp/src/qpid/broker/amqp/Session.h index a991ac9e3e..1d9c2d161d 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Session.h +++ b/qpid/cpp/src/qpid/broker/amqp/Session.h @@ -100,6 +100,7 @@ class Session : public ManagedSession, public boost::enable_shared_from_this<Ses boost::shared_ptr<qpid::broker::amqp::Topic> topic; boost::shared_ptr<Relay> relay; NodeProperties properties; + ResolvedNode(bool isDynamic) : properties(isDynamic) {} }; ResolvedNode resolve(const std::string name, pn_terminus_t* terminus, bool incoming); |