summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/management
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-12-06 18:37:18 +0000
committerAlan Conway <aconway@apache.org>2007-12-06 18:37:18 +0000
commitf03223296e70664d3ecd57df357e71202c79eff7 (patch)
tree7d0b5b8bcb6be11ef3294d04c198b4e5e7981fce /cpp/src/qpid/management
parent430e644a4a647c256ae51682d7230c35d954073e (diff)
downloadqpid-python-f03223296e70664d3ecd57df357e71202c79eff7.tar.gz
From Ted Ross <tross@redhat.com>
Queue statistics fixed. Additional objects added (exchange, binding). Changes: M cpp/src/qpid/broker/ExchangeRegistry.h M cpp/src/qpid/broker/ExchangeRegistry.cpp ExchangeRegistry was modified to pass a parent pointer to created exchanges. This parent reference is not stored but is used to link management objects in a hierarchy of ownership. M cpp/src/qpid/broker/Exchange.h M cpp/src/qpid/broker/Exchange.cpp Exchange now inherits Manageable to make it visible via the management interface. The Exchange parent class handles most of the management boilerplate. A Binding struct was introduced to track bindings for management. This is separate from QueueBindings which track bindings for queues. M cpp/src/qpid/broker/HeadersExchange.h M cpp/src/qpid/broker/FanOutExchange.h M cpp/src/qpid/broker/DirectExchange.h M cpp/src/qpid/broker/TopicExchange.h M cpp/src/qpid/broker/HeadersExchange.cpp M cpp/src/qpid/broker/FanOutExchange.cpp M cpp/src/qpid/broker/DirectExchange.cpp M cpp/src/qpid/broker/TopicExchange.cpp M cpp/src/qpid/management/ManagementExchange.cpp M cpp/src/qpid/management/ManagementExchange.h Each exchange type handles management stats in its own specific way. Additionally, the constructors pass the management parent pointer to the constructor or Exchange. An extra layer was added to contain bindings. Instead of directly storing bound queues, the exchanges store "bindings" which are managable constructs. M cpp/src/qpid/broker/Broker.cpp Broker now explicitly enables the management agent. Also sets the management parent (vhost) in the exchange registry. M cpp/src/qpid/broker/Vhost.cpp Updated constructor to be more defensive in case the management agent has not been enabled. M cpp/src/qpid/broker/Queue.cpp Same constructor update as vhost. Moved accounting of dequeues into "pop". Implemented management method handler (purge). M cpp/src/qpid/broker/Deliverable.h A new method was added to extract the content size of the deliverable content (if appropriate). The method is not pure virtual and returns zero if not overridden. M cpp/src/qpid/broker/DeliverableMessage.h M cpp/src/qpid/broker/TxPublish.cpp M cpp/src/qpid/broker/DeliverableMessage.cpp M cpp/src/qpid/broker/TxPublish.h These derivatives of Deliverable were updated with overrides for contenSize. M cpp/src/qpid/management/ManagementAgent.h M cpp/src/qpid/management/ManagementAgent.cpp An "enable" method was added to prevent inadvertent creation of a management agent when not desired. Adding and deleting management objects is now protected by a mutex. Make sure that deleted objects get reported even if neither their configuration nor instrumentation is changed. M specs/management-schema.xml Minor cosmetic updates. Additional parent linkage. M cpp/managementgen/schema.py M cpp/managementgen/templates/Class.cpp Added generated code to publish schema details for methods. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@601807 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/management')
-rw-r--r--cpp/src/qpid/management/ManagementAgent.cpp26
-rw-r--r--cpp/src/qpid/management/ManagementAgent.h9
-rw-r--r--cpp/src/qpid/management/ManagementExchange.cpp11
-rw-r--r--cpp/src/qpid/management/ManagementExchange.h5
4 files changed, 34 insertions, 17 deletions
diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp
index 85c2acce1d..90da74404b 100644
--- a/cpp/src/qpid/management/ManagementAgent.cpp
+++ b/cpp/src/qpid/management/ManagementAgent.cpp
@@ -33,6 +33,7 @@ using namespace qpid::broker;
using namespace qpid::sys;
ManagementAgent::shared_ptr ManagementAgent::agent;
+bool ManagementAgent::enabled = 0;
ManagementAgent::ManagementAgent (uint16_t _interval) : interval (_interval)
{
@@ -40,16 +41,21 @@ ManagementAgent::ManagementAgent (uint16_t _interval) : interval (_interval)
nextObjectId = uint64_t (qpid::sys::Duration (qpid::sys::now ()));
}
+void ManagementAgent::enableManagement (void)
+{
+ enabled = 1;
+}
+
ManagementAgent::shared_ptr ManagementAgent::getAgent (void)
{
- if (agent.get () == 0)
+ if (enabled && agent.get () == 0)
agent = shared_ptr (new ManagementAgent (10));
return agent;
}
-void ManagementAgent::setExchange (Exchange::shared_ptr _mexchange,
- Exchange::shared_ptr _dexchange)
+void ManagementAgent::setExchange (broker::Exchange::shared_ptr _mexchange,
+ broker::Exchange::shared_ptr _dexchange)
{
mExchange = _mexchange;
dExchange = _dexchange;
@@ -57,6 +63,7 @@ void ManagementAgent::setExchange (Exchange::shared_ptr _mexchange,
void ManagementAgent::addObject (ManagementObject::shared_ptr object)
{
+ RWlock::ScopedWlock writeLock (userLock);
uint64_t objectId = nextObjectId++;
object->setObjectId (objectId);
@@ -74,6 +81,8 @@ void ManagementAgent::Periodic::fire ()
void ManagementAgent::clientAdded (void)
{
+ RWlock::ScopedRlock readLock (userLock);
+
for (ManagementObjectMap::iterator iter = managementObjects.begin ();
iter != managementObjects.end ();
iter++)
@@ -94,7 +103,7 @@ void ManagementAgent::EncodeHeader (Buffer& buf)
void ManagementAgent::SendBuffer (Buffer& buf,
uint32_t length,
- Exchange::shared_ptr exchange,
+ broker::Exchange::shared_ptr exchange,
string routingKey)
{
intrusive_ptr<Message> msg (new Message ());
@@ -129,9 +138,10 @@ void ManagementAgent::PeriodicProcessing (void)
{
#define BUFSIZE 65536
#define THRESHOLD 16384
- char msgChars[BUFSIZE];
- uint32_t contentSize;
- string routingKey;
+ RWlock::ScopedWlock writeLock (userLock);
+ char msgChars[BUFSIZE];
+ uint32_t contentSize;
+ string routingKey;
std::list<uint64_t> deleteList;
if (managementObjects.empty ())
@@ -157,7 +167,7 @@ void ManagementAgent::PeriodicProcessing (void)
SendBuffer (msgBuffer, contentSize, mExchange, routingKey);
}
- if (object->getConfigChanged ())
+ if (object->getConfigChanged () || object->isDeleted ())
{
Buffer msgBuffer (msgChars, BUFSIZE);
EncodeHeader (msgBuffer);
diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h
index c33a59adff..a4f10632da 100644
--- a/cpp/src/qpid/management/ManagementAgent.h
+++ b/cpp/src/qpid/management/ManagementAgent.h
@@ -25,6 +25,7 @@
#include "qpid/Options.h"
#include "qpid/broker/Exchange.h"
#include "qpid/broker/Timer.h"
+#include "qpid/sys/Mutex.h"
#include "ManagementObject.h"
#include <boost/shared_ptr.hpp>
@@ -41,11 +42,12 @@ class ManagementAgent
typedef boost::shared_ptr<ManagementAgent> shared_ptr;
+ static void enableManagement (void);
static shared_ptr getAgent (void);
void setInterval (uint16_t _interval) { interval = _interval; }
- void setExchange (broker::Exchange::shared_ptr mgmtExchange,
- broker::Exchange::shared_ptr directExchange);
+ void setExchange (broker::Exchange::shared_ptr mgmtExchange,
+ broker::Exchange::shared_ptr directExchange);
void addObject (ManagementObject::shared_ptr object);
void clientAdded (void);
void dispatchCommand (broker::Deliverable& msg,
@@ -64,6 +66,9 @@ class ManagementAgent
};
static shared_ptr agent;
+ static bool enabled;
+
+ qpid::sys::RWlock userLock;
ManagementObjectMap managementObjects;
broker::Timer timer;
broker::Exchange::shared_ptr mExchange;
diff --git a/cpp/src/qpid/management/ManagementExchange.cpp b/cpp/src/qpid/management/ManagementExchange.cpp
index f18b6fc402..ee18f026e7 100644
--- a/cpp/src/qpid/management/ManagementExchange.cpp
+++ b/cpp/src/qpid/management/ManagementExchange.cpp
@@ -27,13 +27,14 @@ using namespace qpid::broker;
using namespace qpid::framing;
using namespace qpid::sys;
-ManagementExchange::ManagementExchange (const string& _name) :
- Exchange (_name), TopicExchange(_name) {}
+ManagementExchange::ManagementExchange (const string& _name, Manageable* _parent) :
+ Exchange (_name, _parent), TopicExchange(_name, _parent) {}
ManagementExchange::ManagementExchange (const std::string& _name,
bool _durable,
- const FieldTable& _args) :
- Exchange (_name, _durable, _args),
- TopicExchange(_name, _durable, _args) {}
+ const FieldTable& _args,
+ Manageable* _parent) :
+ Exchange (_name, _durable, _args, _parent),
+ TopicExchange(_name, _durable, _args, _parent) {}
bool ManagementExchange::bind (Queue::shared_ptr queue,
diff --git a/cpp/src/qpid/management/ManagementExchange.h b/cpp/src/qpid/management/ManagementExchange.h
index 6ccdf47182..0fcd65b092 100644
--- a/cpp/src/qpid/management/ManagementExchange.h
+++ b/cpp/src/qpid/management/ManagementExchange.h
@@ -35,9 +35,10 @@ class ManagementExchange : public virtual TopicExchange
public:
static const std::string typeName;
- ManagementExchange (const string& name);
+ ManagementExchange (const string& name, Manageable* _parent = 0);
ManagementExchange (const string& _name, bool _durable,
- const qpid::framing::FieldTable& _args);
+ const qpid::framing::FieldTable& _args,
+ Manageable* _parent = 0);
virtual std::string getType() const { return typeName; }