diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2007-10-31 20:06:05 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2007-10-31 20:06:05 +0000 |
commit | d4d4a9f2ba6b9c457eba9c5ae0b5939d72bd2743 (patch) | |
tree | 7227ba7db88228237defe3f8486847aeb683923c /cpp/src | |
parent | 7990138bb3eb014c85bfb806c91e23def530ef37 (diff) | |
download | qpid-python-d4d4a9f2ba6b9c457eba9c5ae0b5939d72bd2743.tar.gz |
Patch from Ted
QPID-668
This patch does two things:
1) Adds management objects for "broker" and "virtual host".
2) Moves all management-related source files from qpid/broker to qpid/broker/management.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@590806 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
19 files changed, 339 insertions, 29 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index b6337f615c..0a91147652 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -159,10 +159,12 @@ libqpidbroker_la_SOURCES = \ qpid/broker/FanOutExchange.cpp \ qpid/broker/HeadersExchange.cpp \ qpid/broker/IncomingExecutionContext.cpp \ - qpid/broker/ManagementAgent.cpp \ - qpid/broker/ManagementExchange.cpp \ - qpid/broker/ManagementObject.cpp \ - qpid/broker/ManagementObjectQueue.cpp \ + qpid/broker/management/ManagementAgent.cpp \ + qpid/broker/management/ManagementExchange.cpp \ + qpid/broker/management/ManagementObject.cpp \ + qpid/broker/management/ManagementObjectBroker.cpp \ + qpid/broker/management/ManagementObjectQueue.cpp \ + qpid/broker/management/ManagementObjectVhost.cpp \ qpid/broker/Message.cpp \ qpid/broker/MessageAdapter.cpp \ qpid/broker/MessageBuilder.cpp \ @@ -256,10 +258,12 @@ nobase_include_HEADERS = \ qpid/broker/HandlerImpl.h \ qpid/broker/HeadersExchange.h \ qpid/broker/IncomingExecutionContext.h \ - qpid/broker/ManagementAgent.h \ - qpid/broker/ManagementExchange.h \ - qpid/broker/ManagementObject.h \ - qpid/broker/ManagementObjectQueue.h \ + qpid/broker/management/ManagementAgent.h \ + qpid/broker/management/ManagementExchange.h \ + qpid/broker/management/ManagementObject.h \ + qpid/broker/management/ManagementObjectBroker.h \ + qpid/broker/management/ManagementObjectQueue.h \ + qpid/broker/management/ManagementObjectVhost.h \ qpid/broker/Message.h \ qpid/broker/MessageAdapter.h \ qpid/broker/MessageBuilder.h \ diff --git a/cpp/src/qpid/broker/Broker.cpp b/cpp/src/qpid/broker/Broker.cpp index 051c872e77..01f8a04545 100644 --- a/cpp/src/qpid/broker/Broker.cpp +++ b/cpp/src/qpid/broker/Broker.cpp @@ -28,7 +28,7 @@ #include "NullMessageStore.h" #include "RecoveryManagerImpl.h" #include "TopicExchange.h" -#include "ManagementExchange.h" +#include "management/ManagementExchange.h" #include "qpid/log/Statement.h" #include "qpid/Url.h" @@ -125,6 +125,14 @@ Broker::Broker(const Broker::Options& conf) : Exchange::shared_ptr mExchange = exchanges.get (qpid_management); managementAgent->setExchange (mExchange); dynamic_pointer_cast<ManagementExchange>(mExchange)->setManagmentAgent (managementAgent); + + mgmtObject = ManagementObjectBroker::shared_ptr (new ManagementObjectBroker (conf)); + managementAgent->addObject (dynamic_pointer_cast<ManagementObject>(mgmtObject)); + + // Since there is currently no support for virtual hosts, a management object + // representing the implied single virtual host is added here. + mgmtVhostObject = ManagementObjectVhost::shared_ptr (new ManagementObjectVhost (conf)); + managementAgent->addObject (dynamic_pointer_cast<ManagementObject>(mgmtVhostObject)); } else QPID_LOG(info, "Management not enabled"); diff --git a/cpp/src/qpid/broker/Broker.h b/cpp/src/qpid/broker/Broker.h index 817197a351..5a67fb7212 100644 --- a/cpp/src/qpid/broker/Broker.h +++ b/cpp/src/qpid/broker/Broker.h @@ -30,7 +30,9 @@ #include "MessageStore.h" #include "QueueRegistry.h" #include "SessionManager.h" -#include "ManagementAgent.h" +#include "management/ManagementAgent.h" +#include "management/ManagementObjectBroker.h" +#include "management/ManagementObjectVhost.h" #include "qpid/Options.h" #include "qpid/Plugin.h" #include "qpid/Url.h" @@ -65,10 +67,10 @@ class Broker : public sys::Runnable, public Plugin::Target int connectionBacklog; std::string store; long stagingThreshold; - string storeDir; - bool storeAsync; - bool enableMgmt; - uint16_t mgmtPubInterval; + string storeDir; + bool storeAsync; + bool enableMgmt; + uint16_t mgmtPubInterval; uint32_t ack; }; @@ -129,6 +131,8 @@ class Broker : public sys::Runnable, public Plugin::Target HandlerUpdaters handlerUpdaters; SessionManager sessionManager; ManagementAgent::shared_ptr managementAgent; + ManagementObjectBroker::shared_ptr mgmtObject; + ManagementObjectVhost::shared_ptr mgmtVhostObject; static MessageStore* createStore(const Options& config); }; diff --git a/cpp/src/qpid/broker/ExchangeRegistry.cpp b/cpp/src/qpid/broker/ExchangeRegistry.cpp index 98e3cc7347..35660cfa0b 100644 --- a/cpp/src/qpid/broker/ExchangeRegistry.cpp +++ b/cpp/src/qpid/broker/ExchangeRegistry.cpp @@ -23,7 +23,7 @@ #include "FanOutExchange.h" #include "HeadersExchange.h" #include "TopicExchange.h" -#include "ManagementExchange.h" +#include "management/ManagementExchange.h" #include "qpid/framing/reply_exceptions.h" using namespace qpid::broker; diff --git a/cpp/src/qpid/broker/Queue.h b/cpp/src/qpid/broker/Queue.h index 17f2d8ba91..f247312b60 100644 --- a/cpp/src/qpid/broker/Queue.h +++ b/cpp/src/qpid/broker/Queue.h @@ -35,7 +35,7 @@ #include "PersistableQueue.h" #include "QueuePolicy.h" #include "QueueBindings.h" -#include "ManagementObjectQueue.h" +#include "management/ManagementObjectQueue.h" namespace qpid { namespace broker { diff --git a/cpp/src/qpid/broker/QueueRegistry.cpp b/cpp/src/qpid/broker/QueueRegistry.cpp index bc572e4238..31eab33fe2 100644 --- a/cpp/src/qpid/broker/QueueRegistry.cpp +++ b/cpp/src/qpid/broker/QueueRegistry.cpp @@ -19,8 +19,8 @@ * */ #include "QueueRegistry.h" -#include "ManagementAgent.h" -#include "ManagementObjectQueue.h" +#include "management/ManagementAgent.h" +#include "management/ManagementObjectQueue.h" #include "qpid/log/Statement.h" #include <sstream> #include <assert.h> diff --git a/cpp/src/qpid/broker/QueueRegistry.h b/cpp/src/qpid/broker/QueueRegistry.h index 03b4778f7a..8dc5539051 100644 --- a/cpp/src/qpid/broker/QueueRegistry.h +++ b/cpp/src/qpid/broker/QueueRegistry.h @@ -24,7 +24,7 @@ #include <map> #include "qpid/sys/Mutex.h" #include "Queue.h" -#include "ManagementAgent.h" +#include "management/ManagementAgent.h" namespace qpid { namespace broker { diff --git a/cpp/src/qpid/broker/ManagementAgent.cpp b/cpp/src/qpid/broker/management/ManagementAgent.cpp index 2f6a0597f0..1121b7bc6b 100644 --- a/cpp/src/qpid/broker/ManagementAgent.cpp +++ b/cpp/src/qpid/broker/management/ManagementAgent.cpp @@ -20,7 +20,7 @@ */ #include "ManagementAgent.h" -#include "DeliverableMessage.h" +#include "qpid/broker/DeliverableMessage.h" #include "qpid/log/Statement.h" #include <qpid/broker/Message.h> #include <qpid/broker/MessageDelivery.h> @@ -181,7 +181,6 @@ void ManagementAgent::PeriodicProcessing (void) MessageProperties* props = msg->getFrames().getHeaders()->get<MessageProperties>(true); props->setContentLength(contentSize); - //msg->getFrames().getHeaders()->get<DeliveryProperties>(true)->setRoutingKey("mgmt"); msg->getFrames().append(content); DeliverableMessage deliverable (msg); diff --git a/cpp/src/qpid/broker/ManagementAgent.h b/cpp/src/qpid/broker/management/ManagementAgent.h index e1d62270db..c3cfa58291 100644 --- a/cpp/src/qpid/broker/ManagementAgent.h +++ b/cpp/src/qpid/broker/management/ManagementAgent.h @@ -23,9 +23,9 @@ */ #include "qpid/Options.h" -#include "Exchange.h" +#include "qpid/broker/Exchange.h" +#include "qpid/broker/Timer.h" #include "ManagementObject.h" -#include "Timer.h" #include <boost/shared_ptr.hpp> namespace qpid { diff --git a/cpp/src/qpid/broker/ManagementExchange.cpp b/cpp/src/qpid/broker/management/ManagementExchange.cpp index 5d829477ba..5d829477ba 100644 --- a/cpp/src/qpid/broker/ManagementExchange.cpp +++ b/cpp/src/qpid/broker/management/ManagementExchange.cpp diff --git a/cpp/src/qpid/broker/ManagementExchange.h b/cpp/src/qpid/broker/management/ManagementExchange.h index 56c051a7f8..c38f38d0a1 100644 --- a/cpp/src/qpid/broker/ManagementExchange.h +++ b/cpp/src/qpid/broker/management/ManagementExchange.h @@ -21,7 +21,7 @@ #ifndef _ManagementExchange_ #define _ManagementExchange_ -#include "TopicExchange.h" +#include "qpid/broker/TopicExchange.h" #include "ManagementAgent.h" namespace qpid { diff --git a/cpp/src/qpid/broker/ManagementObject.cpp b/cpp/src/qpid/broker/management/ManagementObject.cpp index c536d96b1b..c536d96b1b 100644 --- a/cpp/src/qpid/broker/ManagementObject.cpp +++ b/cpp/src/qpid/broker/management/ManagementObject.cpp diff --git a/cpp/src/qpid/broker/ManagementObject.h b/cpp/src/qpid/broker/management/ManagementObject.h index 237f2f3d79..107da62e67 100644 --- a/cpp/src/qpid/broker/ManagementObject.h +++ b/cpp/src/qpid/broker/management/ManagementObject.h @@ -92,9 +92,9 @@ class ManagementObject virtual bool getSchemaNeeded (void) = 0; virtual void setSchemaNeeded (void) = 0; - inline bool getConfigChanged (void) { return configChanged; } - inline bool getInstChanged (void) { return instChanged; } - inline void setAllChanged (void) + inline bool getConfigChanged (void) { return configChanged; } + virtual bool getInstChanged (void) { return instChanged; } + inline void setAllChanged (void) { configChanged = true; instChanged = true; diff --git a/cpp/src/qpid/broker/management/ManagementObjectBroker.cpp b/cpp/src/qpid/broker/management/ManagementObjectBroker.cpp new file mode 100644 index 0000000000..378017d5a8 --- /dev/null +++ b/cpp/src/qpid/broker/management/ManagementObjectBroker.cpp @@ -0,0 +1,98 @@ +/* + * + * 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. + * + */ + +#include "config.h" +#include "qpid/broker/Broker.h" +#include "ManagementObjectBroker.h" + +using namespace qpid::broker; +using namespace qpid::sys; +using namespace qpid::framing; + +bool ManagementObjectBroker::schemaNeeded = true; + +ManagementObjectBroker::ManagementObjectBroker (const Options& _conf) +{ + Broker::Options& conf = (Broker::Options&) _conf; + + sysId = "sysId"; + port = conf.port; + workerThreads = conf.workerThreads; + maxConns = conf.maxConnections; + connBacklog = conf.connectionBacklog; + stagingThreshold = conf.stagingThreshold; + storeLib = conf.store; + asyncStore = conf.storeAsync; + mgmtPubInterval = conf.mgmtPubInterval; + initialDiskPageSize = 0; + initialPagesPerQueue = 0; + clusterName = ""; + version = PACKAGE_VERSION; +} + +ManagementObjectBroker::~ManagementObjectBroker () {} + +void ManagementObjectBroker::writeSchema (Buffer& buf) +{ + schemaNeeded = false; + + schemaItem (buf, TYPE_STRING, "sysId", "System ID", true, true); + schemaItem (buf, TYPE_UINT16, "port", "TCP Port for AMQP Service", true); + schemaItem (buf, TYPE_UINT16, "workerThreads", "Thread pool size", true); + schemaItem (buf, TYPE_UINT16, "maxConns", "Maximum allowed connections", true); + schemaItem (buf, TYPE_UINT16, "connBacklog", + "Connection backlog limit for listening socket", true); + schemaItem (buf, TYPE_UINT32, "stagingThreshold", + "Broker stages messages over this size to disk", true); + schemaItem (buf, TYPE_STRING, "storeLib", "Name of persistent storage library", true); + schemaItem (buf, TYPE_UINT8, "asyncStore", "Use async persistent store", true); + schemaItem (buf, TYPE_UINT16, "mgmtPubInterval", "Interval for management broadcasts", true); + schemaItem (buf, TYPE_UINT32, "initialDiskPageSize", + "Number of disk pages allocated for storage", true); + schemaItem (buf, TYPE_UINT32, "initialPagesPerQueue", + "Number of disk pages allocated per queue", true); + schemaItem (buf, TYPE_STRING, "clusterName", + "Name of cluster this server is a member of, zero-length for standalone server", true); + schemaItem (buf, TYPE_STRING, "version", "Running software version", true); + + schemaListEnd (buf); +} + +void ManagementObjectBroker::writeConfig (Buffer& buf) +{ + configChanged = false; + + writeTimestamps (buf); + buf.putShortString (sysId); + buf.putShort (port); + buf.putShort (workerThreads); + buf.putShort (maxConns); + buf.putShort (connBacklog); + buf.putLong (stagingThreshold); + buf.putShortString (storeLib); + buf.putOctet (asyncStore ? 1 : 0); + buf.putShort (mgmtPubInterval); + buf.putLong (initialDiskPageSize); + buf.putLong (initialPagesPerQueue); + buf.putShortString (clusterName); + buf.putShortString (version); +} + diff --git a/cpp/src/qpid/broker/management/ManagementObjectBroker.h b/cpp/src/qpid/broker/management/ManagementObjectBroker.h new file mode 100644 index 0000000000..f83df061af --- /dev/null +++ b/cpp/src/qpid/broker/management/ManagementObjectBroker.h @@ -0,0 +1,75 @@ +#ifndef _ManagementObjectBroker_ +#define _ManagementObjectBroker_ + +/* + * + * 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. + * + */ + +#include "ManagementObject.h" +#include "qpid/Options.h" +#include "boost/shared_ptr.hpp" + +namespace qpid { +namespace broker { + +class ManagementObjectBroker : public ManagementObject +{ + public: + + typedef boost::shared_ptr<ManagementObjectBroker> shared_ptr; + + ManagementObjectBroker (const Options& conf); + ~ManagementObjectBroker (void); + + private: + + static bool schemaNeeded; + + std::string objectName; + + std::string sysId; + uint16_t port; + uint16_t workerThreads; + uint16_t maxConns; + uint16_t connBacklog; + uint32_t stagingThreshold; + std::string storeLib; + bool asyncStore; + uint16_t mgmtPubInterval; + uint32_t initialDiskPageSize; + uint32_t initialPagesPerQueue; + std::string clusterName; + std::string version; + + uint16_t getObjectType (void) { return OBJECT_BROKER; } + std::string getObjectName (void) { return objectName; } + void writeSchema (Buffer& buf); + void writeConfig (Buffer& buf); + void writeInstrumentation (Buffer& /*buf*/) {} + bool getSchemaNeeded (void) { return schemaNeeded; } + void setSchemaNeeded (void) { schemaNeeded = true; } + + inline bool getInstChanged (void) { return false; } +}; + +}} + + +#endif /*!_ManagementObjectBroker_*/ diff --git a/cpp/src/qpid/broker/ManagementObjectQueue.cpp b/cpp/src/qpid/broker/management/ManagementObjectQueue.cpp index d30cda03a4..70913ea910 100644 --- a/cpp/src/qpid/broker/ManagementObjectQueue.cpp +++ b/cpp/src/qpid/broker/management/ManagementObjectQueue.cpp @@ -27,8 +27,9 @@ using namespace qpid::framing; bool ManagementObjectQueue::schemaNeeded = true; -ManagementObjectQueue::ManagementObjectQueue (std::string& _name, bool _durable, bool _autoDelete) : - name(_name), durable(_durable), autoDelete(_autoDelete) +ManagementObjectQueue::ManagementObjectQueue (std::string& _name, + bool _durable, bool _autoDelete) : + vhostName("/"), name(_name), durable(_durable), autoDelete(_autoDelete) { msgTotalEnqueues = 0; msgTotalDequeues = 0; @@ -78,6 +79,7 @@ void ManagementObjectQueue::writeSchema (Buffer& buf) { schemaNeeded = false; + schemaItem (buf, TYPE_STRING, "vhostRef", "Virtual Host Ref", true, true); schemaItem (buf, TYPE_STRING, "name", "Queue Name", true, true); schemaItem (buf, TYPE_BOOL, "durable", "Durable", true); schemaItem (buf, TYPE_BOOL, "autoDelete", "AutoDelete", true); @@ -124,6 +126,7 @@ void ManagementObjectQueue::writeConfig (Buffer& buf) configChanged = false; writeTimestamps (buf); + buf.putShortString (vhostName); buf.putShortString (name); buf.putOctet (durable ? 1 : 0); buf.putOctet (autoDelete ? 1 : 0); @@ -134,6 +137,7 @@ void ManagementObjectQueue::writeInstrumentation (Buffer& buf) instChanged = false; writeTimestamps (buf); + buf.putShortString (vhostName); buf.putShortString (name); buf.putLongLong (msgTotalEnqueues); buf.putLongLong (msgTotalDequeues); diff --git a/cpp/src/qpid/broker/ManagementObjectQueue.h b/cpp/src/qpid/broker/management/ManagementObjectQueue.h index cb2d399b76..4a0608c7d0 100644 --- a/cpp/src/qpid/broker/ManagementObjectQueue.h +++ b/cpp/src/qpid/broker/management/ManagementObjectQueue.h @@ -37,6 +37,7 @@ class ManagementObjectQueue : public ManagementObject static bool schemaNeeded; std::string objectName; + std::string vhostName; std::string name; bool durable; bool autoDelete; diff --git a/cpp/src/qpid/broker/management/ManagementObjectVhost.cpp b/cpp/src/qpid/broker/management/ManagementObjectVhost.cpp new file mode 100644 index 0000000000..25a2200106 --- /dev/null +++ b/cpp/src/qpid/broker/management/ManagementObjectVhost.cpp @@ -0,0 +1,54 @@ +/* + * + * 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. + * + */ + +#include "qpid/broker/Broker.h" +#include "ManagementObjectVhost.h" + +using namespace qpid::broker; +using namespace qpid::sys; +using namespace qpid::framing; + +bool ManagementObjectVhost::schemaNeeded = true; + +ManagementObjectVhost::ManagementObjectVhost (const Options& /*_conf*/) +{ + name = "/"; +} + +ManagementObjectVhost::~ManagementObjectVhost () {} + +void ManagementObjectVhost::writeSchema (Buffer& buf) +{ + schemaNeeded = false; + + schemaItem (buf, TYPE_STRING, "name", "Name of virtual host", true, true); + + schemaListEnd (buf); +} + +void ManagementObjectVhost::writeConfig (Buffer& buf) +{ + configChanged = false; + + writeTimestamps (buf); + buf.putShortString (name); +} + diff --git a/cpp/src/qpid/broker/management/ManagementObjectVhost.h b/cpp/src/qpid/broker/management/ManagementObjectVhost.h new file mode 100644 index 0000000000..77ac4eea38 --- /dev/null +++ b/cpp/src/qpid/broker/management/ManagementObjectVhost.h @@ -0,0 +1,63 @@ +#ifndef _ManagementObjectVhost_ +#define _ManagementObjectVhost_ + +/* + * + * 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. + * + */ + +#include "ManagementObject.h" +#include "qpid/Options.h" +#include "boost/shared_ptr.hpp" + +namespace qpid { +namespace broker { + +class ManagementObjectVhost : public ManagementObject +{ + public: + + typedef boost::shared_ptr<ManagementObjectVhost> shared_ptr; + + ManagementObjectVhost (const Options& conf); + ~ManagementObjectVhost (void); + + private: + + static bool schemaNeeded; + + std::string objectName; + + std::string name; + + uint16_t getObjectType (void) { return OBJECT_VHOST; } + std::string getObjectName (void) { return objectName; } + void writeSchema (Buffer& buf); + void writeConfig (Buffer& buf); + void writeInstrumentation (Buffer& /*buf*/) {} + bool getSchemaNeeded (void) { return schemaNeeded; } + void setSchemaNeeded (void) { schemaNeeded = true; } + + inline bool getInstChanged (void) { return false; } +}; + +}} + + +#endif /*!_ManagementObjectVhost_*/ |