summaryrefslogtreecommitdiff
path: root/qpid/python/commands/qpid-cluster
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2009-06-26 12:57:43 +0000
committerTed Ross <tross@apache.org>2009-06-26 12:57:43 +0000
commitaa655f892b92c0295d4c97f011b05353d68b546f (patch)
treee926440ad514a7d17566e742dd8039ddf4db6b92 /qpid/python/commands/qpid-cluster
parentfa9b863c9085a1397348fb3d5aa563faa54cb213 (diff)
downloadqpid-python-aa655f892b92c0295d4c97f011b05353d68b546f.tar.gz
Added --timeout options to cli tools.
Cli tools will not hang indefinitely if the broker is non-responsive. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@788681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python/commands/qpid-cluster')
-rwxr-xr-xqpid/python/commands/qpid-cluster14
1 files changed, 10 insertions, 4 deletions
diff --git a/qpid/python/commands/qpid-cluster b/qpid/python/commands/qpid-cluster
index 07fa666041..f196a6e2b0 100755
--- a/qpid/python/commands/qpid-cluster
+++ b/qpid/python/commands/qpid-cluster
@@ -28,6 +28,7 @@ import re
from qmf.console import Session
_host = "localhost"
+_connTimeout = 10
_stopId = None
_stopAll = False
_force = False
@@ -42,6 +43,7 @@ def Usage ():
print " ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost"
print
print "Options:"
+ print " --timeout seconds (10) Maximum time to wait for broker connection"
print " -C [--all-connections] View client connections to all cluster members"
print " -c [--connections] ID View client connections to specified member"
print " -d [--del-connection] HOST:PORT"
@@ -88,7 +90,7 @@ class BrokerManager:
def SetBroker(self, brokerUrl):
self.url = brokerUrl
self.qmf = Session()
- self.broker = self.qmf.addBroker(brokerUrl)
+ self.broker = self.qmf.addBroker(brokerUrl, _connTimeout)
agents = self.qmf.getAgents()
for a in agents:
if a.getAgentBank() == 0:
@@ -200,7 +202,7 @@ class BrokerManager:
idx = 0
for host in hostList:
if _showConn == "all" or _showConn == idList[idx] or _delConn:
- self.brokers.append(self.qmf.addBroker(host))
+ self.brokers.append(self.qmf.addBroker(host, _connTimeout))
displayList.append(idList[idx])
idx += 1
@@ -247,7 +249,7 @@ class BrokerManager:
##
try:
- longOpts = ("stop=", "all-stop", "force", "connections=", "all-connections" "del-connection=", "numeric")
+ longOpts = ("stop=", "all-stop", "force", "connections=", "all-connections" "del-connection=", "numeric", "timeout=")
(optlist, encArgs) = getopt.gnu_getopt(sys.argv[1:], "s:kfCc:d:n", longOpts)
except:
Usage()
@@ -260,6 +262,10 @@ except:
count = 0
for opt in optlist:
+ if opt[0] == "--timeout":
+ _connTimeout = int(opt[1])
+ if _connTimeout == 0:
+ _connTimeout = None
if opt[0] == "-s" or opt[0] == "--stop":
_stopId = opt[1]
if len(_stopId.split(":")) != 2:
@@ -316,7 +322,7 @@ except Exception,e:
if e.__repr__().find("connection aborted") > 0:
# we expect this when asking the connected broker to shut down
sys.exit(0)
- print "Failed:", e.args
+ print "Failed: %s - %s" % (e.__class__.__name__, e)
sys.exit(1)
bm.Disconnect()