diff options
author | Ted Ross <tross@apache.org> | 2008-10-24 15:12:53 +0000 |
---|---|---|
committer | Ted Ross <tross@apache.org> | 2008-10-24 15:12:53 +0000 |
commit | a482cc67a7764ca791084283c0076b0397f6e153 (patch) | |
tree | d3f389bda1087fb29524da7b817d27dd86312af1 /python/commands | |
parent | f5997e515738fabd366a90d4352bfe7d9d60abb6 (diff) | |
download | qpid-python-a482cc67a7764ca791084283c0076b0397f6e153.tar.gz |
Added exchange options to qpid-config
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@707651 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/commands')
-rwxr-xr-x | python/commands/qpid-config | 83 |
1 files changed, 59 insertions, 24 deletions
diff --git a/python/commands/qpid-config b/python/commands/qpid-config index e7f866edcc..6917d4c5c0 100755 --- a/python/commands/qpid-config +++ b/python/commands/qpid-config @@ -35,6 +35,8 @@ _maxQueueCount = None _policyType = None _lvq = False _optimisticConsume = False +_msgSequence = False +_ive = False FILECOUNT = "qpid.file_count" FILESIZE = "qpid.file_size" @@ -44,6 +46,8 @@ POLICY_TYPE = "qpid.policy_type" CLUSTER_DURABLE = "qpid.persist_last_node" LVQ = "qpid.last_value_queue" OPTIMISTIC_CONSUME = "qpid.optimistic_consume" +MSG_SEQUENCE = "qpid.msg_sequence" +IVE = "qpid.ive" def Usage (): print "Usage: qpid-config [OPTIONS]" @@ -74,7 +78,12 @@ def Usage (): print " --optimistic-consume Enable optimistic consume on the queue" print print "Add Exchange Options:" - print " --durable Exchange is durable" + print " --durable Exchange is durable" + print " --sequence Exchange will insert a 'qpid.msg_sequence' field in the message header" + print " with a value that increments for each message forwarded." + print " --ive Exchange will behave as an 'initial-value-exchange', keeping a reference" + print " to the last message forwarded and enqueuing that message to newly bound" + print " queues." print sys.exit (1) @@ -116,11 +125,26 @@ class BrokerManager: def ExchangeList (self, filter): exchanges = self.qmf.getObjects(_class="exchange") - print "Durable Type Bindings Exchange Name" - print "=======================================================" + caption1 = "Type " + caption2 = "Exchange Name" + maxNameLen = len(caption2) + for ex in exchanges: + if self.match(ex.name, filter): + if len(ex.name) > maxNameLen: maxNameLen = len(ex.name) + print "%s%-*s Attributes" % (caption1, maxNameLen, caption2) + line = "" + for i in range(((maxNameLen + len(caption1)) / 5) + 5): + line += "=====" + print line + for ex in exchanges: if self.match (ex.name, filter): - print "%4c %-10s%5d %s" % (YN (ex.durable), ex.type, ex.bindingCount, ex.name) + print "%-10s%-*s " % (ex.type, maxNameLen, ex.name), + args = ex.arguments + if ex.durable: print "--durable", + if MSG_SEQUENCE in args and args[MSG_SEQUENCE] == 1: print "--sequence", + if IVE in args and args[IVE] == 1: print "--ive", + print def ExchangeListRecurse (self, filter): exchanges = self.qmf.getObjects(_class="exchange") @@ -144,7 +168,8 @@ class BrokerManager: caption = "Queue Name" maxNameLen = len(caption) for q in queues: - if len(q.name) > maxNameLen: maxNameLen = len(q.name) + if self.match (q.name, filter): + if len(q.name) > maxNameLen: maxNameLen = len(q.name) print "%-*s Attributes" % (maxNameLen, caption) line = "" for i in range((maxNameLen / 5) + 5): @@ -152,20 +177,21 @@ class BrokerManager: print line for q in queues: - print "%-*s " % (maxNameLen, q.name), - args = q.arguments - if q.durable: print "durable", - if CLUSTER_DURABLE in args and args[CLUSTER_DURABLE] == 1: print "clusterDurable", - if q.autoDelete: print "autoDel", - if q.exclusive: print "excl", - if FILESIZE in args: print "fileSize=%d" % args[FILESIZE], - if FILECOUNT in args: print "fileCount=%d" % args[FILECOUNT], - if MAX_QUEUE_SIZE in args: print "maxQSize=%d" % args[MAX_QUEUE_SIZE], - if MAX_QUEUE_COUNT in args: print "maxQCount=%d" % args[MAX_QUEUE_COUNT], - if POLICY_TYPE in args: print "policy=%s" % args[POLICY_TYPE], - if LVQ in args and args[LVQ] == 1: print "lvq", - if OPTIMISTIC_CONSUME in args and args[OPTIMISTIC_CONSUME] == 1: print "optConsume", - print + if self.match (q.name, filter): + print "%-*s " % (maxNameLen, q.name), + args = q.arguments + if q.durable: print "--durable", + if CLUSTER_DURABLE in args and args[CLUSTER_DURABLE] == 1: print "--cluster-durable", + if q.autoDelete: print "auto-del", + if q.exclusive: print "excl", + if FILESIZE in args: print "--file-size=%d" % args[FILESIZE], + if FILECOUNT in args: print "--file-count=%d" % args[FILECOUNT], + if MAX_QUEUE_SIZE in args: print "--max-queue-size=%d" % args[MAX_QUEUE_SIZE], + if MAX_QUEUE_COUNT in args: print "--max-queue-count=%d" % args[MAX_QUEUE_COUNT], + if POLICY_TYPE in args: print "--policy-type=%s" % args[POLICY_TYPE], + if LVQ in args and args[LVQ] == 1: print "--last-value-queue", + if OPTIMISTIC_CONSUME in args and args[OPTIMISTIC_CONSUME] == 1: print "--optimistic-consume", + print def QueueListRecurse (self, filter): exchanges = self.qmf.getObjects(_class="exchange") @@ -189,7 +215,12 @@ class BrokerManager: Usage () etype = args[0] ename = args[1] - self.broker.getAmqpSession().exchange_declare (exchange=ename, type=etype, durable=_durable) + declArgs = {} + if _msgSequence: + declArgs[MSG_SEQUENCE] = 1 + if _ive: + declArgs[IVE] = 1 + self.broker.getAmqpSession().exchange_declare (exchange=ename, type=etype, durable=_durable, arguments=declArgs) def DelExchange (self, args): if len (args) < 1: @@ -265,6 +296,7 @@ def YN (bool): return 'Y' return 'N' + ## ## Main Program ## @@ -272,7 +304,7 @@ def YN (bool): try: longOpts = ("durable", "cluster-durable", "bindings", "broker-addr=", "file-count=", "file-size=", "max-queue-size=", "max-queue-count=", "policy-type=", - "last-value-queue", "optimistic-consume") + "last-value-queue", "optimistic-consume", "sequence", "ive") (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], "a:b", longOpts) except: Usage () @@ -300,6 +332,10 @@ for opt in optlist: _lvq = True if opt[0] == "--optimistic-consume": _optimisticConsume = True + if opt[0] == "--sequence": + _msgSequence = True + if opt[0] == "--ive": + _ive = True nargs = len (cargs) bm = BrokerManager () @@ -313,12 +349,12 @@ try: modifier = "" if nargs > 1: modifier = cargs[1] - if cmd[0] == 'e': + if cmd == "exchanges": if _recursive: bm.ExchangeListRecurse (modifier) else: bm.ExchangeList (modifier) - elif cmd[0] == 'q': + elif cmd == "queues": if _recursive: bm.QueueListRecurse (modifier) else: @@ -344,7 +380,6 @@ try: else: Usage () except Exception,e: - raise print "Failed:", e.message sys.exit(1) |