summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/qpid/agent/ManagementAgent.h10
-rw-r--r--cpp/include/qpid/management/ManagementObject.h4
-rw-r--r--cpp/src/qpid/agent/ManagementAgentImpl.cpp15
-rw-r--r--cpp/src/qpid/agent/ManagementAgentImpl.h2
-rw-r--r--cpp/src/qpid/management/ManagementAgent.cpp20
-rw-r--r--cpp/src/qpid/management/ManagementAgent.h3
-rw-r--r--cpp/src/tests/ManagementTest.cpp7
7 files changed, 61 insertions, 0 deletions
diff --git a/cpp/include/qpid/agent/ManagementAgent.h b/cpp/include/qpid/agent/ManagementAgent.h
index aa0a974c35..e2451244c1 100644
--- a/cpp/include/qpid/agent/ManagementAgent.h
+++ b/cpp/include/qpid/agent/ManagementAgent.h
@@ -75,6 +75,16 @@ class ManagementAgent
const std::string& product,
const std::string& instance="") = 0;
+ // Retrieve the name of the agent as assigned by setName()
+ //
+ virtual void getName(std::string& vendor,
+ std::string& product,
+ std::string& instance) = 0;
+
+ // Obtain the fully qualified name of the agent
+ //
+ virtual const std::string& getAddress() = 0;
+
// Connect to a management broker
//
// brokerHost - Hostname or IP address (dotted-quad) of broker.
diff --git a/cpp/include/qpid/management/ManagementObject.h b/cpp/include/qpid/management/ManagementObject.h
index 6bbd7ec407..59a7f00603 100644
--- a/cpp/include/qpid/management/ManagementObject.h
+++ b/cpp/include/qpid/management/ManagementObject.h
@@ -65,6 +65,10 @@ public:
QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq);
QPID_COMMON_EXTERN ObjectId(std::istream&);
QPID_COMMON_EXTERN ObjectId(const std::string&);
+ QPID_COMMON_EXTERN ObjectId(const std::string& agentAddress, const std::string& key,
+ uint64_t epoch=0) : agent(0), first(0), second(0),
+ agentEpoch(epoch), v2Key(key), agentName(agentAddress) {}
+
// Deprecated:
QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint64_t object);
QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const;
diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/cpp/src/qpid/agent/ManagementAgentImpl.cpp
index bc841ca3ee..351e0bfd00 100644
--- a/cpp/src/qpid/agent/ManagementAgentImpl.cpp
+++ b/cpp/src/qpid/agent/ManagementAgentImpl.cpp
@@ -144,6 +144,21 @@ void ManagementAgentImpl::setName(const string& vendor, const string& product, c
attrMap["_name"] = name_address;
}
+
+void ManagementAgentImpl::getName(string& vendor, string& product, string& instance)
+{
+ vendor = std::string(attrMap["_vendor"]);
+ product = std::string(attrMap["_product"]);
+ instance = std::string(attrMap["_instance"]);
+}
+
+
+const std::string& ManagementAgentImpl::getAddress()
+{
+ return name_address;
+}
+
+
void ManagementAgentImpl::init(const string& brokerHost,
uint16_t brokerPort,
uint16_t intervalSeconds,
diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.h b/cpp/src/qpid/agent/ManagementAgentImpl.h
index 7d4531f1b8..4a58807e98 100644
--- a/cpp/src/qpid/agent/ManagementAgentImpl.h
+++ b/cpp/src/qpid/agent/ManagementAgentImpl.h
@@ -54,6 +54,8 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen
void setName(const std::string& vendor,
const std::string& product,
const std::string& instance="");
+ void getName(std::string& vendor, std::string& product, std::string& instance);
+ const std::string& getAddress();
void init(const std::string& brokerHost = "localhost",
uint16_t brokerPort = 5672,
uint16_t intervalSeconds = 10,
diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp
index 8818a4c3ac..9e4e9665ac 100644
--- a/cpp/src/qpid/management/ManagementAgent.cpp
+++ b/cpp/src/qpid/management/ManagementAgent.cpp
@@ -197,6 +197,12 @@ void ManagementAgent::pluginsInitialized() {
void ManagementAgent::setName(const string& vendor, const string& product, const string& instance)
{
+ if (vendor.find(':') != vendor.npos) {
+ throw Exception("vendor string cannot contain a ':' character.");
+ }
+ if (product.find(':') != product.npos) {
+ throw Exception("product string cannot contain a ':' character.");
+ }
attrMap["_vendor"] = vendor;
attrMap["_product"] = product;
string inst;
@@ -218,6 +224,20 @@ void ManagementAgent::setName(const string& vendor, const string& product, const
}
+void ManagementAgent::getName(string& vendor, string& product, string& instance)
+{
+ vendor = std::string(attrMap["_vendor"]);
+ product = std::string(attrMap["_product"]);
+ instance = std::string(attrMap["_instance"]);
+}
+
+
+const std::string& ManagementAgent::getAddress()
+{
+ return name_address;
+}
+
+
void ManagementAgent::writeData ()
{
string filename (dataDir + "/.mbrokerdata");
diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h
index 44e3eb1a35..a6e906e2a8 100644
--- a/cpp/src/qpid/management/ManagementAgent.h
+++ b/cpp/src/qpid/management/ManagementAgent.h
@@ -77,6 +77,9 @@ public:
void setName(const std::string& vendor,
const std::string& product,
const std::string& instance="");
+ void getName(std::string& vendor, std::string& product, std::string& instance);
+ const std::string& getAddress();
+
void setInterval(uint16_t _interval) { interval = _interval; }
void setExchange(qpid::broker::Exchange::shared_ptr mgmtExchange,
qpid::broker::Exchange::shared_ptr directExchange);
diff --git a/cpp/src/tests/ManagementTest.cpp b/cpp/src/tests/ManagementTest.cpp
index e9b8ac32b9..8944c084c0 100644
--- a/cpp/src/tests/ManagementTest.cpp
+++ b/cpp/src/tests/ManagementTest.cpp
@@ -86,6 +86,13 @@ QPID_AUTO_TEST_CASE(testObjectIdAttach) {
BOOST_CHECK_EQUAL(out2.str(), "10-20-30-MrSmith-0(GabbaGabbaHey)");
}
+QPID_AUTO_TEST_CASE(testObjectIdCreate) {
+ ObjectId oid("some-agent-name", "an-object-name");
+
+ BOOST_CHECK_EQUAL(oid.getAgentName(), "some-agent-name");
+ BOOST_CHECK_EQUAL(oid.getV2Key(), "an-object-name");
+}
+
QPID_AUTO_TEST_CASE(testConsoleObjectId) {
qpid::console::ObjectId oid1, oid2;