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/02/03 14:35:59 UTC

svn commit: r906038 - in /qpid/trunk/qpid/cpp: include/qpid/management/ managementgen/qmfgen/ managementgen/qmfgen/templates/ src/qpid/management/

Author: tross
Date: Wed Feb  3 13:35:58 2010
New Revision: 906038

URL: http://svn.apache.org/viewvc?rev=906038&view=rev
Log:
Changes to management code generation:

   1) Added readProperties(Buffer) method to ManagementObject to help in the 
      serialization and unserialization of data for cluster replication.
   2) Added hooks to ManagementObject and ObjectId to prepare for QMFv2 object
      naming.

Modified:
    qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h
    qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml
    qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py
    qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
    qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h
    qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp
    qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp

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=906038&r1=906037&r2=906038&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h Wed Feb  3 13:35:58 2010
@@ -51,6 +51,7 @@
     const AgentAttachment* agent;
     uint64_t first;
     uint64_t second;
+    std::string v2Key;
     void fromString(const std::string&);
 public:
     QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0) {}
@@ -63,6 +64,8 @@
     QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const;
     QPID_COMMON_EXTERN void encode(framing::Buffer& buffer);
     QPID_COMMON_EXTERN void decode(framing::Buffer& buffer);
+    QPID_COMMON_EXTERN void setV2Key(const std::string& key) { v2Key = key; }
+    QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; }
     friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&);
 };
 
@@ -128,6 +131,7 @@
 
     QPID_COMMON_EXTERN int  getThreadIndex();
     QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf);
+    QPID_COMMON_EXTERN void readTimestamps(qpid::framing::Buffer& buf);
 
   public:
     QPID_COMMON_EXTERN static int maxThreads;
@@ -141,12 +145,14 @@
     virtual ~ManagementObject() {}
 
     virtual writeSchemaCall_t getWriteSchemaCall() = 0;
+    virtual void readProperties(qpid::framing::Buffer& buf) = 0;
     virtual void writeProperties(qpid::framing::Buffer& buf) = 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;
     QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId);
 
     virtual std::string& getClassName() const = 0;

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=906038&r1=906037&r2=906038&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml Wed Feb  3 13:35:58 2010
@@ -19,38 +19,38 @@
   under the License.
 -->
 
