diff options
author | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
commit | 9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 (patch) | |
tree | 2a890e1df09e5b896a9b4168a7b22648f559a1f2 /cpp/src/qpid/ha/HaBroker.h | |
parent | 172d9b2a16cfb817bbe632d050acba7e31401cd2 (diff) | |
download | qpid-python-asyncstore.tar.gz |
Update from trunk r1375509 through r1450773asyncstore
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/ha/HaBroker.h')
-rw-r--r-- | cpp/src/qpid/ha/HaBroker.h | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/cpp/src/qpid/ha/HaBroker.h b/cpp/src/qpid/ha/HaBroker.h index 7dabe6e35b..6b15c88e0a 100644 --- a/cpp/src/qpid/ha/HaBroker.h +++ b/cpp/src/qpid/ha/HaBroker.h @@ -25,14 +25,12 @@ #include "BrokerInfo.h" #include "Membership.h" #include "types.h" -#include "ReplicationTest.h" #include "Settings.h" #include "qpid/Url.h" #include "qpid/sys/Mutex.h" #include "qmf/org/apache/qpid/ha/HaBroker.h" #include "qpid/management/Manageable.h" #include "qpid/types/Variant.h" -#include <memory> #include <set> #include <boost/shared_ptr.hpp> @@ -54,11 +52,15 @@ namespace ha { class Backup; class ConnectionObserver; class Primary; - +class Role; /** * HA state and actions associated with a HA broker. Holds all the management info. * * THREAD SAFE: may be called in arbitrary broker IO or timer threads. + + * NOTE: HaBroker and Role subclasses follow this lock hierarchy: + * - HaBroker MUST NOT hold its own lock across calls Role subclasses. + * - Role subclasses MAY hold their locks accross calls to HaBroker. */ class HaBroker : public management::Manageable { @@ -71,66 +73,46 @@ class HaBroker : public management::Manageable void initialize(); // Implement Manageable. - qpid::management::ManagementObject* GetManagementObject() const { return mgmtObject; } + qpid::management::ManagementObject::shared_ptr GetManagementObject() const { return mgmtObject; } management::Manageable::status_t ManagementMethod ( uint32_t methodId, management::Args& args, std::string& text); broker::Broker& getBroker() { return broker; } const Settings& getSettings() const { return settings; } - /** Shut down the broker. Caller should log a critical error message. */ - void shutdown(); + /** Shut down the broker because of a critical error. */ + void shutdown(const std::string& message); BrokerStatus getStatus() const; - void setStatus(BrokerStatus); - void activate(); - - Backup* getBackup() { return backup.get(); } - ReplicationTest getReplicationTest() const { return replicationTest; } - boost::shared_ptr<ConnectionObserver> getObserver() { return observer; } - const BrokerInfo& getBrokerInfo() const { return brokerInfo; } - - void setMembership(const types::Variant::List&); // Set membership from list. - void resetMembership(const BrokerInfo& b); // Reset to contain just one member. - void addBroker(const BrokerInfo& b); // Add a broker to the membership. - void removeBroker(const types::Uuid& id); // Remove a broker from membership. - + BrokerInfo getBrokerInfo() const { return membership.getInfo(); } + Membership& getMembership() { return membership; } types::Uuid getSystemId() const { return systemId; } private: - void setClientUrl(const Url&); + + void setPublicUrl(const Url&); void setBrokerUrl(const Url&); void updateClientUrl(sys::Mutex::ScopedLock&); - bool isPrimary(sys::Mutex::ScopedLock&) { return !backup.get(); } - - void setStatus(BrokerStatus, sys::Mutex::ScopedLock&); - void recover(); - void statusChanged(sys::Mutex::ScopedLock&); - void setLinkProperties(sys::Mutex::ScopedLock&); - std::vector<Url> getKnownBrokers() const; - void membershipUpdated(sys::Mutex::ScopedLock&); - - std::string logPrefix; - broker::Broker& broker; - types::Uuid systemId; + // Immutable members + const types::Uuid systemId; const Settings settings; + // Member variables protected by lock mutable sys::Mutex lock; - boost::shared_ptr<ConnectionObserver> observer; // Used by Backup and Primary - std::auto_ptr<Backup> backup; - std::auto_ptr<Primary> primary; - qmf::org::apache::qpid::ha::HaBroker* mgmtObject; - Url clientUrl, brokerUrl; + Url publicUrl, brokerUrl; std::vector<Url> knownBrokers; - BrokerStatus status; - BrokerInfo brokerInfo; + + // Independently thread-safe member variables + broker::Broker& broker; + qmf::org::apache::qpid::ha::HaBroker::shared_ptr mgmtObject; + boost::shared_ptr<ConnectionObserver> observer; // Used by Backup and Primary + boost::shared_ptr<Role> role; Membership membership; - ReplicationTest replicationTest; }; }} // namespace qpid::ha |