diff options
Diffstat (limited to 'cpp/src')
| -rw-r--r-- | cpp/src/Makefile.am | 3 | ||||
| -rw-r--r-- | cpp/src/qpid/cluster/Cluster.cpp | 46 | ||||
| -rw-r--r-- | cpp/src/qpid/cluster/Cluster.h | 10 | ||||
| -rw-r--r-- | cpp/src/qpid/cluster/management-schema.xml | 57 |
4 files changed, 114 insertions, 2 deletions
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 <boost/bind.hpp> #include <boost/cast.hpp> @@ -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 <boost/intrusive_ptr.hpp> @@ -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<cluster::Connection> 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<sys::Poller> 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 @@ +<schema package="org.apache.qpid.cluster"> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + + <!-- Type information: + + Numeric types with "_wm" suffix are watermarked numbers. These are compound + values containing a current value, and a low and high water mark for the reporting + interval. The low and high water marks are set to the current value at the + beginning of each interval and track the minimum and maximum values of the statistic + over the interval respectively. + + Access rights for configuration elements: + + RO => Read Only + RC => Read/Create, can be set at create time only, read-only thereafter + RW => Read/Write + + If access rights are omitted for a property, they are assumed to be RO. + + --> + + <class name="cluster"> + <property name="brokerRef" type="objId" references="Broker" access="RC" index="y" parentRef="y"/> + <property name="clusterName" type="sstr" access="RC" desc="Name of cluster this server is a member of"/> + <property name="clusterID" type="sstr" access="RO" desc="Globally uniquie ID (UUID) for this cluster instance"/> + <property name="publishedURL" type="sstr" access="RO" desc="URL this node advertizes itself as"/> + <property name="clusterSize" type="uint16" access="RO" desc="Number of brokers currently in the cluster"/> + <property name="status" type="sstr" access="RO" desc="Cluster node status (STALLED,ACTIVE,JOINING)"/> + <property name="members" type="map" access="RO" desc="List of 'host:port' of member nodes in the cluster"/> + + + <method name="stopClusterNode"/> + <method name="stopFullCluster"/> + + </class> + + +</schema> + |
