diff options
| author | Gordon Sim <gsim@apache.org> | 2009-01-23 21:55:15 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2009-01-23 21:55:15 +0000 |
| commit | b849efb083c88de6c1932d0f7a87a7c500dbd3d6 (patch) | |
| tree | 727bdbdb8c3701d90a0d31e2f3e42b26d10c9f9d /cpp/src/qpid/broker | |
| parent | 85428cec6a090c58c34453dee8b38ac20a619a96 (diff) | |
| download | qpid-python-b849efb083c88de6c1932d0f7a87a7c500dbd3d6.tar.gz | |
Use special management ids for objects used in state transfer to new members. This prevents the ids getting out of sync across the cluster and allows management methods to be used reliably.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@737203 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker')
| -rw-r--r-- | cpp/src/qpid/broker/Connection.cpp | 7 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Connection.h | 2 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Exchange.cpp | 15 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Exchange.h | 30 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Queue.cpp | 8 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/SessionState.cpp | 5 |
6 files changed, 41 insertions, 26 deletions
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp index 66ee6281c6..b7446a2220 100644 --- a/cpp/src/qpid/broker/Connection.cpp +++ b/cpp/src/qpid/broker/Connection.cpp @@ -48,7 +48,7 @@ namespace _qmf = qmf::org::apache::qpid::broker; namespace qpid { namespace broker { -Connection::Connection(ConnectionOutputHandler* out_, Broker& broker_, const std::string& mgmtId_, bool isLink_) : +Connection::Connection(ConnectionOutputHandler* out_, Broker& broker_, const std::string& mgmtId_, bool isLink_, uint64_t objectId) : ConnectionState(out_, broker_), adapter(*this, isLink_), isLink(isLink_), @@ -70,9 +70,10 @@ Connection::Connection(ConnectionOutputHandler* out_, Broker& broker_, const std // TODO set last bool true if system connection - if (agent != 0) + if (agent != 0) { mgmtObject = new _qmf::Connection(agent, this, parent, mgmtId, !isLink, false); - agent->addObject(mgmtObject); + agent->addObject(mgmtObject, objectId); + } ConnectionState::setUrl(mgmtId); } } diff --git a/cpp/src/qpid/broker/Connection.h b/cpp/src/qpid/broker/Connection.h index 559cd4cfe3..80d828584d 100644 --- a/cpp/src/qpid/broker/Connection.h +++ b/cpp/src/qpid/broker/Connection.h @@ -64,7 +64,7 @@ class Connection : public sys::ConnectionInputHandler, public RefCounted { public: - Connection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId, bool isLink = false); + Connection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId, bool isLink = false, uint64_t objectId = 0); ~Connection (); /** Get the SessionHandler for channel. Create if it does not already exist */ diff --git a/cpp/src/qpid/broker/Exchange.cpp b/cpp/src/qpid/broker/Exchange.cpp index 34673bdab3..53c49bf0ce 100644 --- a/cpp/src/qpid/broker/Exchange.cpp +++ b/cpp/src/qpid/broker/Exchange.cpp @@ -22,6 +22,7 @@ #include "Exchange.h" #include "ExchangeRegistry.h" #include "qpid/agent/ManagementAgent.h" +#include "qpid/management/ManagementBroker.h" #include "qpid/log/Statement.h" #include "qpid/framing/MessageProperties.h" #include "DeliverableMessage.h" @@ -32,6 +33,7 @@ using qpid::framing::Buffer; using qpid::framing::FieldTable; using qpid::sys::Mutex; using qpid::management::ManagementAgent; +using qpid::management::ManagementBroker; using qpid::management::ManagementObject; using qpid::management::Manageable; using qpid::management::Args; @@ -109,12 +111,14 @@ Exchange::Exchange(const string& _name, bool _durable, const qpid::framing::Fiel mgmtExchange = new _qmf::Exchange (agent, this, parent, _name, durable); mgmtExchange->set_arguments(args); if (!durable) { - if (name == "") + if (name == "") { agent->addObject (mgmtExchange, 0x1000000000000004LL); // Special default exchange ID - else if (name == "qpid.management") + } else if (name == "qpid.management") { agent->addObject (mgmtExchange, 0x1000000000000005LL); // Special management exchange ID - else - agent->addObject (mgmtExchange); + } else { + ManagementBroker* mb = dynamic_cast<ManagementBroker*>(agent); + agent->addObject (mgmtExchange, mb ? mb->allocateId(this) : 0); + } } } } @@ -245,7 +249,8 @@ Exchange::Binding::Binding(const string& _key, Queue::shared_ptr _queue, Exchang (agent, this, (Manageable*) parent, queueId, key, args); if (!origin.empty()) mgmtBinding->set_origin(origin); - agent->addObject (mgmtBinding); + ManagementBroker* mb = dynamic_cast<ManagementBroker*>(agent); + agent->addObject (mgmtBinding, mb ? mb->allocateId(this) : 0); } } } diff --git a/cpp/src/qpid/broker/Exchange.h b/cpp/src/qpid/broker/Exchange.h index 5de3e98bc0..488549bbf6 100644 --- a/cpp/src/qpid/broker/Exchange.h +++ b/cpp/src/qpid/broker/Exchange.h @@ -39,6 +39,22 @@ namespace broker { class ExchangeRegistry; class Exchange : public PersistableExchange, public management::Manageable { +public: + struct Binding : public management::Manageable { + typedef boost::shared_ptr<Binding> shared_ptr; + typedef std::vector<Binding::shared_ptr> vector; + + Queue::shared_ptr queue; + const std::string key; + const framing::FieldTable args; + qmf::org::apache::qpid::broker::Binding* mgmtBinding; + + Binding(const std::string& key, Queue::shared_ptr queue, Exchange* parent = 0, + framing::FieldTable args = framing::FieldTable(), const std::string& origin = std::string()); + ~Binding(); + management::ManagementObject* GetManagementObject() const; + }; + private: const std::string name; const bool durable; @@ -64,20 +80,6 @@ protected: void routeIVE(); - struct Binding : public management::Manageable { - typedef boost::shared_ptr<Binding> shared_ptr; - typedef std::vector<Binding::shared_ptr> vector; - - Queue::shared_ptr queue; - const std::string key; - const framing::FieldTable args; - qmf::org::apache::qpid::broker::Binding* mgmtBinding; - - Binding(const std::string& key, Queue::shared_ptr queue, Exchange* parent = 0, - framing::FieldTable args = framing::FieldTable(), const std::string& origin = std::string()); - ~Binding(); - management::ManagementObject* GetManagementObject() const; - }; struct MatchQueue { const Queue::shared_ptr queue; diff --git a/cpp/src/qpid/broker/Queue.cpp b/cpp/src/qpid/broker/Queue.cpp index 962b463571..d459c64c54 100644 --- a/cpp/src/qpid/broker/Queue.cpp +++ b/cpp/src/qpid/broker/Queue.cpp @@ -30,6 +30,7 @@ #include "qpid/StringUtils.h" #include "qpid/log/Statement.h" +#include "qpid/management/ManagementBroker.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Time.h" @@ -46,6 +47,7 @@ using namespace qpid::broker; using namespace qpid::sys; using namespace qpid::framing; using qpid::management::ManagementAgent; +using qpid::management::ManagementBroker; using qpid::management::ManagementObject; using qpid::management::Manageable; using qpid::management::Args; @@ -103,8 +105,10 @@ Queue::Queue(const string& _name, bool _autodelete, // Add the object to the management agent only if this queue is not durable. // If it's durable, we will add it later when the queue is assigned a persistenceId. - if (store == 0) - agent->addObject (mgmtObject); + if (store == 0) { + ManagementBroker* mb = dynamic_cast<ManagementBroker*>(agent); + agent->addObject (mgmtObject, mb ? mb->allocateId(this) : 0); + } } } } diff --git a/cpp/src/qpid/broker/SessionState.cpp b/cpp/src/qpid/broker/SessionState.cpp index e17a813db7..0a24a39d38 100644 --- a/cpp/src/qpid/broker/SessionState.cpp +++ b/cpp/src/qpid/broker/SessionState.cpp @@ -30,6 +30,7 @@ #include "qpid/framing/reply_exceptions.h" #include "qpid/framing/ServerInvoker.h" #include "qpid/log/Statement.h" +#include "qpid/management/ManagementBroker.h" #include <boost/bind.hpp> #include <boost/lexical_cast.hpp> @@ -41,6 +42,7 @@ using namespace framing; using sys::Mutex; using boost::intrusive_ptr; using qpid::management::ManagementAgent; +using qpid::management::ManagementBroker; using qpid::management::ManagementObject; using qpid::management::Manageable; using qpid::management::Args; @@ -65,7 +67,8 @@ SessionState::SessionState( mgmtObject->set_attached (0); mgmtObject->set_detachedLifespan (0); mgmtObject->clr_expireTime(); - agent->addObject (mgmtObject); + ManagementBroker* mb = dynamic_cast<ManagementBroker*>(agent); + agent->addObject (mgmtObject, mb ? mb->allocateId(this) : 0); } } attach(h); |
