Author: gsim
Date: Tue Mar 1 16:32:46 2011
New Revision: 1075889
URL: http://svn.apache.org/viewvc?rev=1075889&view=rev
Log:
QPID-3091: add generic mechanism for adding and listing queue arguments
Modified:
qpid/trunk/qpid/tools/src/py/qpid-config
Modified: qpid/trunk/qpid/tools/src/py/qpid-config
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-config?rev=1075889&r1=1075888&r2=1075889&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-config (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-config Tue Mar 1 16:32:46 2011
@@ -101,6 +101,7 @@ class Config:
self._flowResumeCount = None
self._flowStopSize = None
self._flowResumeSize = None
+ self._extra_arguments = []
config = Config()
@@ -119,6 +120,13 @@ FLOW_STOP_COUNT = "qpid.flow_stop_coun
FLOW_RESUME_COUNT = "qpid.flow_resume_count"
FLOW_STOP_SIZE = "qpid.flow_stop_size"
FLOW_RESUME_SIZE = "qpid.flow_resume_size"
+#There are various arguments to declare that have specific program
+#options in this utility. However there is now a generic mechanism for
+#passing arguments as well. The SPECIAL_ARGS list contains the
+#arguments for which there are specific program options defined
+#i.e. the arguments for which there is special processing on add and
+#list
+SPECIAL_ARGS=[FILECOUNT,FILESIZE,MAX_QUEUE_SIZE,MAX_QUEUE_COUNT,POLICY_TYPE,CLUSTER_DURABLE,LVQ,LVQNB,MSG_SEQUENCE,IVE,QUEUE_EVENT_GENERATION,FLOW_STOP_COUNT,FLOW_STOP_SIZE,FLOW_RESUME_SIZE]
class JHelpFormatter(IndentedHelpFormatter):
"""Format usage and description without stripping newlines from usage
strings
@@ -178,6 +186,8 @@ def OptionsAndArguments(argv):
help="Turn on sender flow control when the number of
queued messages exceeds this value.")
group3.add_option("--flow-resume-count", action="store", type="int",
metavar="<n>",
help="Turn off sender flow control when the number of
queued messages drops below this value.")
+ group3.add_option("--argument", dest="extra_arguments", action="append",
default=[],
+ metavar="<NAME=VALUE>", help="Specify a key-value pair
to add to queue arguments")
# no option for declaring an exclusive queue - which can only be used by
the session that creates it.
parser.add_option_group(group3)
@@ -257,6 +267,8 @@ def OptionsAndArguments(argv):
config._flowStopCount = opts.flow_stop_count
if opts.flow_resume_count:
config._flowResumeCount = opts.flow_resume_count
+ if opts.extra_arguments:
+ config._extra_arguments = opts.extra_arguments
return args
@@ -419,7 +431,7 @@ class BrokerManager:
if FLOW_RESUME_SIZE in args: print "--flow-resume-size=%s" %
args[FLOW_RESUME_SIZE],
if FLOW_STOP_COUNT in args: print "--flow-stop-count=%s" %
args[FLOW_STOP_COUNT],
if FLOW_RESUME_COUNT in args: print "--flow-resume-count=%s" %
args[FLOW_RESUME_COUNT],
- print
+ print " ".join(["--argument %s=%s" % (k, v) for k,v in
args.iteritems() if not k in SPECIAL_ARGS])
def QueueListRecurse(self, filter):
exchanges = self.qmf.getObjects(_class="exchange",
_agent=self.brokerAgent)
@@ -464,6 +476,10 @@ class BrokerManager:
Usage()
qname = args[0]
declArgs = {}
+ for a in config._extra_arguments:
+ r = a.split("=", 1)
+ declArgs[r[0]] = r[1] if len(r) == 2 else None
+
if config._durable:
declArgs[FILECOUNT] = config._fileCount
declArgs[FILESIZE] = config._fileSize
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]