Author: gsim
Date: Mon Oct 13 09:43:10 2008
New Revision: 704159

URL: http://svn.apache.org/viewvc?rev=704159&view=rev
Log:
Allow management clienst to specify transport to use for inter-broker links


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.h
    incubator/qpid/trunk/qpid/python/commands/qpid-route
    incubator/qpid/trunk/qpid/specs/management-schema.xml

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Mon Oct 13 
09:43:10 2008
@@ -341,15 +341,18 @@
         _qmf::ArgsBrokerConnect& hp=
             dynamic_cast<_qmf::ArgsBrokerConnect&>(args);
 
-        if (hp.i_useSsl)
-            return Manageable::STATUS_FEATURE_NOT_IMPLEMENTED;
+        string transport = hp.i_transport.empty() ? TCP_TRANSPORT : 
hp.i_transport;
+        if (!getProtocolFactory(transport)) {
+            QPID_LOG(error, "Transport '" << transport << "' not supported");
+            return  Manageable::STATUS_NOT_IMPLEMENTED;
+        }
+        QPID_LOG(info, "Connecting to " << hp.i_host << ":" << hp.i_port << " 
using '" << transport << "' as " << "'" << hp.i_username << "'");
 
         std::pair<Link::shared_ptr, bool> response =
-            links.declare (hp.i_host, hp.i_port, hp.i_useSsl, hp.i_durable,
+            links.declare (hp.i_host, hp.i_port, transport, hp.i_durable,
                            hp.i_authMechanism, hp.i_username, hp.i_password);
         if (hp.i_durable && response.second)
             store->create(*response.first);
-
         status = Manageable::STATUS_OK;
         break;
       }
@@ -398,7 +401,7 @@
 {
     boost::shared_ptr<ProtocolFactory> pf = getProtocolFactory(transport);
     if (pf) pf->connect(poller, host, port, f ? f : factory.get(), failed);
-    else throw Exception(QPID_MSG("Unsupported transport type: " << 
transport));
+    else throw NoSuchTransportException(QPID_MSG("Unsupported transport type: 
" << transport));
 }
 
 void Broker::connect(

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h Mon Oct 13 09:43:10 
2008
@@ -64,6 +64,12 @@
 
 static const  uint16_t DEFAULT_PORT=5672;
 
+struct NoSuchTransportException : qpid::Exception
+{
+    NoSuchTransportException(const std::string& s) : Exception(s) {}
+    virtual ~NoSuchTransportException() throw() {}
+};
+
 /**
  * A broker instance. 
  */

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp Mon Oct 13 09:43:10 
2008
@@ -44,14 +44,16 @@
            MessageStore*  _store,
            string&        _host,
            uint16_t       _port,
-           bool           _useSsl,
+           string&        _transport,
            bool           _durable,
            string&        _authMechanism,
            string&        _username,
            string&        _password,
            Broker*        _broker,
            management::Manageable* parent)
-    : links(_links), store(_store), host(_host), port(_port), useSsl(_useSsl), 
durable(_durable),
+    : links(_links), store(_store), host(_host), port(_port), 
+      transport(_transport), 
+      durable(_durable),
       authMechanism(_authMechanism), username(_username), password(_password),
       persistenceId(0), mgmtObject(0), broker(_broker), state(0),
       visitCount(0),
@@ -65,7 +67,7 @@
         ManagementAgent* agent = ManagementAgent::Singleton::getInstance();
         if (agent != 0)
         {
-            mgmtObject = new _qmf::Link(agent, this, parent, _host, _port, 
_useSsl, _durable);
+            mgmtObject = new _qmf::Link(agent, this, parent, _host, _port, 
_transport, _durable);
             if (!durable)
                 agent->addObject(mgmtObject);
         }
@@ -107,7 +109,7 @@
         // Set the state before calling connect.  It is possible that connect
         // will fail synchronously and call Link::closed before returning.
         setStateLH(STATE_CONNECTING);
-        broker->connect (host, port, useSsl ? "ssl" : Broker::TCP_TRANSPORT,
+        broker->connect (host, port, transport,
                          boost::bind (&Link::closed, this, _1, _2));
     } catch(std::exception& e) {
         setStateLH(STATE_WAITING);
@@ -289,19 +291,20 @@
 {
     string   host;
     uint16_t port;
+    string   transport;
     string   authMechanism;
     string   username;
     string   password;
     
     buffer.getShortString(host);
     port = buffer.getShort();
-    bool useSsl(buffer.getOctet());
+    buffer.getShortString(transport);
     bool durable(buffer.getOctet());
     buffer.getShortString(authMechanism);
     buffer.getShortString(username);
     buffer.getShortString(password);
 
-    return links.declare(host, port, useSsl, durable, authMechanism, username, 
password).first;
+    return links.declare(host, port, transport, durable, authMechanism, 
username, password).first;
 }
 
 void Link::encode(Buffer& buffer) const 
@@ -309,7 +312,7 @@
     buffer.putShortString(string("link"));
     buffer.putShortString(host);
     buffer.putShort(port);
-    buffer.putOctet(useSsl  ? 1 : 0);
+    buffer.putShortString(transport);
     buffer.putOctet(durable ? 1 : 0);
     buffer.putShortString(authMechanism);
     buffer.putShortString(username);
@@ -321,7 +324,7 @@
     return host.size() + 1 // short-string (host)
         + 5                // short-string ("link")
         + 2                // port
-        + 1                // useSsl
+        + transport.size() + 1 // short-string(transport)
         + 1                // durable
         + authMechanism.size() + 1
         + username.size() + 1

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.h?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Link.h Mon Oct 13 09:43:10 
2008
@@ -47,7 +47,7 @@
             MessageStore*       store;
             string        host;
             uint16_t      port;
-            bool          useSsl;
+            string        transport;
             bool          durable;
             string        authMechanism;
             string        username;
@@ -86,7 +86,7 @@
                  MessageStore* store,
                  string&       host,
                  uint16_t      port,
-                 bool          useSsl,
+                 string&       transport,
                  bool          durable,
                  string&       authMechanism,
                  string&       username,

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp Mon Oct 13 
09:43:10 2008
@@ -56,7 +56,7 @@
 
 pair<Link::shared_ptr, bool> LinkRegistry::declare(string&  host,
                                                    uint16_t port,
-                                                   bool     useSsl,
+                                                   string&  transport,
                                                    bool     durable,
                                                    string&  authMechanism,
                                                    string&  username,
@@ -73,7 +73,7 @@
     {
         Link::shared_ptr link;
 
-        link = Link::shared_ptr (new Link (this, store, host, port, useSsl, 
durable,
+        link = Link::shared_ptr (new Link (this, store, host, port, transport, 
durable,
                                            authMechanism, username, password,
                                            broker, parent));
         links[key] = link;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.h?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.h Mon Oct 13 
09:43:10 2008
@@ -69,7 +69,7 @@
         std::pair<Link::shared_ptr, bool>
             declare(std::string& host,
                     uint16_t     port,
-                    bool         useSsl,
+                    std::string& transport,
                     bool         durable,
                     std::string& authMechanism,
                     std::string& username,

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-route
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-route?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-route (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-route Mon Oct 13 09:43:10 
2008
@@ -50,6 +50,7 @@
 _quiet    = False
 _durable  = False
 _dellink  = False
+_transport = "tcp"
 
 class RouteManager:
     def __init__ (self, destBroker):
@@ -84,8 +85,9 @@
             mech = "ANONYMOUS"
         else:
             mech = "PLAIN"
-        res = broker.connect(self.src.host, self.src.port, False, _durable,
-                             mech, self.src.authName, self.src.authPass)
+        res = broker.connect(self.src.host, self.src.port, _durable,
+                             mech, self.src.authName, self.src.authPass,
+                             _transport)
         if _verbose:
             print "Connect method returned:", res.status, res.text
         link = self.getLink()
@@ -131,8 +133,9 @@
                 mech = "ANONYMOUS"
             else:
                 mech = "PLAIN"
-            res = broker.connect(self.src.host, self.src.port, False, _durable,
-                                 mech, self.src.authName, self.src.authPass)
+            res = broker.connect(self.src.host, self.src.port, _durable,
+                                 mech, self.src.authName, self.src.authPass,
+                                 _transport)
             if _verbose:
                 print "Connect method returned:", res.status, res.text
             link = self.getLink()

Modified: incubator/qpid/trunk/qpid/specs/management-schema.xml
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/specs/management-schema.xml?rev=704159&r1=704158&r2=704159&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/specs/management-schema.xml (original)
+++ incubator/qpid/trunk/qpid/specs/management-schema.xml Mon Oct 13 09:43:10 
2008
@@ -79,11 +79,11 @@
     <method name="connect" desc="Establish a connection to another broker">
       <arg name="host"          dir="I" type="sstr"/>
       <arg name="port"          dir="I" type="uint32"/>
-      <arg name="useSsl"        dir="I" type="bool"/>
       <arg name="durable"       dir="I" type="bool"/>
       <arg name="authMechanism" dir="I" type="sstr"/>
       <arg name="username"      dir="I" type="sstr"/>
       <arg name="password"      dir="I" type="sstr"/>
+      <arg name="transport"     dir="I" type="sstr"/>
     </method>
 
     <method name="queueMoveMessages" desc="Move messages from one queue to 
another">
@@ -233,7 +233,7 @@
     <property name="vhostRef"  type="objId"  references="Vhost" access="RC" 
index="y" parentRef="y"/>
     <property name="host"      type="sstr"   access="RC" index="y"/>
     <property name="port"      type="uint16" access="RC" index="y"/>
-    <property name="useSsl"    type="bool"   access="RC"/>
+    <property name="transport" type="sstr"   access="RC"/>
     <property name="durable"   type="bool"   access="RC"/>
 
     <statistic name="state"       type="sstr" desc="Operational state of the 
link"/>


Reply via email to