diff options
author | Alan Conway <aconway@apache.org> | 2008-01-07 16:28:07 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-01-07 16:28:07 +0000 |
commit | 168f40831104bc954cadba17d08544c08c858b77 (patch) | |
tree | 42bb4c7f3585377c4575cd0b494267b6e083769a /qpid/python/mgmt-cli | |
parent | 6da6577b74339048993b75bda781917a357c9105 (diff) | |
download | qpid-python-168f40831104bc954cadba17d08544c08c858b77.tar.gz |
Patch from https://issues.apache.org/jira/browse/QPID-722 by Ted Ross:
Two changes in this patch:
1) Management object IDs are now persistent for persistent (durable) objects. This is required to provide continuity of historical management data across broker restarts. The format of object IDs now indicates whether they are transient or persistent. The upper bit (bit 63) is 0 for transient IDs and 1 for persistent IDs.
2) Changes have been made to the management code generator in preparation for allowing it to be used by outside projects that wish to use the broker Plugin API for management access.
File-by-file notes:
M python/mgmt-cli/managementdata.py
Enhanced user-friendly display of 64-bit object IDs to
differentiate between persistent IDs and non-persistent IDs.
M cpp/src/Makefile.am
Changed command line format for call to the management code
generator.
M cpp/src/qpid/broker/Broker.cpp
M cpp/src/qpid/broker/Vhost.cpp
M cpp/src/qpid/broker/Queue.cpp
Updated calls to ManagementAgent::addObject to use the new support
for persistent IDs, ensuring that the management object IDs for
persistent objects are themselves persistent.
M cpp/src/qpid/management/ManagementAgent.h
M cpp/src/qpid/management/ManagementAgent.cpp
Added support (using defaulted arguments) to
ManagementAgent::addObject for persistent object IDs
M cpp/managementgen/generate.py
M cpp/managementgen/schema.py
M cpp/managementgen/main.py
Added the ability for templates to set variables to be used during
code generation.
Makefile fragment is now generated using a template rather than
hard-code. This was done to help non-qpid code to use the code
generator for management-via-qpid support.
M cpp/managementgen/templates/Args.h
M cpp/managementgen/templates/Class.cpp
M cpp/managementgen/templates/Class.h
Use a generator variable to define the comment prefix.
A cpp/managementgen/templates/Makefile.mk
New template for the qpid makefile fragment.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@609672 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python/mgmt-cli')
-rw-r--r-- | qpid/python/mgmt-cli/managementdata.py | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/qpid/python/mgmt-cli/managementdata.py b/qpid/python/mgmt-cli/managementdata.py index 419cbd13c0..e7233c98ae 100644 --- a/qpid/python/mgmt-cli/managementdata.py +++ b/qpid/python/mgmt-cli/managementdata.py @@ -44,6 +44,21 @@ class ManagementData: # element :== (<element-name>, <element-value>) # + def registerObjId (self, objId): + if self.baseId == 0: + if objId & 0x8000000000000000L == 0: + self.baseId = objId - 1000 + + def displayObjId (self, objId): + if objId & 0x8000000000000000L == 0: + return objId - self.baseId + return (objId & 0x7fffffffffffffffL) + 5000 + + def rawObjId (self, displayId): + if displayId < 5000: + return displayId + self.baseId + return displayId - 5000 + 0x8000000000000000L + def dataHandler (self, context, className, list, timestamps): """ Callback for configuration and instrumentation data updates """ self.lock.acquire () @@ -53,10 +68,9 @@ class ManagementData: if className not in self.tables: self.tables[className] = {} - # Calculate a base-id so displayed IDs are reasonable 4-digit numbers + # Register the ID so a more friendly presentation can be displayed id = long (list[0][1]) - if self.baseId == 0: - self.baseId = id - 1000 + self.registerObjId (id) # If this object hasn't been seen before, create a new object record with # the timestamps and empty lists for configuration and instrumentation data. @@ -129,7 +143,7 @@ class ManagementData: def refName (self, oid): if oid == 0: return "NULL" - return str (oid - self.baseId) + return str (self.displayObjId (oid)) def valueDisplay (self, className, key, value): for kind in range (2): @@ -244,12 +258,12 @@ class ManagementData: list = [] if tokens[0] == "all": for id in self.tables[className]: - list.append (id - self.baseId) + list.append (self.displayObjId (id)) elif tokens[0] == "active": for id in self.tables[className]: if self.tables[className][id][0][2] == 0: - list.append (id - self.baseId) + list.append (self.displayObjId (id)) else: for token in tokens: @@ -257,7 +271,7 @@ class ManagementData: if token.find ("-") != -1: ids = token.split("-", 2) for id in range (int (ids[0]), int (ids[1]) + 1): - if self.getClassForId (long (id) + self.baseId) == className: + if self.getClassForId (self.rawObjId (long (id))) == className: list.append (id) else: list.append (token) @@ -329,7 +343,7 @@ class ManagementData: else: rootId = int (tokens[0]) - className = self.getClassForId (rootId + self.baseId) + className = self.getClassForId (self.rawObjId (rootId)) remaining = tokens if className == None: print "Id not known: %d" % int (tokens[0]) @@ -348,8 +362,8 @@ class ManagementData: ids = [] for id in userIds: - if self.getClassForId (long (id) + self.baseId) == className: - ids.append (long (id) + self.baseId) + if self.getClassForId (self.rawObjId (long (id))) == className: + ids.append (self.rawObjId (long (id))) rows = [] timestamp = None @@ -481,7 +495,7 @@ class ManagementData: self.lock.acquire () methodOk = True try: - className = self.getClassForId (userOid + self.baseId) + className = self.getClassForId (self.rawObjId (userOid)) if className == None: raise ValueError () @@ -505,7 +519,7 @@ class ManagementData: self.lock.release () if methodOk: # try: - self.broker.method (self.methodSeq, userOid + self.baseId, className, + self.broker.method (self.methodSeq, self.rawObjId (userOid), className, methodName, namedArgs) # except ValueError, e: # print "Error invoking method:", e |