From 92b8daec32ca76cbfdd02558e45d41ff7373f6ef Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 16 Oct 2008 18:45:56 +0000 Subject: Add UUID generated for each new cluster instance. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@705322 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/Cluster.cpp | 17 ++++++--- cpp/src/qpid/cluster/Cluster.h | 11 +++++- cpp/src/qpid/cluster/management-schema.xml | 59 +++++++++++++++--------------- 3 files changed, 51 insertions(+), 36 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index a0bcb9ae02..70c73191ee 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -78,7 +78,7 @@ struct ClusterDispatcher : public framing::AMQP_AllOperations::ClusterHandler { void dumpRequest(const std::string& url) { cluster.dumpRequest(member, url, l); } void ready(const std::string& url) { cluster.ready(member, url, l); } void configChange(const std::string& addresses) { cluster.configChange(member, addresses, l); } - void dumpOffer(uint64_t dumpee) { cluster.dumpOffer(member, dumpee, l); } + void dumpOffer(uint64_t dumpee, const Uuid& id) { cluster.dumpOffer(member, dumpee, id, l); } void dumpStart(uint64_t dumpee, const std::string& url) { cluster.dumpStart(member, dumpee, url, l); } void shutdown() { cluster.shutdown(member, l); } @@ -110,8 +110,6 @@ Cluster::Cluster(const std::string& name_, const Url& url_, broker::Broker& b) : mgmtObject = new qmf::Cluster (agent, this, &broker,name.str(),myUrl.str()); agent->addObject (mgmtObject); mgmtObject->set_status("JOINING"); - // FIXME aconway 2008-09-24: - // if first cluster up set new UUID to set_clusterID() else set UUID of cluster being joined. } broker.getKnownBrokers = boost::bind(&Cluster::getUrls, this); failoverExchange.reset(new FailoverExchange(this)); @@ -372,6 +370,7 @@ void Cluster::configChange(const MemberId&, const std::string& addresses, Lock& if (state == INIT) { // First configChange if (map.aliveCount() == 1) { + setClusterId(true); QPID_LOG(info, *this << " first in cluster at " << myUrl); state = READY; if (mgmtObject!=0) mgmtObject->set_status("ACTIVE"); @@ -395,7 +394,7 @@ void Cluster::tryMakeOffer(const MemberId& id, Lock& l) { if (state == READY && map.isNewbie(id)) { state = OFFER; QPID_LOG(debug, *this << " send dump-offer to " << id); - mcastControl(ClusterDumpOfferBody(ProtocolVersion(), id), l); + mcastControl(ClusterDumpOfferBody(ProtocolVersion(), id, clusterId), l); } } @@ -432,7 +431,7 @@ void Cluster::ready(const MemberId& id, const std::string& url, Lock& l) { } } -void Cluster::dumpOffer(const MemberId& dumper, uint64_t dumpeeInt, Lock& l) { +void Cluster::dumpOffer(const MemberId& dumper, uint64_t dumpeeInt, const Uuid& uuid, Lock& l) { if (state == LEFT) return; MemberId dumpee(dumpeeInt); boost::optional url = map.dumpOffer(dumper, dumpee); @@ -450,6 +449,7 @@ void Cluster::dumpOffer(const MemberId& dumper, uint64_t dumpeeInt, Lock& l) { else if (dumpee == myId && url) { assert(state == NEWBIE); QPID_LOG(debug, *this << " accepted dump-offer from " << dumper); + setClusterId(uuid); state = DUMPEE; deliverQueue.stop(); checkDumpIn(l); @@ -580,4 +580,11 @@ broker::Broker& Cluster::getBroker() const { return broker; // Immutable, no need to lock. } +void Cluster::setClusterId(const Uuid& uuid) { + clusterId = uuid; + if (mgmtObject) + mgmtObject->set_clusterID(clusterId.str()); + QPID_LOG(debug, *this << " cluster-id = " << clusterId); +} + }} // namespace qpid::cluster diff --git a/cpp/src/qpid/cluster/Cluster.h b/cpp/src/qpid/cluster/Cluster.h index 8ee55e68f8..d8b9c958d8 100644 --- a/cpp/src/qpid/cluster/Cluster.h +++ b/cpp/src/qpid/cluster/Cluster.h @@ -42,6 +42,12 @@ #include namespace qpid { + +namespace framing { +class AMQBody; +class Uuid; +} + namespace cluster { class Connection; @@ -118,7 +124,7 @@ class Cluster : private Cpg::Handler, public management::Manageable { // May be called in CPG thread via deliver() OR in deliverQueue thread. // void dumpRequest(const MemberId&, const std::string&, Lock&); - void dumpOffer(const MemberId& dumper, uint64_t dumpee, Lock&); + void dumpOffer(const MemberId& dumper, uint64_t dumpee, const framing::Uuid&, Lock&); void dumpStart(const MemberId& dumper, uint64_t dumpeeInt, const std::string& urlStr, Lock&); void ready(const MemberId&, const std::string&, Lock&); void configChange(const MemberId&, const std::string& addresses, Lock& l); @@ -166,6 +172,8 @@ class Cluster : private Cpg::Handler, public management::Manageable { void dumpOutError(const std::exception&); void dumpOutDone(Lock&); + void setClusterId(const framing::Uuid&); + mutable sys::Monitor lock; broker::Broker& broker; @@ -181,6 +189,7 @@ class Cluster : private Cpg::Handler, public management::Manageable { PollableEventQueue deliverQueue; PlainEventQueue mcastQueue; uint32_t mcastId; + framing::Uuid clusterId; qmf::org::apache::qpid::cluster::Cluster* mgmtObject; // mgnt owns lifecycle diff --git a/cpp/src/qpid/cluster/management-schema.xml b/cpp/src/qpid/cluster/management-schema.xml index 0f30814367..4c25ddf636 100644 --- a/cpp/src/qpid/cluster/management-schema.xml +++ b/cpp/src/qpid/cluster/management-schema.xml @@ -1,39 +1,39 @@ - + @@ -44,8 +44,7 @@ - - + -- cgit v1.2.1