-<type name="objId"     base="REF"       cpp="::qpid::management::ObjectId"  encode="#.encode(@)" decode="#.decode(@)"  accessor="direct" init="::qpid::management::ObjectId()" byRef="y"/>
-<type name="uint8"     base="U8"        cpp="uint8_t"       encode="@.putOctet(#)"       decode="# = @.getOctet()"     accessor="direct" init="0"/>
-<type name="uint16"    base="U16"       cpp="uint16_t"      encode="@.putShort(#)"       decode="# = @.getShort()"     accessor="direct" init="0"/>
-<type name="uint32"    base="U32"       cpp="uint32_t"      encode="@.putLong(#)"        decode="# = @.getLong()"      accessor="direct" init="0"/>
-<type name="uint64"    base="U64"       cpp="uint64_t"      encode="@.putLongLong(#)"    decode="# = @.getLongLong()"  accessor="direct" init="0"/>
-<type name="int8"      base="S8"        cpp="int8_t"        encode="@.putInt8(#)"        decode="# = @.getInt8()"      accessor="direct" init="0"/>
-<type name="int16"     base="S16"       cpp="int16_t"       encode="@.putInt16(#)"       decode="# = @.getInt16()"     accessor="direct" init="0"/>
-<type name="int32"     base="S32"       cpp="int32_t"       encode="@.putInt32(#)"       decode="# = @.getInt32()"     accessor="direct" init="0"/>
-<type name="int64"     base="S64"       cpp="int64_t"       encode="@.putInt64(#)"       decode="# = @.getInt64()"     accessor="direct" init="0"/>
-<type name="bool"      base="BOOL"      cpp="uint8_t"       encode="@.putOctet(#?1:0)"   decode="# = @.getOctet()==1"  accessor="direct" init="0"/>
-<type name="sstr"      base="SSTR"      cpp="std::string"   encode="@.putShortString(#)" decode="@.getShortString(#)"  accessor="direct" init='""' byRef="y"/>
-<type name="lstr"      base="LSTR"      cpp="std::string"   encode="@.putMediumString(#)" decode="@.getMediumString(#)" accessor="direct" init='""' byRef="y"/>
-<type name="absTime"   base="ABSTIME"   cpp="int64_t"       encode="@.putLongLong(#)"    decode="# = @.getLongLong()"  accessor="direct" init="0"/>
-<type name="deltaTime" base="DELTATIME" cpp="uint64_t"      encode="@.putLongLong(#)"    decode="# = @.getLongLong()"  accessor="direct" init="0"/>
-<type name="float"     base="FLOAT"     cpp="float"         encode="@.putFloat(#)"       decode="# = @.getFloat()"     accessor="direct" init="0."/>
-<type name="double"    base="DOUBLE"    cpp="double"        encode="@.putDouble(#)"      decode="# = @.getDouble()"    accessor="direct" init="0."/>
-<type name="uuid"      base="UUID"      cpp="::qpid::framing::Uuid" encode="#.encode(@)"       decode="#.decode(@)"    accessor="direct" init="::qpid::framing::Uuid()" byRef="y"/>
-<type name="map"       base="FTABLE"    cpp="::qpid::framing::FieldTable" encode="#.encode(@)" decode="#.decode(@)"    accessor="direct" init="::qpid::framing::FieldTable()" byRef="y"/>
+<type name="objId"     base="REF"       cpp="::qpid::management::ObjectId"  encode="#.encode(@)" decode="#.decode(@)"  stream="#.getV2Key()" accessor="direct" init="::qpid::management::ObjectId()" byRef="y"/>
+<type name="uint8"     base="U8"        cpp="uint8_t"       encode="@.putOctet(#)"       decode="# = @.getOctet()"     stream="#" accessor="direct" init="0"/>
+<type name="uint16"    base="U16"       cpp="uint16_t"      encode="@.putShort(#)"       decode="# = @.getShort()"     stream="#" accessor="direct" init="0"/>
+<type name="uint32"    base="U32"       cpp="uint32_t"      encode="@.putLong(#)"        decode="# = @.getLong()"      stream="#" accessor="direct" init="0"/>
+<type name="uint64"    base="U64"       cpp="uint64_t"      encode="@.putLongLong(#)"    decode="# = @.getLongLong()"  stream="#" accessor="direct" init="0"/>
+<type name="int8"      base="S8"        cpp="int8_t"        encode="@.putInt8(#)"        decode="# = @.getInt8()"      stream="#" accessor="direct" init="0"/>
+<type name="int16"     base="S16"       cpp="int16_t"       encode="@.putInt16(#)"       decode="# = @.getInt16()"     stream="#" accessor="direct" init="0"/>
+<type name="int32"     base="S32"       cpp="int32_t"       encode="@.putInt32(#)"       decode="# = @.getInt32()"     stream="#" accessor="direct" init="0"/>
+<type name="int64"     base="S64"       cpp="int64_t"       encode="@.putInt64(#)"       decode="# = @.getInt64()"     stream="#" accessor="direct" init="0"/>
+<type name="bool"      base="BOOL"      cpp="uint8_t"       encode="@.putOctet(#?1:0)"   decode="# = @.getOctet()==1"  stream="#" accessor="direct" init="0"/>
+<type name="sstr"      base="SSTR"      cpp="std::string"   encode="@.putShortString(#)" decode="@.getShortString(#)"  stream="#" accessor="direct" init='""' byRef="y"/>
+<type name="lstr"      base="LSTR"      cpp="std::string"   encode="@.putMediumString(#)" decode="@.getMediumString(#)" stream="#" accessor="direct" init='""' byRef="y"/>
+<type name="absTime"   base="ABSTIME"   cpp="int64_t"       encode="@.putLongLong(#)"    decode="# = @.getLongLong()"  stream="#" accessor="direct" init="0"/>
+<type name="deltaTime" base="DELTATIME" cpp="uint64_t"      encode="@.putLongLong(#)"    decode="# = @.getLongLong()"  stream="#" accessor="direct" init="0"/>
+<type name="float"     base="FLOAT"     cpp="float"         encode="@.putFloat(#)"       decode="# = @.getFloat()"     stream="#" accessor="direct" init="0."/>
+<type name="double"    base="DOUBLE"    cpp="double"        encode="@.putDouble(#)"      decode="# = @.getDouble()"    stream="#" accessor="direct" init="0."/>
+<type name="uuid"      base="UUID"      cpp="::qpid::framing::Uuid" encode="#.encode(@)"       decode="#.decode(@)"    stream="#" accessor="direct" init="::qpid::framing::Uuid()" byRef="y"/>
+<type name="map"       base="FTABLE"    cpp="::qpid::framing::FieldTable" encode="#.encode(@)" decode="#.decode(@)"    stream="#" accessor="direct" init="::qpid::framing::FieldTable()" byRef="y"/>
 
