You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2010/03/31 23:13:14 UTC
svn commit: r929716 [1/4] - in /qpid/trunk/qpid: cpp/bindings/qmf/tests/
cpp/examples/qmf-agent/ cpp/include/qpid/agent/ cpp/include/qpid/framing/
cpp/include/qpid/management/ cpp/managementgen/ cpp/managementgen/qmfgen/
cpp/managementgen/qmfgen/templa...
Author: tross
Date: Wed Mar 31 21:13:12 2010
New Revision: 929716
URL: http://svn.apache.org/viewvc?rev=929716&view=rev
Log:
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.
Modified:
qpid/trunk/qpid/cpp/bindings/qmf/tests/python_console.py
qpid/trunk/qpid/cpp/examples/qmf-agent/example.cpp
qpid/trunk/qpid/cpp/examples/qmf-agent/schema.xml
qpid/trunk/qpid/cpp/include/qpid/agent/ManagementAgent.h
qpid/trunk/qpid/cpp/include/qpid/framing/FieldTable.h
qpid/trunk/qpid/cpp/include/qpid/management/ManagementEvent.h
qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h
qpid/trunk/qpid/cpp/managementgen/qmf-gen
qpid/trunk/qpid/cpp/managementgen/qmfgen/generate.py
qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml
qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py
qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Args.h
qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h
qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.cpp
qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.h
qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp
qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp
qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp
qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
qpid/trunk/qpid/cpp/src/qpid/broker/System.cpp
qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp
qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h
qpid/trunk/qpid/cpp/src/qpid/management/ManagementDirectExchange.cpp
qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp
qpid/trunk/qpid/cpp/src/qpid/management/ManagementTopicExchange.cpp
qpid/trunk/qpid/cpp/src/tests/Makefile.am
qpid/trunk/qpid/cpp/src/tests/ManagementTest.cpp
qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py
qpid/trunk/qpid/tools/src/py/qpid-cluster
qpid/trunk/qpid/tools/src/py/qpid-config
qpid/trunk/qpid/tools/src/py/qpid-stat
Modified: qpid/trunk/qpid/cpp/bindings/qmf/tests/python_console.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf/tests/python_console.py?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf/tests/python_console.py (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf/tests/python_console.py Wed Mar 31 21:13:12 2010
@@ -48,7 +48,7 @@ class QmfInteropTests(TestBase010):
self.assertEqual(len(parents), 1)
parent = parents[0]
for seq in range(10):
- result = parent.echo(seq)
+ result = parent.echo(seq, _timeout=5)
self.assertEqual(result.status, 0)
self.assertEqual(result.text, "OK")
self.assertEqual(result.sequence, seq)
Modified: qpid/trunk/qpid/cpp/examples/qmf-agent/example.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/examples/qmf-agent/example.cpp?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/examples/qmf-agent/example.cpp (original)
+++ qpid/trunk/qpid/cpp/examples/qmf-agent/example.cpp Wed Mar 31 21:13:12 2010
@@ -24,6 +24,7 @@
#include <qpid/agent/ManagementAgent.h>
#include <qpid/sys/Mutex.h>
#include <qpid/sys/Time.h>
+#include "qpid/types/Variant.h"
#include "qmf/org/apache/qpid/agent/example/Parent.h"
#include "qmf/org/apache/qpid/agent/example/Child.h"
#include "qmf/org/apache/qpid/agent/example/ArgsParentCreate_child.h"
@@ -44,6 +45,7 @@ using qpid::management::ManagementObject
using qpid::management::Manageable;
using qpid::management::Args;
using qpid::sys::Mutex;
+using qpid::types::Variant;
namespace _qmf = qmf::org::apache::qpid::agent::example;
class ChildClass;
@@ -96,8 +98,22 @@ CoreClass::CoreClass(ManagementAgent* _a
static uint64_t persistId = 0x111222333444555LL;
mgmtObject = new _qmf::Parent(agent, this, name);
- agent->addObject(mgmtObject, persistId++);
+ agent->addObject(mgmtObject);
mgmtObject->set_state("IDLE");
+
+ Variant::Map args;
+ Variant::Map subMap;
+ args["first"] = "String data";
+ args["second"] = 34;
+ subMap["string-data"] = "Text";
+ subMap["numeric-data"] = 10000;
+ args["map-data"] = subMap;
+ mgmtObject->set_args(args);
+
+ Variant::List list;
+ list.push_back(20000);
+ list.push_back("string-item");
+ mgmtObject->set_list(list);
}
void CoreClass::doLoop()
@@ -178,6 +194,9 @@ int main_int(int argc, char** argv)
// Register the Qmf_example schema with the agent
_qmf::Package packageInit(agent);
+ // Name the agent.
+ agent->setName("apache.org", "qmf-example");
+
// Start the agent. It will attempt to make a connection to the
// management broker
agent->init(settings, 5, false, ".magentdata");
Modified: qpid/trunk/qpid/cpp/examples/qmf-agent/schema.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/examples/qmf-agent/schema.xml?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/examples/qmf-agent/schema.xml (original)
+++ qpid/trunk/qpid/cpp/examples/qmf-agent/schema.xml Wed Mar 31 21:13:12 2010
@@ -29,6 +29,8 @@
This class represents a parent object
<property name="name" type="sstr" access="RC" index="y"/>
+ <property name="args" type="map" access="RO"/>
+ <property name="list" type="list" access="RO"/>
<statistic name="state" type="sstr" desc="Operational state of the link"/>
<statistic name="count" type="count64" unit="tick" desc="Counter that increases monotonically"/>
Modified: qpid/trunk/qpid/cpp/include/qpid/agent/ManagementAgent.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/agent/ManagementAgent.h?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/agent/ManagementAgent.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/agent/ManagementAgent.h Wed Mar 31 21:13:12 2010
@@ -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;
//
//
Modified: qpid/trunk/qpid/cpp/include/qpid/framing/FieldTable.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/framing/FieldTable.h?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/framing/FieldTable.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/framing/FieldTable.h Wed Mar 31 21:13:12 2010
@@ -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;
Modified: qpid/trunk/qpid/cpp/include/qpid/management/ManagementEvent.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/management/ManagementEvent.h?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/management/ManagementEvent.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/management/ManagementEvent.h Wed Mar 31 21:13:12 2010
@@ -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;
};
}}
Modified: qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h Wed Mar 31 21:13:12 2010
@@ -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;
Modified: qpid/trunk/qpid/cpp/managementgen/qmf-gen
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmf-gen?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmf-gen (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmf-gen Wed Mar 31 21:13:12 2010
@@ -62,8 +62,10 @@ if len(args) == 0:
vargs = {}
if opts.brokerplugin:
vargs["agentHeaderDir"] = "management"
+ vargs["genQmfV1"] = True
else:
vargs["agentHeaderDir"] = "agent"
+ vargs["genQmfV1"] = None
for schemafile in args:
package = SchemaPackage(typefile, schemafile, opts)
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/generate.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/generate.py?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/generate.py (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/generate.py Wed Mar 31 21:13:12 2010
@@ -38,39 +38,43 @@ class Template:
self.filename = filename
self.handler = handler
self.handler.initExpansion ()
- self.writing = True
+ self.writing = 0 # 0 => write output lines; >0 => recursive depth of conditional regions
def expandLine (self, line, stream, object):
cursor = 0
while 1:
sub = line.find ("/*MGEN:", cursor)
if sub == -1:
- if self.writing:
+ if self.writing == 0:
stream.write (line[cursor:len (line)])
return
subend = line.find("*/", sub)
- if self.writing:
+ if self.writing == 0:
stream.write (line[cursor:sub])
cursor = subend + 2
tag = line[sub:subend]
if tag[7:10] == "IF(":
- close = tag.find(")")
- if close == -1:
- raise ValueError ("Missing ')' on condition")
- cond = tag[10:close]
- dotPos = cond.find (".")
- if dotPos == -1:
- raise ValueError ("Invalid condition tag: %s" % cond)
- tagObject = cond[0:dotPos]
- tagName = cond[dotPos + 1 : len(cond)]
- if not self.handler.testCondition(object, tagObject, tagName):
- self.writing = False
+ if self.writing == 0:
+ close = tag.find(")")
+ if close == -1:
+ raise ValueError ("Missing ')' on condition")
+ cond = tag[10:close]
+ dotPos = cond.find (".")
+ if dotPos == -1:
+ raise ValueError ("Invalid condition tag: %s" % cond)
+ tagObject = cond[0:dotPos]
+ tagName = cond[dotPos + 1 : len(cond)]
+ if not self.handler.testCondition(object, tagObject, tagName):
+ self.writing += 1
+ else:
+ self.writing += 1
elif tag[7:12] == "ENDIF":
- self.writing = True
+ if self.writing > 0:
+ self.writing -= 1
else:
equalPos = tag.find ("=")
@@ -80,12 +84,12 @@ class Template:
raise ValueError ("Invalid tag: %s" % tag)
tagObject = tag[7:dotPos]
tagName = tag[dotPos + 1:len (tag)]
- if self.writing:
+ if self.writing == 0:
self.handler.substHandler (object, stream, tagObject, tagName)
else:
tagKey = tag[7:equalPos]
tagVal = tag[equalPos + 1:len (tag)]
- if self.writing:
+ if self.writing == 0:
self.handler.setVariable (tagKey, tagVal)
def expand (self, object):
@@ -297,6 +301,9 @@ class Generator:
self.packagelist.append(path)
self.packagePath = self.normalize(self.dest + path)
+ def testGenQMFv1 (self, variables):
+ return variables["genQmfV1"]
+
def genDisclaimer (self, stream, variables):
prefix = variables["commentPrefix"]
stream.write (prefix + " This source file was created by a code generator.\n")
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml Wed Mar 31 21:13:12 2010
@@ -19,7 +19,14 @@
under the License.
-->
-<type name="objId" base="REF" cpp="::qpid::management::ObjectId" encode="#.encode(@)" decode="#.decode(@)" stream="#.getV2Key()" size="16" accessor="direct" init="::qpid::management::ObjectId()" byRef="y"/>
+<!-- "unmap": cast to convert from Variant to native type constructor,
+ "map": cast to convert from native type to Variant constructor parameter
+-->
+
+<type name="objId" base="REF" cpp="::qpid::management::ObjectId"
+ encode="{std::string _s; #.encode(_s); @.putRawData(_s);}"
+ decode="{std::string _s; @.getRawData(_s, #.encodedSize()); #.decode(_s);}"
+stream="#.getV2Key()" size="16" accessor="direct" init="::qpid::management::ObjectId()" byRef="y"/>
<type name="uint8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" stream="#" size="1" accessor="direct" init="0"/>
<type name="uint16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" stream="#" size="2" accessor="direct" init="0"/>
<type name="uint32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" stream="#" size="4" accessor="direct" init="0"/>
@@ -29,14 +36,25 @@
<type name="int32" base="S32" cpp="int32_t" encode="@.putInt32(#)" decode="# = @.getInt32()" stream="#" size="4" accessor="direct" init="0"/>
<type name="int64" base="S64" cpp="int64_t" encode="@.putInt64(#)" decode="# = @.getInt64()" stream="#" size="8" accessor="direct" init="0"/>
<type name="bool" base="BOOL" cpp="uint8_t" encode="@.putOctet(#?1:0)" decode="# = @.getOctet()==1" stream="#" size="1" accessor="direct" init="0"/>
-<type name="sstr" base="SSTR" cpp="std::string" encode="@.putShortString(#)" decode="@.getShortString(#)" stream="#" size="(1 + #.length())" accessor="direct" init='""' byRef="y"/>
-<type name="lstr" base="LSTR" cpp="std::string" encode="@.putMediumString(#)" decode="@.getMediumString(#)" stream="#" size="(2 + #.length())" accessor="direct" init='""' byRef="y"/>
+<type name="sstr" base="SSTR" cpp="std::string" encode="@.putShortString(#)" decode="@.getShortString(#)" stream="#" size="(1 + #.length())" accessor="direct" init='""' byRef="y" unmap="(#).getString()"/>
+<type name="lstr" base="LSTR" cpp="std::string" encode="@.putMediumString(#)" decode="@.getMediumString(#)" stream="#" size="(2 + #.length())" accessor="direct" init='""' byRef="y" unmap="(#).getString()"/>
<type name="absTime" base="ABSTIME" cpp="int64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" size="8" accessor="direct" init="0"/>
<type name="deltaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" size="8" accessor="direct" init="0"/>
<type name="float" base="FLOAT" cpp="float" encode="@.putFloat(#)" decode="# = @.getFloat()" stream="#" size="4" accessor="direct" init="0."/>
<type name="double" base="DOUBLE" cpp="double" encode="@.putDouble(#)" decode="# = @.getDouble()" stream="#" size="8" accessor="direct" init="0."/>
-<type name="uuid" base="UUID" cpp="::qpid::framing::Uuid" encode="#.encode(@)" decode="#.decode(@)" stream="#" size="16" accessor="direct" init="::qpid::framing::Uuid()" byRef="y"/>
-<type name="map" base="FTABLE" cpp="::qpid::framing::FieldTable" encode="#.encode(@)" decode="#.decode(@)" stream="#" size="#.encodedSize()" accessor="direct" init="::qpid::framing::FieldTable()" byRef="y"/>
+<type name="uuid" base="UUID" cpp="::qpid::types::Uuid"
+ encode="{::qpid::framing::Uuid _u(#.data()); _u.encode(@); }"
+ decode="{::qpid::framing::Uuid _u; _u.decode(@); # = ::qpid::types::Uuid(_u.data());}"
+ stream="#" size="16" accessor="direct" init="::qpid::types::Uuid()" byRef="y" unmap="(#).asUuid().data()" map="::qpid::types::Uuid((#).data())" />
+<type name="map" base="FTABLE" cpp="::qpid::types::Variant::Map"
+ encode="{::qpid::framing::FieldTable _f = ManagementAgent::fromMap(#); _f.encode(@);}"
+ decode="{::qpid::framing::FieldTable _f; _f.decode(@); # = ManagementAgent::toMap(_f);}"
+ size="::qpid::framing::FieldTable(ManagementAgent::fromMap(#)).encodedSize()"
+stream="#" accessor="direct" init="::qpid::types::Variant::Map()" byRef="y" unmap="::qpid::types::Variant::Map(); assert(false); /*TBD*/"/>
+<type name="list" base="LIST" cpp="::qpid::types::Variant::List"
+ encode="{::qpid::framing::List _l = ManagementAgent::fromList(#); _l.encode(@);}"
+ decode="{::qpid::framing::List _l; _l.decode(@); # = ManagementAgent::toList(_l);}"
+stream="#" size="#.encodedSize()" accessor="direct" init="::qpid::types::Variant::List()" byRef="y" unmap="::qpid::types::Variant::List(); assert(false); /*TBD*/"/>
<type name="hilo8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" style="wm" stream="#" size="1" accessor="counter" init="0"/>
<type name="hilo16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" style="wm" stream="#" size="2" accessor="counter" init="0"/>
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py Wed Mar 31 21:13:12 2010
@@ -19,12 +19,18 @@
from xml.dom.minidom import parse, parseString, Node
from cStringIO import StringIO
-import md5
+#import md5
+try:
+ import hashlib
+ _md5Obj = hashlib.md5
+except ImportError:
+ import md5
+ _md5Obj = md5.new
class Hash:
""" Manage the hash of an XML sub-tree """
def __init__(self, node):
- self.md5Sum = md5.new()
+ self.md5Sum = _md5Obj()
self._compute(node)
def addSubHash(self, hash):
@@ -64,6 +70,8 @@ class SchemaType:
self.init = "0"
self.perThread = False
self.byRef = False
+ self.unmap = "#"
+ self.map = "#"
attrs = node.attributes
for idx in range (attrs.length):
@@ -109,6 +117,12 @@ class SchemaType:
raise ValueError ("Expected 'y' in byRef attribute")
self.byRef = True
+ elif key == 'unmap':
+ self.unmap = val
+
+ elif key == 'map':
+ self.map = val
+
else:
raise ValueError ("Unknown attribute in type '%s'" % key)
@@ -211,6 +225,17 @@ class SchemaType:
def genRead (self, stream, varName, indent=" "):
stream.write(indent + self.decode.replace("@", "buf").replace("#", varName) + ";\n")
+ def genUnmap (self, stream, varName, indent=" ", key=None, mapName="_map",
+ _optional=False):
+ if key is None:
+ key = varName
+ stream.write(indent + "if ((_i = " + mapName + ".find(\"" + key + "\")) != " + mapName + ".end()) {\n")
+ stream.write(indent + " " + varName + " = " +
+ self.unmap.replace("#", "_i->second") + ";\n")
+ if _optional:
+ stream.write(indent + " _found = true;\n")
+ stream.write(indent + "}\n")
+
def genWrite (self, stream, varName, indent=" "):
if self.style != "mma":
stream.write (indent + self.encode.replace ("@", "buf").replace ("#", varName) + ";\n")
@@ -230,6 +255,31 @@ class SchemaType:
.replace ("#", varName + "Count ? " + varName + "Total / " +
varName + "Count : 0") + ";\n")
+ def genMap (self, stream, varName, indent=" ", key=None, mapName="_map"):
+ if key is None:
+ key = varName
+ if self.style != "mma":
+ var_cast = self.map.replace("#", varName)
+ stream.write(indent + mapName + "[\"" + key + "\"] = ::qpid::types::Variant(" + var_cast + ");\n")
+ if self.style == "wm":
+ var_cast_hi = self.map.replace("#", varName + "High")
+ var_cast_lo = self.map.replace("#", varName + "Low")
+ stream.write(indent + mapName + "[\"" + key + "High\"] = " +
+ "::qpid::types::Variant(" + var_cast_hi + ");\n")
+ stream.write(indent + mapName + "[\"" + key + "Low\"] = " +
+ "::qpid::types::Variant(" + var_cast_lo + ");\n")
+ if self.style == "mma":
+ var_cast = self.map.replace("#", varName + "Count")
+ stream.write(indent + mapName + "[\"" + key + "Count\"] = " + "::qpid::types::Variant(" + var_cast + ");\n")
+ var_cast = self.map.replace("#", varName + "Min")
+ stream.write(indent + mapName + "[\"" + key + "Min\"] = " +
+ "(" + varName + "Count ? ::qpid::types::Variant(" + var_cast + ") : ::qpid::types::Variant(0));\n")
+ var_cast = self.map.replace("#", varName + "Max")
+ stream.write(indent + mapName + "[\"" + key + "Max\"] = " + "::qpid::types::Variant(" + var_cast + ");\n")
+
+ var_cast = self.map.replace("#", "(" + varName + "Total / " + varName + "Count)")
+ stream.write(indent + mapName + "[\"" + key + "Avg\"] = " +
+ "(" + varName + "Count ? ::qpid::types::Variant(" + var_cast + ") : ::qpid::types::Variant(0));\n")
def getReadCode (self, varName, bufName):
result = self.decode.replace ("@", bufName).replace ("#", varName)
@@ -392,6 +442,29 @@ class SchemaProperty:
stream.write (" ft.setString (DESC, \"" + self.desc + "\");\n")
stream.write (" buf.put (ft);\n\n")
+
+ def genSchemaMap(self, stream):
+ stream.write (" {\n")
+ stream.write (" ::qpid::types::Variant::Map _value;\n")
+ stream.write (" _value[TYPE] = TYPE_" + self.type.type.base +";\n")
+ stream.write (" _value[ACCESS] = ACCESS_" + self.access + ";\n")
+ stream.write (" _value[IS_INDEX] = " + str (self.isIndex) + ";\n")
+ stream.write (" _value[IS_OPTIONAL] = " + str (self.isOptional) + ";\n")
+ if self.unit != None:
+ stream.write (" _value[UNIT] = \"" + self.unit + "\";\n")
+ if self.min != None:
+ stream.write (" _value[MIN] = " + self.min + ";\n")
+ if self.max != None:
+ stream.write (" _value[MAX] = " + self.max + ";\n")
+ if self.maxLen != None:
+ stream.write (" _value[MAXLEN] = " + self.maxLen + ";\n")
+ if self.desc != None:
+ stream.write (" _value[DESC] = \"" + self.desc + "\";\n")
+ stream.write (" _props[\"" + self.name + "\"] = _value;\n")
+ stream.write (" }\n\n")
+
+
+
def genSize (self, stream):
indent = " "
if self.isOptional:
@@ -419,6 +492,43 @@ class SchemaProperty:
if self.isOptional:
stream.write(" }\n")
+ def genUnmap (self, stream):
+ indent = " "
+ if self.isOptional:
+ stream.write(" _found = false;\n")
+ self.type.type.genUnmap (stream, self.name, indent, _optional=self.isOptional)
+ if self.isOptional:
+ stream.write(" if (_found) {\n")
+ stream.write(" presenceMask[presenceByte_%s] |= presenceMask_%s;\n" %
+ (self.name, self.name))
+ stream.write(" }\n")
+
+ def genMap (self, stream):
+ indent = " "
+ if self.isOptional:
+ stream.write(" if (presenceMask[presenceByte_%s] & presenceMask_%s) {\n" % (self.name, self.name))
+ indent = " "
+ self.type.type.genMap (stream, self.name, indent)
+ if self.isOptional:
+ stream.write(" }\n")
+
+
+ def __repr__(self):
+ m = {}
+ m["name"] = self.name
+ m["type"] = self.type
+ m["ref"] = self.ref
+ m["access"] = self.access
+ m["isIndex"] = self.isIndex
+ m["isParentRef"] = self.isParentRef
+ m["isGeneralRef"] = self.isGeneralRef
+ m["isOptional"] = self.isOptional
+ m["unit"] = self.unit
+ m["min"] = self.min
+ m["max"] = self.max
+ m["maxLen"] = self.maxLen
+ m["desc"] = self.desc
+ return str(m)
#=====================================================================================
#
@@ -492,6 +602,17 @@ class SchemaStatistic:
stream.write (" ft.setString (DESC, \"" + desc + "\");\n")
stream.write (" buf.put (ft);\n\n")
+ def genSchemaTextMap(self, stream, name, desc):
+ stream.write (" {\n")
+ stream.write (" ::qpid::types::Variant::Map _value;\n")
+ stream.write (" _value[TYPE] = TYPE_" + self.type.type.base +";\n")
+ if self.unit != None:
+ stream.write (" _value[UNIT] = \"" + self.unit + "\";\n")
+ if desc != None:
+ stream.write (" _value[DESC] = \"" + desc + "\";\n")
+ stream.write (" _stats[\"" + self.name + "\"] = _value;\n")
+ stream.write (" }\n\n")
+
def genSchema (self, stream):
if self.type.type.style != "mma":
self.genSchemaText (stream, self.name, self.desc)
@@ -518,6 +639,32 @@ class SchemaStatistic:
self.genSchemaText (stream, self.name + "Max", descMax)
self.genSchemaText (stream, self.name + "Average", descAverage)
+ def genSchemaMap (self, stream):
+ if self.type.type.style != "mma":
+ self.genSchemaTextMap (stream, self.name, self.desc)
+ if self.type.type.style == "wm":
+ descHigh = self.desc
+ descLow = self.desc
+ if self.desc != None:
+ descHigh = descHigh + " (High)"
+ descLow = descLow + " (Low)"
+ self.genSchemaTextMap (stream, self.name + "High", descHigh)
+ self.genSchemaTextMap (stream, self.name + "Low", descLow)
+ if self.type.type.style == "mma":
+ descCount = self.desc
+ descMin = self.desc
+ descMax = self.desc
+ descAverage = self.desc
+ if self.desc != None:
+ descCount = descCount + " (Samples)"
+ descMin = descMin + " (Min)"
+ descMax = descMax + " (Max)"
+ descAverage = descAverage + " (Average)"
+ self.genSchemaTextMap (stream, self.name + "Samples", descCount)
+ self.genSchemaTextMap (stream, self.name + "Min", descMin)
+ self.genSchemaTextMap (stream, self.name + "Max", descMax)
+ self.genSchemaTextMap (stream, self.name + "Average", descAverage)
+
def genAssign (self, stream):
if self.assign != None:
if self.type.type.perThread:
@@ -533,6 +680,12 @@ class SchemaStatistic:
else:
self.type.type.genWrite (stream, self.name)
+ def genMap (self, stream):
+ if self.type.type.perThread:
+ self.type.type.genMap(stream, "totals." + self.name, key=self.name)
+ else:
+ self.type.type.genMap(stream, self.name)
+
def genInitialize (self, stream, prefix="", indent=" "):
val = self.type.type.init
if self.type.type.style != "mma":
@@ -648,6 +801,30 @@ class SchemaArg:
stream.write (" ft.setString (DESC, \"" + self.desc + "\");\n")
stream.write (" buf.put (ft);\n\n")
+ def genSchemaMap (self, stream, event=False):
+ stream.write (" {\n")
+ stream.write (" ::qpid::types::Variant::Map _avalue;\n")
+ stream.write (" _avalue[TYPE] = TYPE_" + self.type.type.base +";\n")
+ if (not event):
+ stream.write (" _avalue[DIR] = \"" + self.dir + "\";\n")
+ if self.unit != None:
+ stream.write (" _avalue[UNIT] = \"" + self.unit + "\";\n")
+ if not event:
+ if self.min != None:
+ stream.write (" _avalue[MIN] = " + self.min + ";\n")
+ if self.max != None:
+ stream.write (" _avalue[MAX] = " + self.max + ";\n")
+ if self.maxLen != None:
+ stream.write (" _avalue[MAXLEN] = " + self.maxLen + ";\n")
+ if self.default != None:
+ stream.write (" _avalue[DEFAULT] = \"" + self.default + "\";\n")
+ if self.desc != None:
+ stream.write (" _avalue[DESC] = \"" + self.desc + "\";\n")
+ stream.write (" _args[\"" + self.name + "\"] = _avalue;\n")
+ stream.write (" }\n")
+
+
+
def genFormalParam (self, stream, variables):
stream.write ("%s _%s" % (self.type.type.asArg, self.name))
@@ -727,6 +904,24 @@ class SchemaMethod:
for arg in self.args:
arg.genSchema (stream)
+ def genSchemaMap (self, stream, variables):
+ stream.write (" {\n")
+ stream.write (" ::qpid::types::Variant::Map _value;\n")
+ stream.write (" ::qpid::types::Variant::Map _args;\n")
+ stream.write (" _value[ARGCOUNT] = " + str(len(self.args)) + ";\n")
+ if self.desc != None:
+ stream.write (" _value[DESC] = \"" + self.desc + "\";\n")
+
+ for arg in self.args:
+ arg.genSchemaMap (stream)
+
+ stream.write (" if (!_args.empty())\n")
+ stream.write (" _value[ARGS] = _args;\n")
+
+
+ stream.write (" _methods[\"" + self.name + "\"] = _value;\n")
+ stream.write (" }\n\n")
+
#=====================================================================================
#
#=====================================================================================
@@ -849,10 +1044,20 @@ class SchemaEvent:
for arg in self.args:
stream.write(" " + arg.type.type.encode.replace("@", "buf").replace("#", arg.name) + ";\n")
+ def genArgMap(self, stream, variables):
+ for arg in self.args:
+ arg.type.type.genMap(stream, arg.name, " ", mapName="map")
+ #stream.write(" " + arg.type.type.encode.replace("@", "buf").replace("#", arg.name) + ";\n")
+
+
def genArgSchema(self, stream, variables):
for arg in self.args:
arg.genSchema(stream, True)
+ def genArgSchemaMap(self, stream, variables):
+ for arg in self.args:
+ arg.genSchemaMap(stream, True)
+
def genSchemaMD5(self, stream, variables):
sum = self.hash.getDigest()
for idx in range (len (sum)):
@@ -1023,12 +1228,36 @@ class SchemaClass:
inArgCount = inArgCount + 1
if methodCount == 0:
- stream.write ("string&, Buffer&, Buffer& outBuf")
+ stream.write ("string&, const string&, string& outStr")
else:
if inArgCount == 0:
- stream.write ("string& methodName, Buffer&, Buffer& outBuf")
+ stream.write ("string& methodName, const string&, string& outStr")
else:
- stream.write ("string& methodName, Buffer& inBuf, Buffer& outBuf")
+ stream.write ("string& methodName, const string& inStr, string& outStr")
+
+
+ def genDoMapMethodArgs (self, stream, variables):
+ methodCount = 0
+ inArgCount = 0
+ for method in self.methods:
+ methodCount = methodCount + 1
+ for arg in method.args:
+ if arg.getDir () == "I" or arg.getDir () == "IO":
+ inArgCount = inArgCount + 1
+
+ if methodCount == 0:
+ stream.write ("string&," +
+ " const ::qpid::types::Variant::Map&," +
+ " ::qpid::types::Variant::Map& outMap")
+ else:
+ if inArgCount == 0:
+ stream.write ("string& methodName," +
+ " const ::qpid::types::Variant::Map&," +
+ " ::qpid::types::Variant::Map& outMap")
+ else:
+ stream.write ("string& methodName," +
+ " const ::qpid::types::Variant::Map& inMap," +
+ " ::qpid::types::Variant::Map& outMap")
def genHiLoStatResets (self, stream, variables):
for inst in self.statistics:
@@ -1109,8 +1338,22 @@ class SchemaClass:
stream.write ("%d" % len (self.methods))
def genMethodHandlers (self, stream, variables):
+ inArgs = False
+ for method in self.methods:
+ for arg in method.args:
+ if arg.getDir () == "I" or arg.getDir () == "IO":
+ inArgs = True;
+ break
+
+ if inArgs:
+ stream.write("\n")
+ stream.write(" char *_tmpBuf = new char[inStr.length()];\n")
+ stream.write(" memcpy(_tmpBuf, inStr.data(), inStr.length());\n")
+ stream.write(" ::qpid::framing::Buffer inBuf(_tmpBuf, inStr.length());\n")
+
for method in self.methods:
stream.write ("\n if (methodName == \"" + method.getName () + "\") {\n")
+ stream.write (" _matched = true;\n")
if method.getArgCount () == 0:
stream.write (" ::qpid::management::ArgsNone ioArgs;\n")
else:
@@ -1131,7 +1374,43 @@ class SchemaClass:
stream.write (" " +\
arg.type.type.getWriteCode ("ioArgs." +\
arg.dir.lower () + "_" +\
- arg.name, "outBuf") + ";\n")
+ arg.name, "outBuf") + ";\n")
+ stream.write(" }\n")
+
+ if inArgs:
+ stream.write ("\n delete [] _tmpBuf;\n")
+
+
+
+ def genMapMethodHandlers (self, stream, variables):
+ for method in self.methods:
+ stream.write ("\n if (methodName == \"" + method.getName () + "\") {\n")
+ if method.getArgCount () == 0:
+ stream.write (" ::qpid::management::ArgsNone ioArgs;\n")
+ else:
+ stream.write (" Args" + method.getFullName () + " ioArgs;\n")
+ stream.write (" ::qpid::types::Variant::Map::const_iterator _i;\n")
+
+ # decode each input argument from the input map
+ for arg in method.args:
+ if arg.getDir () == "I" or arg.getDir () == "IO":
+ arg.type.type.genUnmap(stream,
+ "ioArgs." + arg.dir.lower () + "_" + arg.name,
+ " ",
+ arg.name,
+ "inMap")
+
+ stream.write (" status = coreObject->ManagementMethod (METHOD_" +\
+ method.getName().upper() + ", ioArgs, text);\n")
+ stream.write (" outMap[\"_status_code\"] = (uint32_t) status;\n")
+ stream.write (" outMap[\"_status_text\"] = ::qpid::management::Manageable::StatusText(status, text);\n")
+ for arg in method.args:
+ if arg.getDir () == "O" or arg.getDir () == "IO":
+ arg.type.type.genMap(stream,
+ "ioArgs." + arg.dir.lower () + "_" + arg.name,
+ " ",
+ arg.name,
+ "outMap")
stream.write (" return;\n }\n")
def genOpenNamespaces (self, stream, variables):
@@ -1160,6 +1439,10 @@ class SchemaClass:
for prop in self.properties:
prop.genSchema (stream)
+ def genPropertySchemaMap (self, stream, variables):
+ for prop in self.properties:
+ prop.genSchemaMap(stream)
+
def genSetGeneralReferenceDeclaration (self, stream, variables):
for prop in self.properties:
if prop.isGeneralRef:
@@ -1169,6 +1452,10 @@ class SchemaClass:
for stat in self.statistics:
stat.genSchema (stream)
+ def genStatisticSchemaMap (self, stream, variables):
+ for stat in self.statistics:
+ stat.genSchemaMap(stream)
+
def genMethodIdDeclarations (self, stream, variables):
number = 1
for method in self.methods:
@@ -1180,6 +1467,10 @@ class SchemaClass:
for method in self.methods:
method.genSchema (stream, variables)
+ def genMethodSchemaMap(self, stream, variables):
+ for method in self.methods:
+ method.genSchemaMap(stream, variables)
+
def genNameCap (self, stream, variables):
stream.write (capitalize(self.name))
@@ -1241,6 +1532,17 @@ class SchemaClass:
for stat in self.statistics:
stat.genWrite (stream)
+ def genMapEncodeProperties(self, stream, variables):
+ for prop in self.properties:
+ prop.genMap (stream)
+
+ def genMapEncodeStatistics (self, stream, variables):
+ for stat in self.statistics:
+ stat.genMap (stream)
+
+ def genMapDecodeProperties (self, stream, variables):
+ for prop in self.properties:
+ prop.genUnmap (stream)
class SchemaEventArgs:
def __init__(self, package, node, typespec, fragments, options):
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Args.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Args.h?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Args.h (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Args.h Wed Mar 31 21:13:12 2010
@@ -24,8 +24,8 @@
/*MGEN:Root.Disclaimer*/
#include "qpid/management/Args.h"
-#include "qpid/framing/FieldTable.h"
-#include "qpid/framing/Uuid.h"
+//#include "qpid/framing/FieldTable.h"
+//#include "qpid/framing/Uuid.h"
#include <string>
namespace qmf {
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp Wed Mar 31 21:13:12 2010
@@ -21,15 +21,15 @@
/*MGEN:Root.Disclaimer*/
#include "qpid/log/Statement.h"
+#include "qpid/management/Manageable.h"
#include "qpid/framing/FieldTable.h"
-#include "qpid/management/Manageable.h"
+#include "qpid/framing/Buffer.h"
#include "qpid//*MGEN:Class.AgentHeaderLocation*//ManagementAgent.h"
#include "/*MGEN:Class.NameCap*/.h"
/*MGEN:Class.MethodArgIncludes*/
#include <iostream>
using namespace qmf::/*MGEN:Class.Namespace*/;
-using namespace qpid::framing;
using qpid::management::ManagementAgent;
using qpid::management::Manageable;
using qpid::management::ManagementObject;
@@ -38,7 +38,7 @@ using std::string;
string /*MGEN:Class.NameCap*/::packageName = string ("/*MGEN:Class.NamePackageLower*/");
string /*MGEN:Class.NameCap*/::className = string ("/*MGEN:Class.NameLower*/");
-uint8_t /*MGEN:Class.NameCap*/::md5Sum[16] =
+uint8_t /*MGEN:Class.NameCap*/::md5Sum[MD5_LEN] =
{/*MGEN:Class.SchemaMD5*/};
/*MGEN:Class.NameCap*/::/*MGEN:Class.NameCap*/ (ManagementAgent*, Manageable* _core/*MGEN:Class.ParentArg*//*MGEN:Class.ConstructorArgs*/) :
@@ -90,9 +90,12 @@ void /*MGEN:Class.NameCap*/::registerSel
agent->registerClass(packageName, className, md5Sum, writeSchema);
}
-void /*MGEN:Class.NameCap*/::writeSchema (Buffer& buf)
+void /*MGEN:Class.NameCap*/::writeSchema (std::string& schema)
{
- FieldTable ft;
+ const int _bufSize=65536;
+ char _msgChars[_bufSize];
+ ::qpid::framing::Buffer buf(_msgChars, _bufSize);
+ ::qpid::framing::FieldTable ft;
// Schema class header:
buf.putOctet (CLASS_KIND_TABLE);
@@ -109,10 +112,15 @@ void /*MGEN:Class.NameCap*/::writeSchema
/*MGEN:Class.StatisticSchema*/
// Methods
/*MGEN:Class.MethodSchema*/
+ {
+ uint32_t _len = buf.getPosition();
+ buf.reset();
+ buf.getRawData(schema, _len);
+ }
}
/*MGEN:IF(Class.ExistPerThreadStats)*/
-void /*MGEN:Class.NameCap*/::aggregatePerThreadStats(struct PerThreadStats* totals)
+void /*MGEN:Class.NameCap*/::aggregatePerThreadStats(struct PerThreadStats* totals) const
{
/*MGEN:Class.InitializeTotalPerThreadStats*/
for (int idx = 0; idx < maxThreads; idx++) {
@@ -124,6 +132,7 @@ void /*MGEN:Class.NameCap*/::aggregatePe
}
/*MGEN:ENDIF*/
+/*MGEN:IF(Root.GenQMFv1)*/
uint32_t /*MGEN:Class.NameCap*/::writePropertiesSize() const
{
uint32_t size = writeTimestampsSize();
@@ -134,32 +143,62 @@ uint32_t /*MGEN:Class.NameCap*/::writePr
return size;
}
-void /*MGEN:Class.NameCap*/::readProperties (Buffer& buf)
+void /*MGEN:Class.NameCap*/::readProperties (const std::string& _sBuf)
{
+ char *_tmpBuf = new char[_sBuf.length()];
+ memcpy(_tmpBuf, _sBuf.data(), _sBuf.length());
+ ::qpid::framing::Buffer buf(_tmpBuf, _sBuf.length());
::qpid::sys::Mutex::ScopedLock mutex(accessLock);
- readTimestamps(buf);
+
+ {
+ std::string _tbuf;
+ buf.getRawData(_tbuf, writeTimestampsSize());
+ readTimestamps(_tbuf);
+ }
+
/*MGEN:IF(Class.ExistOptionals)*/
for (uint8_t idx = 0; idx < /*MGEN:Class.PresenceMaskBytes*/; idx++)
presenceMask[idx] = buf.getOctet();
/*MGEN:ENDIF*/
/*MGEN:Class.ReadProperties*/
+
+ delete [] _tmpBuf;
}
-void /*MGEN:Class.NameCap*/::writeProperties (Buffer& buf) const
+void /*MGEN:Class.NameCap*/::writeProperties (std::string& _sBuf) const
{
+ const int _bufSize=65536;
+ char _msgChars[_bufSize];
+ ::qpid::framing::Buffer buf(_msgChars, _bufSize);
+
::qpid::sys::Mutex::ScopedLock mutex(accessLock);
configChanged = false;
- writeTimestamps (buf);
+ {
+ std::string _tbuf;
+ writeTimestamps(_tbuf);
+ buf.putRawData(_tbuf);
+ }
+
+
/*MGEN:IF(Class.ExistOptionals)*/
for (uint8_t idx = 0; idx < /*MGEN:Class.PresenceMaskBytes*/; idx++)
buf.putOctet(presenceMask[idx]);
/*MGEN:ENDIF*/
/*MGEN:Class.WriteProperties*/
+
+ uint32_t _bufLen = buf.getPosition();
+ buf.reset();
+
+ buf.getRawData(_sBuf, _bufLen);
}
-void /*MGEN:Class.NameCap*/::writeStatistics (Buffer& buf, bool skipHeaders)
+void /*MGEN:Class.NameCap*/::writeStatistics (std::string& _sBuf, bool skipHeaders)
{
+ const int _bufSize=65536;
+ char _msgChars[_bufSize];
+ ::qpid::framing::Buffer buf(_msgChars, _bufSize);
+
::qpid::sys::Mutex::ScopedLock mutex(accessLock);
instChanged = false;
/*MGEN:IF(Class.ExistPerThreadAssign)*/
@@ -175,8 +214,12 @@ void /*MGEN:Class.NameCap*/::writeStatis
aggregatePerThreadStats(&totals);
/*MGEN:ENDIF*/
/*MGEN:Class.Assign*/
- if (!skipHeaders)
- writeTimestamps (buf);
+ if (!skipHeaders) {
+ std::string _tbuf;
+ writeTimestamps (_tbuf);
+ buf.putRawData(_tbuf);
+ }
+
/*MGEN:Class.WriteStatistics*/
// Maintenance of hi-lo statistics
@@ -189,6 +232,11 @@ void /*MGEN:Class.NameCap*/::writeStatis
}
}
/*MGEN:ENDIF*/
+
+ uint32_t _bufLen = buf.getPosition();
+ buf.reset();
+
+ buf.getRawData(_sBuf, _bufLen);
}
void /*MGEN:Class.NameCap*/::doMethod (/*MGEN:Class.DoMethodArgs*/)
@@ -196,11 +244,25 @@ void /*MGEN:Class.NameCap*/::doMethod (/
Manageable::status_t status = Manageable::STATUS_UNKNOWN_METHOD;
std::string text;
+ bool _matched = false;
+
+ const int _bufSize=65536;
+ char _msgChars[_bufSize];
+ ::qpid::framing::Buffer outBuf(_msgChars, _bufSize);
+
/*MGEN:Class.MethodHandlers*/
- outBuf.putLong(status);
- outBuf.putShortString(Manageable::StatusText(status, text));
-}
+ if (!_matched) {
+ outBuf.putLong(status);
+ outBuf.putShortString(Manageable::StatusText(status, text));
+ }
+
+ uint32_t _bufLen = outBuf.getPosition();
+ outBuf.reset();
+
+ outBuf.getRawData(outStr, _bufLen);
+}
+/*MGEN:ENDIF*/
std::string /*MGEN:Class.NameCap*/::getKey() const
{
std::stringstream key;
@@ -209,3 +271,67 @@ std::string /*MGEN:Class.NameCap*/::getK
return key.str();
}
+
+
+void /*MGEN:Class.NameCap*/::mapEncodeValues (::qpid::types::Variant::Map& _map,
+ bool includeProperties,
+ bool includeStatistics)
+{
+ using namespace ::qpid::types;
+ ::qpid::sys::Mutex::ScopedLock mutex(accessLock);
+
+ if (includeProperties) {
+ configChanged = false;
+/*MGEN:Class.MapEncodeProperties*/
+ }
+
+ if (includeStatistics) {
+ instChanged = false;
+/*MGEN:IF(Class.ExistPerThreadAssign)*/
+ for (int idx = 0; idx < maxThreads; idx++) {
+ struct PerThreadStats* threadStats = perThreadStatsArray[idx];
+ if (threadStats != 0) {
+/*MGEN:Class.PerThreadAssign*/
+ }
+ }
+/*MGEN:ENDIF*/
+/*MGEN:IF(Class.ExistPerThreadStats)*/
+ struct PerThreadStats totals;
+ aggregatePerThreadStats(&totals);
+/*MGEN:ENDIF*/
+/*MGEN:Class.Assign*/
+
+/*MGEN:Class.MapEncodeStatistics*/
+
+ // Maintenance of hi-lo statistics
+/*MGEN:Class.HiLoStatResets*/
+/*MGEN:IF(Class.ExistPerThreadResets)*/
+ for (int idx = 0; idx < maxThreads; idx++) {
+ struct PerThreadStats* threadStats = perThreadStatsArray[idx];
+ if (threadStats != 0) {
+/*MGEN:Class.PerThreadHiLoStatResets*/
+ }
+ }
+/*MGEN:ENDIF*/
+ }
+}
+
+void /*MGEN:Class.NameCap*/::mapDecodeValues (const ::qpid::types::Variant::Map& _map)
+{
+ ::qpid::types::Variant::Map::const_iterator _i;
+ ::qpid::sys::Mutex::ScopedLock mutex(accessLock);
+/*MGEN:IF(Class.ExistOptionals)*/
+ bool _found;
+/*MGEN:ENDIF*/
+/*MGEN:Class.MapDecodeProperties*/
+}
+
+void /*MGEN:Class.NameCap*/::doMethod (/*MGEN:Class.DoMapMethodArgs*/)
+{
+ Manageable::status_t status = Manageable::STATUS_UNKNOWN_METHOD;
+ std::string text;
+
+/*MGEN:Class.MapMethodHandlers*/
+ outMap["_status_code"] = (uint32_t) status;
+ outMap["_status_text"] = Manageable::StatusText(status, text);
+}
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h Wed Mar 31 21:13:12 2010
@@ -24,8 +24,6 @@
/*MGEN:Root.Disclaimer*/
#include "qpid/management/ManagementObject.h"
-#include "qpid/framing/FieldTable.h"
-#include "qpid/framing/Uuid.h"
namespace qpid {
namespace management {
@@ -42,7 +40,7 @@ class /*MGEN:Class.NameCap*/ : public ::
static std::string packageName;
static std::string className;
- static uint8_t md5Sum[16];
+ static uint8_t md5Sum[MD5_LEN];
/*MGEN:IF(Class.ExistOptionals)*/
uint8_t presenceMask[/*MGEN:Class.PresenceMaskBytes*/];
/*MGEN:Class.PresenceMaskConstants*/
@@ -71,18 +69,28 @@ class /*MGEN:Class.NameCap*/ : public ::
return threadStats;
}
- void aggregatePerThreadStats(struct PerThreadStats*);
+ void aggregatePerThreadStats(struct PerThreadStats*) const;
/*MGEN:ENDIF*/
public:
- static void writeSchema(::qpid::framing::Buffer& buf);
+ static void writeSchema(std::string& schema);
+ void mapEncodeValues(::qpid::types::Variant::Map& map,
+ bool includeProperties=true,
+ bool includeStatistics=true);
+ void mapDecodeValues(const ::qpid::types::Variant::Map& map);
+ void doMethod(std::string& methodName,
+ const ::qpid::types::Variant::Map& inMap,
+ ::qpid::types::Variant::Map& outMap);
+ std::string getKey() const;
+/*MGEN:IF(Root.GenQMFv1)*/
uint32_t writePropertiesSize() const;
- void readProperties(::qpid::framing::Buffer& buf);
- void writeProperties(::qpid::framing::Buffer& buf) const;
- void writeStatistics(::qpid::framing::Buffer& buf, bool skipHeaders = false);
+ void readProperties(const std::string& buf);
+ void writeProperties(std::string& buf) const;
+ void writeStatistics(std::string& buf, bool skipHeaders = false);
void doMethod(std::string& methodName,
- ::qpid::framing::Buffer& inBuf,
- ::qpid::framing::Buffer& outBuf);
- std::string getKey() const;
+ const std::string& inBuf,
+ std::string& outBuf);
+/*MGEN:ENDIF*/
+
writeSchemaCall_t getWriteSchemaCall() { return writeSchema; }
/*MGEN:IF(Class.NoStatistics)*/
// Stub for getInstChanged. There are no statistics in this class.
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.cpp?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.cpp (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.cpp Wed Mar 31 21:13:12 2010
@@ -21,13 +21,13 @@
/*MGEN:Root.Disclaimer*/
#include "qpid/log/Statement.h"
-#include "qpid/framing/FieldTable.h"
#include "qpid/management/Manageable.h"
+#include "qpid/framing/FieldTable.h"
+#include "qpid/framing/Buffer.h"
#include "qpid//*MGEN:Event.AgentHeaderLocation*//ManagementAgent.h"
#include "Event/*MGEN:Event.NameCap*/.h"
using namespace qmf::/*MGEN:Event.Namespace*/;
-using namespace qpid::framing;
using qpid::management::ManagementAgent;
using qpid::management::Manageable;
using qpid::management::ManagementObject;
@@ -56,23 +56,45 @@ void Event/*MGEN:Event.NameCap*/::regist
agent->registerEvent(packageName, eventName, md5Sum, writeSchema);
}
-void Event/*MGEN:Event.NameCap*/::writeSchema (Buffer& buf)
+void Event/*MGEN:Event.NameCap*/::writeSchema (std::string& schema)
{
- FieldTable ft;
+ const int _bufSize = 65536;
+ char _msgChars[_bufSize];
+ ::qpid::framing::Buffer buf(_msgChars, _bufSize);
+ ::qpid::framing::FieldTable ft;
// Schema class header:
buf.putOctet (CLASS_KIND_EVENT);
buf.putShortString (packageName); // Package Name
buf.putShortString (eventName); // Event Name
buf.putBin128 (md5Sum); // Schema Hash
- buf.putOctet (0); // No Superclass
buf.putShort (/*MGEN:Event.ArgCount*/); // Argument Count
// Arguments
/*MGEN:Event.ArgSchema*/
+ {
+ uint32_t _len = buf.getPosition();
+ buf.reset();
+ buf.getRawData(schema, _len);
+ }
}
-void Event/*MGEN:Event.NameCap*/::encode(::qpid::framing::Buffer& buf) const
+void Event/*MGEN:Event.NameCap*/::encode(std::string& _sBuf) const
{
+ const int _bufSize=65536;
+ char _msgChars[_bufSize];
+ ::qpid::framing::Buffer buf(_msgChars, _bufSize);
+
/*MGEN:Event.ArgEncodes*/
+
+ uint32_t _bufLen = buf.getPosition();
+ buf.reset();
+
+ buf.getRawData(_sBuf, _bufLen);
+}
+
+void Event/*MGEN:Event.NameCap*/::mapEncode(::qpid::types::Variant::Map& map) const
+{
+ using namespace ::qpid::types;
+/*MGEN:Event.ArgMap*/
}
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.h?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.h (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Event.h Wed Mar 31 21:13:12 2010
@@ -24,8 +24,6 @@
/*MGEN:Root.Disclaimer*/
#include "qpid/management/ManagementEvent.h"
-#include "qpid/framing/FieldTable.h"
-#include "qpid/framing/Uuid.h"
namespace qmf {
/*MGEN:Event.OpenNamespaces*/
@@ -33,10 +31,10 @@ namespace qmf {
class Event/*MGEN:Event.NameCap*/ : public ::qpid::management::ManagementEvent
{
private:
- static void writeSchema (::qpid::framing::Buffer& buf);
+ static void writeSchema (std::string& schema);
static std::string packageName;
static std::string eventName;
- static uint8_t md5Sum[16];
+ static uint8_t md5Sum[MD5_LEN];
/*MGEN:Event.ArgDeclarations*/
@@ -51,7 +49,8 @@ class Event/*MGEN:Event.NameCap*/ : publ
std::string& getEventName() const { return eventName; }
uint8_t* getMd5Sum() const { return md5Sum; }
uint8_t getSeverity() const { return /*MGEN:Event.Severity*/; }
- void encode(::qpid::framing::Buffer& buffer) const;
+ void encode(std::string& buffer) const;
+ void mapEncode(::qpid::types::Variant::Map& map) const;
};
}/*MGEN:Event.CloseNamespaces*/
Modified: qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp?rev=929716&r1=929715&r2=929716&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp Wed Mar 31 21:13:12 2010
@@ -23,6 +23,7 @@
#include "qpid/Plugin.h"
#include "qpid/Options.h"
#include "qpid/log/Logger.h"
+#include "qpid/types/Variant.h"
#include "qmf/org/apache/qpid/acl/Package.h"
#include "qmf/org/apache/qpid/acl/EventAllow.h"
#include "qmf/org/apache/qpid/acl/EventDeny.h"
@@ -94,7 +95,7 @@ Acl::Acl (AclValues& av, Broker& b): acl
" ObjectType:" << AclHelper::getObjectTypeStr(objType) << " Name:" << name );
agent->raiseEvent(_qmf::EventAllow(id, AclHelper::getActionStr(action),
AclHelper::getObjectTypeStr(objType),
- name, framing::FieldTable()));
+ name, types::Variant::Map()));
case ALLOW:
return true;
case DENY:
@@ -106,7 +107,7 @@ Acl::Acl (AclValues& av, Broker& b): acl
QPID_LOG(info, "ACL Deny id:" << id << " action:" << AclHelper::getActionStr(action) << " ObjectType:" << AclHelper::getObjectTypeStr(objType) << " Name:" << name);
agent->raiseEvent(_qmf::EventDeny(id, AclHelper::getActionStr(action),
AclHelper::getObjectTypeStr(objType),
- name, framing::FieldTable()));
+ name, types::Variant::Map()));
return false;
}
return false;
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org