diff options
| author | Ted Ross <tross@apache.org> | 2008-11-13 04:15:15 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2008-11-13 04:15:15 +0000 |
| commit | 45b4ce55e9bb52f9d753b9e61ec19f07dc9f5009 (patch) | |
| tree | 2e976b7d615f521ae5f8cdfb6432faaa6233402b /cpp/src/qpid/agent | |
| parent | 44d591ab8b7a1edf567ce6f2fba170cdf619ade1 (diff) | |
| download | qpid-python-45b4ce55e9bb52f9d753b9e61ec19f07dc9f5009.tar.gz | |
Updated qmf-agent API to allow user to specify uid, password, mechanism, and protocol.
Fixed qmf-console bug related to routing keys of object messages.
Pass the binding key into the management agent to allow for selective broadcast
of object data.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@713631 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/agent')
| -rw-r--r-- | cpp/src/qpid/agent/ManagementAgent.h | 22 | ||||
| -rw-r--r-- | cpp/src/qpid/agent/ManagementAgentImpl.cpp | 45 | ||||
| -rw-r--r-- | cpp/src/qpid/agent/ManagementAgentImpl.h | 27 |
3 files changed, 57 insertions, 37 deletions
diff --git a/cpp/src/qpid/agent/ManagementAgent.h b/cpp/src/qpid/agent/ManagementAgent.h index 03baa10aa2..296bb17e62 100644 --- a/cpp/src/qpid/agent/ManagementAgent.h +++ b/cpp/src/qpid/agent/ManagementAgent.h @@ -81,24 +81,28 @@ class ManagementAgent // storeFile - File where this process has read and write access. This // file shall be used to store persistent state. // - virtual void init (std::string brokerHost = "localhost", - uint16_t brokerPort = 5672, - uint16_t intervalSeconds = 10, - bool useExternalThread = false, - std::string storeFile = "") = 0; + virtual void init(const std::string& brokerHost = "localhost", + uint16_t brokerPort = 5672, + uint16_t intervalSeconds = 10, + bool useExternalThread = false, + const std::string& storeFile = "", + const std::string& uid = "guest", + const std::string& pwd = "guest", + const std::string& mech = "PLAIN", + const std::string& proto = "tcp") = 0; // Register a schema with the management agent. This is normally called by the // package initializer generated by the management code generator. // virtual void - registerClass(std::string& packageName, - std::string& className, + registerClass(const std::string& packageName, + const std::string& className, uint8_t* md5Sum, management::ManagementObject::writeSchemaCall_t schemaCall) = 0; virtual void - registerEvent(std::string& packageName, - std::string& eventName, + registerEvent(const std::string& packageName, + const std::string& eventName, uint8_t* md5Sum, management::ManagementEvent::writeSchemaCall_t schemaCall) = 0; diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/cpp/src/qpid/agent/ManagementAgentImpl.cpp index 06acf6b0e3..3f863d41d7 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.cpp +++ b/cpp/src/qpid/agent/ManagementAgentImpl.cpp @@ -80,7 +80,7 @@ const string ManagementAgentImpl::storeMagicNumber("MA02"); ManagementAgentImpl::ManagementAgentImpl() : extThread(false), writeFd(-1), readFd(-1), - connected(false), lastFailure("never connected"), + initialized(false), connected(false), lastFailure("never connected"), clientWasAdded(true), requestedBrokerBank(0), requestedAgentBank(0), assignedBrokerBank(0), assignedAgentBank(0), bootSequence(0), debugLevel(0), connThreadBody(*this), connThread(connThreadBody), @@ -102,18 +102,26 @@ ManagementAgentImpl::~ManagementAgentImpl() } } -void ManagementAgentImpl::init(string brokerHost, - uint16_t brokerPort, - uint16_t intervalSeconds, - bool useExternalThread, - string _storeFile) +void ManagementAgentImpl::init(const string& brokerHost, + uint16_t brokerPort, + uint16_t intervalSeconds, + bool useExternalThread, + const string& _storeFile, + const string& uid, + const string& pwd, + const string& mech, + const string& proto) { interval = intervalSeconds; extThread = useExternalThread; storeFile = _storeFile; nextObjectId = 1; - host = brokerHost; - port = brokerPort; + connectionSettings.protocol = proto; + connectionSettings.host = brokerHost; + connectionSettings.port = brokerPort; + connectionSettings.username = uid; + connectionSettings.password = pwd; + connectionSettings.mechanism = mech; if (debugLevel) cout << "QMF Agent Initialized: broker=" << brokerHost << ":" << brokerPort << @@ -139,10 +147,12 @@ void ManagementAgentImpl::init(string brokerHost, if ((bootSequence & 0xF000) != 0) bootSequence = 1; storeData(true); + + initialized = true; } -void ManagementAgentImpl::registerClass(string& packageName, - string& className, +void ManagementAgentImpl::registerClass(const string& packageName, + const string& className, uint8_t* md5Sum, management::ManagementObject::writeSchemaCall_t schemaCall) { @@ -151,8 +161,8 @@ void ManagementAgentImpl::registerClass(string& packageName, addClassLocal(ManagementItem::CLASS_KIND_TABLE, pIter, className, md5Sum, schemaCall); } -void ManagementAgentImpl::registerEvent(string& packageName, - string& eventName, +void ManagementAgentImpl::registerEvent(const string& packageName, + const string& eventName, uint8_t* md5Sum, management::ManagementObject::writeSchemaCall_t schemaCall) { @@ -605,7 +615,6 @@ void ManagementAgentImpl::periodicProcessing() Mutex::ScopedLock lock(agentLock); char msgChars[BUFSIZE]; uint32_t contentSize; - string routingKey; list<pair<ObjectId, ManagementObject*> > deleteList; if (!connected) @@ -692,8 +701,10 @@ void ManagementAgentImpl::periodicProcessing() contentSize = BUFSIZE - msgBuffer.available(); if (contentSize > 0) { msgBuffer.reset(); - routingKey = "console.obj." + baseObject->getPackageName() + "." + baseObject->getClassName(); - connThreadBody.sendBuffer(msgBuffer, contentSize, "qpid.management", routingKey); + stringstream key; + key << "console.obj." << baseObject->getPackageName() << "." << baseObject->getClassName() << "." << + assignedBrokerBank << "." << assignedAgentBank; + connThreadBody.sendBuffer(msgBuffer, contentSize, "qpid.management", key.str()); } } @@ -721,10 +732,10 @@ void ManagementAgentImpl::ConnectionThread::run() while (true) { try { - if (!agent.host.empty()) { + if (agent.initialized) { if (agent.debugLevel) cout << "QMF Agent attempting to connect to the broker..." << endl; - connection.open(agent.host.c_str(), agent.port); + connection.open(agent.connectionSettings); session = connection.newSession(queueName.str()); subscriptions = new client::SubscriptionManager(session); diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.h b/cpp/src/qpid/agent/ManagementAgentImpl.h index 5b6437944f..4ba9d7262a 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.h +++ b/cpp/src/qpid/agent/ManagementAgentImpl.h @@ -22,6 +22,7 @@ #include "ManagementAgent.h" #include "qpid/client/Connection.h" +#include "qpid/client/ConnectionSettings.h" #include "qpid/client/SubscriptionManager.h" #include "qpid/client/Session.h" #include "qpid/client/AsyncSession.h" @@ -49,19 +50,23 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen // Methods from ManagementAgent // int getMaxThreads() { return 1; } - void init(std::string brokerHost = "localhost", - uint16_t brokerPort = 5672, - uint16_t intervalSeconds = 10, - bool useExternalThread = false, - std::string storeFile = ""); + void init(const std::string& brokerHost = "localhost", + uint16_t brokerPort = 5672, + uint16_t intervalSeconds = 10, + bool useExternalThread = false, + const std::string& storeFile = "", + const std::string& uid = "guest", + const std::string& pwd = "guest", + const std::string& mech = "PLAIN", + const std::string& proto = "tcp"); bool isConnected() { return connected; } std::string& getLastFailure() { return lastFailure; } - void registerClass(std::string& packageName, - std::string& className, + void registerClass(const std::string& packageName, + const std::string& className, uint8_t* md5Sum, management::ManagementObject::writeSchemaCall_t schemaCall); - void registerEvent(std::string& packageName, - std::string& eventName, + void registerEvent(const std::string& packageName, + const std::string& eventName, uint8_t* md5Sum, management::ManagementObject::writeSchemaCall_t schemaCall); ObjectId addObject(management::ManagementObject* objectPtr, uint64_t persistId = 0); @@ -130,8 +135,8 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen sys::Mutex agentLock; sys::Mutex addLock; framing::Uuid systemId; - std::string host; - uint16_t port; + client::ConnectionSettings connectionSettings; + bool initialized; bool connected; std::string lastFailure; |