-<type name="hilo8"   base="U8"   cpp="uint8_t"  encode="@.putOctet(#)"    decode="# = @.getOctet()"    style="wm" accessor="counter" init="0"/>
-<type name="hilo16"  base="U16"  cpp="uint16_t" encode="@.putShort(#)"    decode="# = @.getShort()"    style="wm" accessor="counter" init="0"/>
-<type name="hilo32"  base="U32"  cpp="uint32_t" encode="@.putLong(#)"     decode="# = @.getLong()"     style="wm" accessor="counter" init="0"/>
-<type name="hilo64"  base="U64"  cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="wm" accessor="counter" init="0"/>
+<type name="hilo8"   base="U8"   cpp="uint8_t"  encode="@.putOctet(#)"    decode="# = @.getOctet()"    style="wm" stream="#" accessor="counter" init="0"/>
+<type name="hilo16"  base="U16"  cpp="uint16_t" encode="@.putShort(#)"    decode="# = @.getShort()"    style="wm" stream="#" accessor="counter" init="0"/>
+<type name="hilo32"  base="U32"  cpp="uint32_t" encode="@.putLong(#)"     decode="# = @.getLong()"     style="wm" stream="#" accessor="counter" init="0"/>
+<type name="hilo64"  base="U64"  cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="wm" stream="#" accessor="counter" init="0"/>
 
-<type name="count8"  base="U8"   cpp="uint8_t"  encode="@.putOctet(#)"    decode="# = @.getOctet()"    accessor="counter" init="0" perThread="y"/>
-<type name="count16" base="U16"  cpp="uint16_t" encode="@.putShort(#)"    decode="# = @.getShort()"    accessor="counter" init="0" perThread="y"/>
-<type name="count32" base="U32"  cpp="uint32_t" encode="@.putLong(#)"     decode="# = @.getLong()"     accessor="counter" init="0" perThread="y"/>
-<type name="count64" base="U64"  cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" accessor="counter" init="0" perThread="y"/>
+<type name="count8"  base="U8"   cpp="uint8_t"  encode="@.putOctet(#)"    decode="# = @.getOctet()"    stream="#" accessor="counter" init="0" perThread="y"/>
+<type name="count16" base="U16"  cpp="uint16_t" encode="@.putShort(#)"    decode="# = @.getShort()"    stream="#" accessor="counter" init="0" perThread="y"/>
+<type name="count32" base="U32"  cpp="uint32_t" encode="@.putLong(#)"     decode="# = @.getLong()"     stream="#" accessor="counter" init="0" perThread="y"/>
+<type name="count64" base="U64"  cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" accessor="counter" init="0" perThread="y"/>
 
 <!-- Min/Max/Average statistics -->
-<type name="mma32"   base="U32"       cpp="uint32_t" encode="@.putLong(#)"     decode="# = @.getLong()"     style="mma" accessor="direct" init="0" perThread="y"/>
-<type name="mma64"   base="U64"       cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" accessor="direct" init="0" perThread="y"/>
-<type name="mmaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" accessor="direct" init="0" perThread="y"/>
+<type name="mma32"   base="U32"       cpp="uint32_t" encode="@.putLong(#)"     decode="# = @.getLong()"     style="mma" stream="#" accessor="direct" init="0" perThread="y"/>
+<type name="mma64"   base="U64"       cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" stream="#" accessor="direct" init="0" perThread="y"/>
+<type name="mmaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" stream="#" accessor="direct" init="0" perThread="y"/>
 
 </schema-types>

Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py?rev=906038&r1=906037&r2=906038&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py Wed Feb  3 13:35:58 2010
@@ -58,6 +58,7 @@
     self.encode    = None
     self.decode    = None
     self.style     = "normal"
+    self.stream    = "#"
     self.accessor  = None
     self.init      = "0"
     self.perThread = False
@@ -85,6 +86,9 @@
       elif key == 'style':
         self.style = val
 
+      elif key == 'stream':
+        self.stream = val
+
       elif key == 'accessor':
         self.accessor = val
 
@@ -200,6 +204,9 @@
       stream.write ("        threadStats->" + varName + "Min   = std::numeric_limits<" + cpptype + ">::max();\n")
       stream.write ("        threadStats->" + varName + "Max   = std::numeric_limits<" + cpptype + ">::min();\n")
 
+  def genRead (self, stream, varName, indent="    "):
+    stream.write(indent + self.decode.replace("@", "buf").replace("#", varName) + ";\n")
+
   def genWrite (self, stream, varName, indent="    "):
     if self.style != "mma":
       stream.write (indent + self.encode.replace ("@", "buf").replace ("#", varName) + ";\n")
@@ -381,6 +388,15 @@
       stream.write ("    ft.setString (DESC,   \"" + self.desc   + "\");\n")
     stream.write ("    buf.put (ft);\n\n")
 
