From 28af05eefebf472eefffd9458f9ae0eac52a5e87 Mon Sep 17 00:00:00 2001 From: "Carl C. Trieloff" Date: Tue, 16 Sep 2008 19:33:36 +0000 Subject: - add mgnt schema for cluster - add mgnt object and init - create call-backs to stop a cluster node & the full cluster git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@696017 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/Makefile.am | 3 +- cpp/src/qpid/cluster/Cluster.cpp | 46 ++++++++++++++++++++++++ cpp/src/qpid/cluster/Cluster.h | 10 +++++- cpp/src/qpid/cluster/management-schema.xml | 57 ++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 cpp/src/qpid/cluster/management-schema.xml (limited to 'cpp') diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index 9bef06e7bb..235e0d35cc 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -30,7 +30,8 @@ $(rgen_generator): mgen_dir=$(top_srcdir)/managementgen mgen_cmd=$(mgen_dir)/qmf-gen -m $(srcdir)/managementgen.mk -o gen/qmf \ $(top_srcdir)/../specs/management-schema.xml \ - $(srcdir)/qpid/acl/management-schema.xml + $(srcdir)/qpid/acl/management-schema.xml \ + $(srcdir)/qpid/cluster/management-schema.xml $(srcdir)/managementgen.mk $(mgen_broker_cpp) $(dist_qpid_management_HEADERS): mgen.timestamp mgen.timestamp: $(mgen_generator) diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index 858542802c..2a73925090 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -33,6 +33,7 @@ #include "qpid/log/Statement.h" #include "qpid/memory.h" #include "qpid/shared_ptr.h" +#include "qmf/org/apache/qpid/cluster/Package.h" #include #include @@ -47,6 +48,12 @@ namespace cluster { using namespace qpid::framing; using namespace qpid::sys; using namespace std; +using namespace qpid::cluster; +using qpid::management::ManagementAgent; +using qpid::management::ManagementObject; +using qpid::management::Manageable; +using qpid::management::Args; +namespace _qmf = qmf::org::apache::qpid::cluster; struct ClusterOperations : public AMQP_AllOperations::ClusterHandler { Cluster& cluster; @@ -74,6 +81,15 @@ Cluster::Cluster(const std::string& name_, const Url& url_, broker::Broker& b) : connectionEventQueue(EventQueue::forEach(boost::bind(&Cluster::connectionEvent, this, _1))), state(START) { + ManagementAgent* agent = ManagementAgent::Singleton::getInstance(); + if (agent != 0){ + _qmf::Package packageInit(agent); + mgmtObject = new _qmf::Cluster (agent, this, &broker,name.str()); + agent->addObject (mgmtObject); + mgmtObject->set_status("JOINING"); + + // if first cluster up set new UUID to set_clusterID() else set UUID of cluster being joined. + } QPID_LOG(notice, self << " joining cluster " << name.str()); broker.addFinalizer(boost::bind(&Cluster::shutdown, this)); cpgDispatchHandle.startWatch(poller); @@ -344,5 +360,35 @@ void Cluster::shutdown() { delete this; } +ManagementObject* Cluster::GetManagementObject(void) const +{ + return (ManagementObject*) mgmtObject; +} + +Manageable::status_t Cluster::ManagementMethod (uint32_t methodId, Args& /*args*/, string&) +{ + Manageable::status_t status = Manageable::STATUS_UNKNOWN_METHOD; + QPID_LOG (debug, "Queue::ManagementMethod [id=" << methodId << "]"); + + switch (methodId) + { + case _qmf::Cluster::METHOD_STOPCLUSTERNODE: + stopClusterNode(); + break; + case _qmf::Cluster::METHOD_STOPFULLCLUSTER: + stopFullCluster(); + break; + } + + return status; +} + +void Cluster::stopClusterNode(void) +{ +} + +void Cluster::stopFullCluster(void) +{ +} }} // namespace qpid::cluster diff --git a/cpp/src/qpid/cluster/Cluster.h b/cpp/src/qpid/cluster/Cluster.h index e33cca8482..982a9da2ca 100644 --- a/cpp/src/qpid/cluster/Cluster.h +++ b/cpp/src/qpid/cluster/Cluster.h @@ -29,6 +29,8 @@ #include "qpid/sys/Monitor.h" #include "qpid/framing/AMQP_AllOperations.h" #include "qpid/Url.h" +#include "qpid/management/Manageable.h" +#include "qmf/org/apache/qpid/cluster/Cluster.h" #include @@ -43,7 +45,7 @@ class Connection; * Connection to the cluster. * Keeps cluster membership data. */ -class Cluster : private Cpg::Handler +class Cluster : private Cpg::Handler, public management::Manageable { public: @@ -129,6 +131,11 @@ class Cluster : private Cpg::Handler boost::intrusive_ptr getConnection(const ConnectionId&); + virtual qpid::management::ManagementObject* GetManagementObject(void) const; + virtual management::Manageable::status_t ManagementMethod (uint32_t methodId, management::Args& args, std::string& text); + void stopClusterNode(void); + void stopFullCluster(void); + mutable sys::Monitor lock; // Protect access to members. broker::Broker& broker; boost::shared_ptr poller; @@ -142,6 +149,7 @@ class Cluster : private Cpg::Handler sys::DispatchHandle cpgDispatchHandle; EventQueue connectionEventQueue; State state; + qmf::org::apache::qpid::cluster::Cluster* mgmtObject; // mgnt owns lifecycle }; }} // namespace qpid::cluster diff --git a/cpp/src/qpid/cluster/management-schema.xml b/cpp/src/qpid/cluster/management-schema.xml new file mode 100644 index 0000000000..1919bb7976 --- /dev/null +++ b/cpp/src/qpid/cluster/management-schema.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1