diff options
| author | Ted Ross <tross@apache.org> | 2010-03-31 21:13:12 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2010-03-31 21:13:12 +0000 |
| commit | 2e29faa768283390452b7d432db28d43cd4a27aa (patch) | |
| tree | 521e9711b340a330408245ba699b35d12b36ce9c /cpp/include | |
| parent | 5e50981ac8a35db09723ad19f5994703d00e10d9 (diff) | |
| download | qpid-python-2e29faa768283390452b7d432db28d43cd4a27aa.tar.gz | |
Merged the changes from the qmf-devel0.7a branch back to the trunk.
This is a checkpoint along the QMFv2 development path.
This update introduces portions of QMFv2 into the code:
- The C++ agent (qpid/agent) uses QMFv2 for data and method transfer
o The APIs no longer use qpid::framing::*
o Consequently, boost is no longer referenced from the API headers.
o Agents and Objects are now referenced by strings, not numbers.
o Schema transfer still uses the QMFv1 format.
- The broker-resident agent can use QMFv1 or QMFv2 based on the command line options.
It defaults to QMFv1 for compatibility.
- The pure-python QMF console (qmf.console) can concurrently interact with both
QMFv1 and QMFv2 agents.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@929716 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include')
| -rw-r--r-- | cpp/include/qpid/agent/ManagementAgent.h | 14 | ||||
| -rw-r--r-- | cpp/include/qpid/framing/FieldTable.h | 1 | ||||
| -rw-r--r-- | cpp/include/qpid/management/ManagementEvent.h | 12 | ||||
| -rw-r--r-- | cpp/include/qpid/management/ManagementObject.h | 83 |
4 files changed, 82 insertions, 28 deletions
diff --git a/cpp/include/qpid/agent/ManagementAgent.h b/cpp/include/qpid/agent/ManagementAgent.h index b6ec82862c..aeb5585e61 100644 --- a/cpp/include/qpid/agent/ManagementAgent.h +++ b/cpp/include/qpid/agent/ManagementAgent.h @@ -63,6 +63,17 @@ class ManagementAgent virtual int getMaxThreads() = 0; + // Set the name of the agent + // + // vendor - Vendor name or domain (i.e. "apache.org") + // product - Product name (i.e. "qpid") + // instance - A unique identifier for this instance of the agent. + // If empty, the agent will create a GUID for the instance. + // + virtual void setName(const std::string& vendor, + const std::string& product, + const std::string& instance="") = 0; + // Connect to a management broker // // brokerHost - Hostname or IP address (dotted-quad) of broker. @@ -128,6 +139,9 @@ class ManagementAgent // in an orderly way. // virtual ObjectId addObject(ManagementObject* objectPtr, uint64_t persistId = 0) = 0; + virtual ObjectId addObject(ManagementObject* objectPtr, + const std::string& key, + bool persistent = true) = 0; // // diff --git a/cpp/include/qpid/framing/FieldTable.h b/cpp/include/qpid/framing/FieldTable.h index 085f7ed110..fdb1a28b9d 100644 --- a/cpp/include/qpid/framing/FieldTable.h +++ b/cpp/include/qpid/framing/FieldTable.h @@ -51,6 +51,7 @@ class FieldTable typedef boost::shared_ptr<FieldValue> ValuePtr; typedef std::map<std::string, ValuePtr> ValueMap; typedef ValueMap::iterator iterator; + typedef ValueMap::const_iterator const_iterator; typedef ValueMap::const_reference const_reference; typedef ValueMap::reference reference; typedef ValueMap::value_type value_type; diff --git a/cpp/include/qpid/management/ManagementEvent.h b/cpp/include/qpid/management/ManagementEvent.h index 01b9ae49ec..e80175096f 100644 --- a/cpp/include/qpid/management/ManagementEvent.h +++ b/cpp/include/qpid/management/ManagementEvent.h @@ -23,7 +23,7 @@ */ #include "qpid/management/ManagementObject.h" -#include <qpid/framing/Buffer.h> +#include "qpid/types/Variant.h" #include <string> namespace qpid { @@ -32,16 +32,20 @@ namespace management { class ManagementAgent; class ManagementEvent : public ManagementItem { -public: - typedef void (*writeSchemaCall_t)(qpid::framing::Buffer&); + public: + static const uint8_t MD5_LEN = 16; + //typedef void (*writeSchemaCall_t)(qpid::framing::Buffer&); + typedef void (*writeSchemaCall_t)(std::string&); virtual ~ManagementEvent() {} virtual writeSchemaCall_t getWriteSchemaCall(void) = 0; + //virtual mapEncodeSchemaCall_t getMapEncodeSchemaCall(void) = 0; virtual std::string& getEventName() const = 0; virtual std::string& getPackageName() const = 0; virtual uint8_t* getMd5Sum() const = 0; virtual uint8_t getSeverity() const = 0; - virtual void encode(qpid::framing::Buffer&) const = 0; + virtual void encode(std::string&) const = 0; + virtual void mapEncode(qpid::types::Variant::Map&) const = 0; }; }} diff --git a/cpp/include/qpid/management/ManagementObject.h b/cpp/include/qpid/management/ManagementObject.h index b1c70f64d6..0e9c7f0a0b 100644 --- a/cpp/include/qpid/management/ManagementObject.h +++ b/cpp/include/qpid/management/ManagementObject.h @@ -24,8 +24,8 @@ #include "qpid/sys/Time.h" #include "qpid/sys/Mutex.h" -#include <qpid/framing/Buffer.h> #include "qpid/CommonImportExport.h" +#include "qpid/types/Variant.h" #include <map> #include <vector> @@ -53,23 +53,33 @@ protected: const AgentAttachment* agent; uint64_t first; uint64_t second; + uint64_t agentEpoch; std::string v2Key; + std::string agentName; void fromString(const std::string&); public: - QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0) {} - QPID_COMMON_EXTERN ObjectId(framing::Buffer& buf) : agent(0) { decode(buf); } - QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint32_t bank, uint64_t object); - QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq, uint64_t object); + QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0), agentEpoch(0) {} + QPID_COMMON_EXTERN ObjectId(const types::Variant& map) : + agent(0), first(0), second(0), agentEpoch(0) { mapDecode(map.asMap()); } + QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker); + 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&); + // 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; QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const; + QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map) const; + QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); + QPID_COMMON_EXTERN operator types::Variant::Map() const; QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; }; - QPID_COMMON_EXTERN void encode(framing::Buffer& buffer) const; - QPID_COMMON_EXTERN void decode(framing::Buffer& buffer); + QPID_COMMON_EXTERN void encode(std::string& buffer) const; + QPID_COMMON_EXTERN void decode(const std::string& buffer); + QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; QPID_COMMON_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); - QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; + QPID_COMMON_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } + QPID_COMMON_EXTERN const std::string& getAgentName() const { return agentName; } QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&); }; @@ -94,6 +104,7 @@ public: static const uint8_t TYPE_S16 = 17; static const uint8_t TYPE_S32 = 18; static const uint8_t TYPE_S64 = 19; + static const uint8_t TYPE_LIST = 21; static const uint8_t ACCESS_RC = 1; static const uint8_t ACCESS_RW = 2; @@ -125,7 +136,7 @@ protected: uint64_t updateTime; ObjectId objectId; mutable bool configChanged; - bool instChanged; + mutable bool instChanged; bool deleted; Manageable* coreObject; mutable sys::Mutex accessLock; @@ -135,13 +146,17 @@ protected: bool forcePublish; QPID_COMMON_EXTERN int getThreadIndex(); - QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf) const; - QPID_COMMON_EXTERN void readTimestamps(qpid::framing::Buffer& buf); + QPID_COMMON_EXTERN void writeTimestamps(std::string& buf) const; + QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const; + QPID_COMMON_EXTERN void readTimestamps(const std::string& buf); + QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf); QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const; public: + QPID_COMMON_EXTERN static const uint8_t MD5_LEN = 16; QPID_COMMON_EXTERN static int maxThreads; - typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&); + //typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&); + typedef void (*writeSchemaCall_t) (std::string&); ManagementObject(Manageable* _core) : createTime(uint64_t(qpid::sys::Duration(qpid::sys::now()))), @@ -151,15 +166,28 @@ protected: virtual ~ManagementObject() {} virtual writeSchemaCall_t getWriteSchemaCall() = 0; - virtual void readProperties(qpid::framing::Buffer& buf) = 0; - virtual uint32_t writePropertiesSize() const = 0; - virtual void writeProperties(qpid::framing::Buffer& buf) const = 0; - virtual void writeStatistics(qpid::framing::Buffer& buf, - bool skipHeaders = false) = 0; - virtual void doMethod(std::string& methodName, - qpid::framing::Buffer& inBuf, - qpid::framing::Buffer& outBuf) = 0; virtual std::string getKey() const = 0; + + // Encode & Decode the property and statistics values + // for this object. + virtual void mapEncodeValues(types::Variant::Map& map, + bool includeProperties, + bool includeStatistics) = 0; + virtual void mapDecodeValues(const types::Variant::Map& map) = 0; + virtual void doMethod(std::string& methodName, + const types::Variant::Map& inMap, + types::Variant::Map& outMap) = 0; + + /** + * The following five methods are not pure-virtual because they will only + * be overridden in cases where QMFv1 is to be supported. + */ + virtual uint32_t writePropertiesSize() const { return 0; } + virtual void readProperties(const std::string&) {} + virtual void writeProperties(std::string&) const {} + virtual void writeStatistics(std::string&, bool = false) {} + virtual void doMethod(std::string&, const std::string&, std::string&) {} + QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId); virtual std::string& getClassName() const = 0; @@ -183,16 +211,23 @@ protected: inline void setFlags(uint32_t f) { flags = f; } inline uint32_t getFlags() { return flags; } bool isSameClass(ManagementObject& other) { - for (int idx = 0; idx < 16; idx++) + for (int idx = 0; idx < MD5_LEN; idx++) if (other.getMd5Sum()[idx] != getMd5Sum()[idx]) return false; return other.getClassName() == getClassName() && other.getPackageName() == getPackageName(); } - QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); } - QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); } - QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); } + // QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); } + // QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); } + //QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); } + + // Encode/Decode the entire object as a map + QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map, + bool includeProperties=true, + bool includeStatistics=true); + + QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); }; typedef std::map<ObjectId, ManagementObject*> ManagementObjectMap; |
