qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eal...@apache.org
Subject svn commit: r1651216 - /qpid/trunk/qpid/tools/src/py/qpid-route
Date Mon, 12 Jan 2015 22:18:34 GMT
Author: eallen
Date: Mon Jan 12 22:18:34 2015
New Revision: 1651216

URL: http://svn.apache.org/r1651216
Log:
QPID-6013 qpid-route should warn when a federation link was not created successfully

Modified:
    qpid/trunk/qpid/tools/src/py/qpid-route

Modified: qpid/trunk/qpid/tools/src/py/qpid-route
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-route?rev=1651216&r1=1651215&r2=1651216&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-route (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-route Mon Jan 12 22:18:34 2015
@@ -25,6 +25,7 @@ import socket
 import os
 import locale
 from qmf.console import Session, BrokerURL
+from time import sleep
 
 usage = """
 Usage:  qpid-route [OPTIONS] dynamic add <dest-broker> <src-broker> <exchange>
[tag] [exclude-list] [mechanism]
@@ -184,6 +185,21 @@ class RouteManager:
                 return link
         return None
 
+    def checkLink(self, link):
+        retry = 3
+        while link is None or (link.state in ("Waiting", "Connecting", "Closing") and retry
> 0):
+            sleep(1)
+            link = self.getLink()
+            retry -= 1
+
+        if link == None:
+            raise Exception("Link failed to create")
+
+        if link.state == "Failed":
+            raise Exception("Link failed to create %s" % (link.lastError or ""))
+        elif config._verbose:
+            print "Link state is", link.state
+
     def addLink(self, remoteBroker, interbroker_mechanism=""):
         self.remote = BrokerURL(remoteBroker)
         if self.local.match(self.remote.host, self.remote.port):
@@ -196,8 +212,6 @@ class RouteManager:
             res = broker.connect(self.remote.host, self.remote.port, config._durable,
                                  interbroker_mechanism, self.remote.authName or "", self.remote.authPass
or "",
                                  config._transport)
-            if config._verbose:
-                print "Connect method returned:", res.status, res.text
 
     def delLink(self, remoteBroker):
         self.remote = BrokerURL(remoteBroker)
@@ -321,8 +335,7 @@ class RouteManager:
 
         self.addLink(remoteBroker, interbroker_mechanism)
         link = self.getLink()
-        if link == None:
-            raise Exception("Link failed to create")
+        self.checkLink(link)
 
         bridges = self.agent.getObjects(_class="bridge")
         for bridge in bridges:
@@ -345,8 +358,7 @@ class RouteManager:
     def addQueueRoute(self, remoteBroker, interbroker_mechanism, exchange, queue ):
         self.addLink(remoteBroker, interbroker_mechanism)
         link = self.getLink()
-        if link == None:
-            raise Exception("Link failed to create")
+        self.checkLink(link)
 
         bridges = self.agent.getObjects(_class="bridge")
         for bridge in bridges:
@@ -537,6 +549,7 @@ def main(argv=None):
                 interbroker_mechanism = ""
                 if nargs > 4: interbroker_mechanism = args[4]
                 rm.addLink(remoteBroker, interbroker_mechanism)
+                rm.checkLink(rm.getLink())
             elif cmd == "del":
                 if nargs != 4:
                     Usage()



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message