+  def genRead (self, stream):
+    indent = "    "
+    if self.isOptional:
+      stream.write("    if (presenceMask[presenceByte_%s] & presenceMask_%s) {\n" % (self.name, self.name))
+      indent = "        "
+    self.type.type.genRead (stream, self.name, indent)
+    if self.isOptional:
+      stream.write("    }\n")
+
   def genWrite (self, stream):
     indent = "    "
     if self.isOptional:
@@ -1054,6 +1070,19 @@
       if element.type.type.perThread:
         element.genDeclaration (stream, "        ")
 
+  def genPrimaryKey (self, stream, variables):
+    first = 1
+    for prop in self.properties:
+      if prop.isIndex == 1:
+        if first:
+          first = None
+        else:
+          stream.write(" << \",\";\n")
+        var = prop.type.type.stream.replace("#", prop.getName())
+        stream.write("    key << %s" % var)
+    if not first:
+      stream.write(";")
+
   def genNamespace (self, stream, variables):
     stream.write("::".join(self.packageName.split(".")))
 
@@ -1182,6 +1211,10 @@
       if inst.type.type.perThread:
         inst.genAssign (stream)
 
+  def genReadProperties (self, stream, variables):
+    for prop in self.properties:
+      prop.genRead (stream)
+
   def genWriteProperties (self, stream, variables):
     for prop in self.properties:
       prop.genWrite (stream)

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=906038&r1=906037&r2=906038&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp Wed Feb  3 13:35:58 2010
@@ -26,6 +26,7 @@
 #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;
@@ -123,6 +124,17 @@
 }
 /*MGEN:ENDIF*/
 
+void /*MGEN:Class.NameCap*/::readProperties (Buffer& buf)
+{
+    ::qpid::sys::Mutex::ScopedLock mutex(accessLock);
+    readTimestamps(buf);
+/*MGEN:IF(Class.ExistOptionals)*/
+    for (uint8_t idx = 0; idx < /*MGEN:Class.PresenceMaskBytes*/; idx++)
+        presenceMask[idx] = buf.getOctet();
+/*MGEN:ENDIF*/
+/*MGEN:Class.ReadProperties*/
+}
+
 void /*MGEN:Class.NameCap*/::writeProperties (Buffer& buf)
 {
     ::qpid::sys::Mutex::ScopedLock mutex(accessLock);
@@ -178,3 +190,12 @@
     outBuf.putLong(status);
     outBuf.putShortString(Manageable::StatusText(status, text));
 }
+
+std::string /*MGEN:Class.NameCap*/::getKey() const
+{
+    std::stringstream key;
+
+/*MGEN:Class.PrimaryKey*/
+    return key.str();
+}
+

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=906038&r1=906037&r2=906038&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h Wed Feb  3 13:35:58 2010
@@ -75,12 +75,14 @@
 /*MGEN:ENDIF*/
     // Private Methods
     static void writeSchema(::qpid::framing::Buffer& buf);
+    void readProperties(::qpid::framing::Buffer& buf);
     void writeProperties(::qpid::framing::Buffer& buf);
     void writeStatistics(::qpid::framing::Buffer& buf,
                          bool skipHeaders = false);
     void doMethod(std::string& methodName,
                   ::qpid::framing::Buffer& inBuf,
                   ::qpid::framing::Buffer& outBuf);
+    std::string getKey() const;
     writeSchemaCall_t getWriteSchemaCall() { return writeSchema; }
 /*MGEN:IF(Class.NoStatistics)*/
     // Stub for getInstChanged.  There are no statistics in this class.

Modified: qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp?rev=906038&r1=906037&r2=906038&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp Wed Feb  3 13:35:58 2010
@@ -194,6 +194,7 @@
     }
 
     ObjectId objId(0 /*flags*/ , sequence, brokerBank, 0, objectNum);
+    objId.setV2Key(object->getKey());
 
     object->setObjectId(objId);
     newManagementObjects[objId] = object;

Modified: qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp?rev=906038&r1=906037&r2=906038&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp Wed Feb  3 13:35:58 2010
@@ -169,6 +169,21 @@
     objectId.encode(buf);
 }
 
+void ManagementObject::readTimestamps (framing::Buffer& buf)
+{
+    std::string unused;
+    uint8_t unusedUuid[16];
+    ObjectId unusedObjectId;
+
+    buf.getShortString(unused);
+    buf.getShortString(unused);
+    buf.getBin128(unusedUuid);
+    updateTime = buf.getLongLong();
+    createTime = buf.getLongLong();
+    destroyTime = buf.getLongLong();
+    unusedObjectId.decode(buf);
+}
+
 void ManagementObject::setReference(ObjectId) {}
 
 int ManagementObject::getThreadIndex() {



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org