Repository: qpid-dispatch
Updated Branches:
  refs/heads/master ce98384ec -> 6eeb184aa


DISPATCH-467 - Added externalAddr feature for auto links.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/ead66da1
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/ead66da1
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/ead66da1

Branch: refs/heads/master
Commit: ead66da1007ecfc02d7bb5a4d88a650e8c4c517e
Parents: ce98384
Author: Ted Ross <tr...@redhat.com>
Authored: Thu Oct 13 10:58:07 2016 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Thu Oct 13 10:58:07 2016 -0400

----------------------------------------------------------------------
 python/qpid_dispatch/management/qdrouter.json |  6 ++
 src/router_config.c                           | 20 +++--
 src/router_core/agent_config_auto_link.c      | 18 ++++-
 src/router_core/agent_config_auto_link.h      |  2 +-
 src/router_core/route_control.c               | 22 ++++--
 src/router_core/route_control.h               |  3 +-
 src/router_core/router_core_private.h         |  1 +
 tests/system_tests_autolinks.py               | 87 +++++++++++++++++-----
 8 files changed, 119 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json 
b/python/qpid_dispatch/management/qdrouter.json
index a748dbf..2bd21ac 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -964,6 +964,12 @@
                     "create": true,
                     "required": false
                 },
+                "externalAddr": {
+                    "type": "string",
+                    "description": "If present, an alternate address of the 
node on the remote container.  This is used if the node has a different address 
than the address used internally by the router to route deliveries.",
+                    "create": true,
+                    "required": false
+                },
                 "linkRef": {
                     "type": "string",
                     "description": "Reference to the 
org.apache.qpid.dispatch.router.link if the link exists",

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/src/router_config.c
----------------------------------------------------------------------
diff --git a/src/router_config.c b/src/router_config.c
index a100bbf..6fbf337 100644
--- a/src/router_config.c
+++ b/src/router_config.c
@@ -401,14 +401,16 @@ qd_error_t qd_router_configure_auto_link(qd_router_t 
*router, qd_entity_t *entit
     char *dir       = 0;
     char *container = 0;
     char *c_name    = 0;
+    char *ext_addr  = 0;
 
     do {
-        name      = qd_entity_opt_string(entity, "name", 0);        
QD_ERROR_BREAK();
-        addr      = qd_entity_get_string(entity, "addr");           
QD_ERROR_BREAK();
-        dir       = qd_entity_get_string(entity, "dir");            
QD_ERROR_BREAK();
-        container = qd_entity_opt_string(entity, "containerId", 0); 
QD_ERROR_BREAK();
-        c_name    = qd_entity_opt_string(entity, "connection", 0);  
QD_ERROR_BREAK();
-        long  phase     = qd_entity_opt_long(entity, "phase", -1);  
QD_ERROR_BREAK();
+        name      = qd_entity_opt_string(entity, "name", 0);         
QD_ERROR_BREAK();
+        addr      = qd_entity_get_string(entity, "addr");            
QD_ERROR_BREAK();
+        dir       = qd_entity_get_string(entity, "dir");             
QD_ERROR_BREAK();
+        container = qd_entity_opt_string(entity, "containerId", 0);  
QD_ERROR_BREAK();
+        c_name    = qd_entity_opt_string(entity, "connection", 0);   
QD_ERROR_BREAK();
+        ext_addr  = qd_entity_opt_string(entity, "externalAddr", 0); 
QD_ERROR_BREAK();
+        long  phase     = qd_entity_opt_long(entity, "phase", -1);   
QD_ERROR_BREAK();
 
         //
         // Formulate this configuration as a route and create it through the 
core management API.
@@ -446,6 +448,11 @@ qd_error_t qd_router_configure_auto_link(qd_router_t 
*router, qd_entity_t *entit
             qd_compose_insert_string(body, c_name);
         }
 
+        if (ext_addr) {
+            qd_compose_insert_string(body, "externalAddr");
+            qd_compose_insert_string(body, ext_addr);
+        }
+
         qd_compose_end_map(body);
 
         int              length = 0;
@@ -480,6 +487,7 @@ qd_error_t qd_router_configure_auto_link(qd_router_t 
*router, qd_entity_t *entit
     free(dir);
     free(container);
     free(c_name);
+    free(ext_addr);
 
     return qd_error_code();
 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/src/router_core/agent_config_auto_link.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_config_auto_link.c 
b/src/router_core/agent_config_auto_link.c
index 4397b81..7c72f82 100644
--- a/src/router_core/agent_config_auto_link.c
+++ b/src/router_core/agent_config_auto_link.c
@@ -31,9 +31,10 @@
 #define QDR_CONFIG_AUTO_LINK_PHASE         5
 #define QDR_CONFIG_AUTO_LINK_CONNECTION    6
 #define QDR_CONFIG_AUTO_LINK_CONTAINER_ID  7
-#define QDR_CONFIG_AUTO_LINK_LINK_REF      8
-#define QDR_CONFIG_AUTO_LINK_OPER_STATUS   9
-#define QDR_CONFIG_AUTO_LINK_LAST_ERROR    10
+#define QDR_CONFIG_AUTO_LINK_EXT_ADDR      8
+#define QDR_CONFIG_AUTO_LINK_LINK_REF      9
+#define QDR_CONFIG_AUTO_LINK_OPER_STATUS   10
+#define QDR_CONFIG_AUTO_LINK_LAST_ERROR    11
 
 const char *qdr_config_auto_link_columns[] =
     {"name",
@@ -44,6 +45,7 @@ const char *qdr_config_auto_link_columns[] =
      "phase",
      "connection",
      "containerId",
+     "externalAddr",
      "linkRef",
      "operStatus",
      "lastError",
@@ -110,6 +112,13 @@ static void 
qdr_config_auto_link_insert_column_CT(qdr_auto_link_t *al, int col,
         qd_compose_insert_null(body);
         break;
 
+    case QDR_CONFIG_AUTO_LINK_EXT_ADDR:
+        if (al->external_addr)
+            qd_compose_insert_string(body, al->external_addr);
+        else
+            qd_compose_insert_null(body);
+        break;
+
     case QDR_CONFIG_AUTO_LINK_LINK_REF:
         if (al->link) {
             snprintf(id_str, 100, "%"PRId64, al->link->identity);
@@ -360,6 +369,7 @@ void qdra_config_auto_link_create_CT(qdr_core_t          
*core,
         qd_parsed_field_t *phase_field      = qd_parse_value_by_key(in_body, 
qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_PHASE]);
         qd_parsed_field_t *connection_field = qd_parse_value_by_key(in_body, 
qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_CONNECTION]);
         qd_parsed_field_t *container_field  = qd_parse_value_by_key(in_body, 
qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_CONTAINER_ID]);
+        qd_parsed_field_t *external_addr    = qd_parse_value_by_key(in_body, 
qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_EXT_ADDR]);
 
         //
         // Addr and dir fields are mandatory.  Fail if they're not both here.
@@ -402,7 +412,7 @@ void qdra_config_auto_link_create_CT(qdr_core_t          
*core,
         bool               is_container = !!container_field;
         qd_parsed_field_t *in_use_conn  = is_container ? container_field : 
connection_field;
 
-        al = qdr_route_add_auto_link_CT(core, name, addr_field, dir, phase, 
in_use_conn, is_container);
+        al = qdr_route_add_auto_link_CT(core, name, addr_field, dir, phase, 
in_use_conn, is_container, external_addr);
 
         //
         // Compose the result map for the response.

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/src/router_core/agent_config_auto_link.h
----------------------------------------------------------------------
diff --git a/src/router_core/agent_config_auto_link.h 
b/src/router_core/agent_config_auto_link.h
index 338f9d8..9ee33c9 100644
--- a/src/router_core/agent_config_auto_link.h
+++ b/src/router_core/agent_config_auto_link.h
@@ -32,7 +32,7 @@ void qdra_config_auto_link_get_CT(qdr_core_t        *core,
                                 qd_field_iterator_t *identity,
                                 qdr_query_t         *query,
                                 const char          
*qdr_config_auto_link_columns[]);
-#define QDR_CONFIG_AUTO_LINK_COLUMN_COUNT 11
+#define QDR_CONFIG_AUTO_LINK_COLUMN_COUNT 12
 
 const char *qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_COLUMN_COUNT + 
1];
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/src/router_core/route_control.c
----------------------------------------------------------------------
diff --git a/src/router_core/route_control.c b/src/router_core/route_control.c
index 7cba7a7..57120b8 100644
--- a/src/router_core/route_control.c
+++ b/src/router_core/route_control.c
@@ -136,8 +136,11 @@ static void qdr_auto_link_activate_CT(qdr_core_t *core, 
qdr_auto_link_t *al, qdr
             target = term;
 
         key = (const char*) qd_hash_key_by_handle(al->addr->hash_handle);
-        if (key) {
-            qdr_terminus_set_address(term, &key[2]); // truncate the "Mp" 
annotation (where p = phase)
+        if (key || al->external_addr) {
+            if (al->external_addr)
+                qdr_terminus_set_address(term, al->external_addr);
+            else
+                qdr_terminus_set_address(term, &key[2]); // truncate the "Mp" 
annotation (where p = phase)
             al->link = qdr_create_link_CT(core, conn, QD_LINK_ENDPOINT, 
al->dir, source, target);
             al->link->auto_link = al;
             al->state = QDR_AUTO_LINK_STATE_ATTACHING;
@@ -251,7 +254,8 @@ qdr_auto_link_t *qdr_route_add_auto_link_CT(qdr_core_t      
    *core,
                                             qd_direction_t       dir,
                                             int                  phase,
                                             qd_parsed_field_t   *conn_id,
-                                            bool                 is_container)
+                                            bool                 is_container,
+                                            qd_parsed_field_t   *external_addr)
 {
     qdr_auto_link_t *al = new_qdr_auto_link_t();
 
@@ -259,11 +263,12 @@ qdr_auto_link_t *qdr_route_add_auto_link_CT(qdr_core_t    
      *core,
     // Set up the auto_link structure
     //
     ZERO(al);
-    al->identity = qdr_identifier(core);
-    al->name     = name ? (char*) qd_field_iterator_copy(name) : 0;
-    al->dir      = dir;
-    al->phase    = phase;
-    al->state    = QDR_AUTO_LINK_STATE_INACTIVE;
+    al->identity      = qdr_identifier(core);
+    al->name          = name ? (char*) qd_field_iterator_copy(name) : 0;
+    al->dir           = dir;
+    al->phase         = phase;
+    al->state         = QDR_AUTO_LINK_STATE_INACTIVE;
+    al->external_addr = external_addr ? (char*) 
qd_field_iterator_copy(qd_parse_raw(external_addr)) : 0;
 
     //
     // Find or create an address for the auto_link destination
@@ -327,6 +332,7 @@ void qdr_route_del_auto_link_CT(qdr_core_t *core, 
qdr_auto_link_t *al)
     //
     DEQ_REMOVE(core->auto_links, al);
     free(al->name);
+    free(al->external_addr);
     free_qdr_auto_link_t(al);
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/src/router_core/route_control.h
----------------------------------------------------------------------
diff --git a/src/router_core/route_control.h b/src/router_core/route_control.h
index f5a8359..8111566 100644
--- a/src/router_core/route_control.h
+++ b/src/router_core/route_control.h
@@ -37,7 +37,8 @@ qdr_auto_link_t *qdr_route_add_auto_link_CT(qdr_core_t        
  *core,
                                             qd_direction_t       dir,
                                             int                  phase,
                                             qd_parsed_field_t   *conn_id,
-                                            bool                 is_container);
+                                            bool                 is_container,
+                                            qd_parsed_field_t   
*external_addr);
 
 void qdr_route_del_auto_link_CT(qdr_core_t *core, qdr_auto_link_t *auto_link);
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/src/router_core/router_core_private.h
----------------------------------------------------------------------
diff --git a/src/router_core/router_core_private.h 
b/src/router_core/router_core_private.h
index 9fa86e9..f44b6b5 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -489,6 +489,7 @@ struct qdr_auto_link_t {
     uint64_t               identity;
     char                  *name;
     qdr_address_t         *addr;
+    char                  *external_addr;
     int                    phase;
     qd_direction_t         dir;
     qdr_conn_identifier_t *conn_id;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ead66da1/tests/system_tests_autolinks.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_autolinks.py b/tests/system_tests_autolinks.py
index f899881..928cf5c 100644
--- a/tests/system_tests_autolinks.py
+++ b/tests/system_tests_autolinks.py
@@ -46,17 +46,27 @@ class AutolinkTest(TestCase):
             ('listener', {'port': cls.tester.get_port(), 'role': 
'route-container'}),
 
             #
+            # Set up the prefix 'node' as a prefix for waypoint addresses
+            #
+            ('address',  {'prefix': 'node', 'waypoint': 'yes'}),
+
+            #
             # Create a pair of default auto-links for 'node.1'
             #
             ('autoLink', {'addr': 'node.1', 'containerId': 'container.1', 
'dir': 'in'}),
             ('autoLink', {'addr': 'node.1', 'containerId': 'container.1', 
'dir': 'out'}),
-            ('address',  {'prefix': 'node', 'waypoint': 'yes'}),
 
             #
             # Create a pair of auto-links on non-default phases for 
container-to-container transfers
             #
             ('autoLink', {'addr': 'xfer.2', 'containerId': 'container.2', 
'dir': 'in',  'phase': '4'}),
             ('autoLink', {'addr': 'xfer.2', 'containerId': 'container.3', 
'dir': 'out', 'phase': '4'}),
+
+            #
+            # Create a pair of auto-links with a different external address
+            #
+            ('autoLink', {'addr': 'node.2', 'externalAddr': 'ext.2', 
'containerId': 'container.4', 'dir': 'in'}),
+            ('autoLink', {'addr': 'node.2', 'externalAddr': 'ext.2', 
'containerId': 'container.4', 'dir': 'out'}),
         ])
 
         cls.router = cls.tester.qdrouterd(name, config)
@@ -70,7 +80,7 @@ class AutolinkTest(TestCase):
         Create the route-container connection and verify that the appropriate 
links are attached.
         Disconnect, reconnect, and verify that the links are re-attached.
         """
-        test = AutolinkAttachTest(self.route_address)
+        test = AutolinkAttachTest('container.1', self.route_address, 'node.1')
         test.run()
         self.assertEqual(None, test.error)
 
@@ -90,7 +100,7 @@ class AutolinkTest(TestCase):
         Create a route-container connection and a normal sender.  Ensure that 
messages sent on the sender
         link are received by the route container and that settlement 
propagates back to the sender.
         """
-        test = AutolinkSenderTest(self.normal_address, self.route_address)
+        test = AutolinkSenderTest('container.1', self.normal_address, 
self.route_address, 'node.1', 'node.1')
         test.run()
         self.assertEqual(None, test.error)
 
@@ -100,7 +110,7 @@ class AutolinkTest(TestCase):
         Create a route-container connection and a normal receiver.  Ensure 
that messages sent from the
         route-container are received by the receiver and that settlement 
propagates back to the sender.
         """
-        test = AutolinkReceiverTest(self.normal_address, self.route_address)
+        test = AutolinkReceiverTest('container.1', self.normal_address, 
self.route_address, 'node.1', 'node.1')
         test.run()
         self.assertEqual(None, test.error)
 
@@ -125,6 +135,37 @@ class AutolinkTest(TestCase):
         self.assertEqual(None, test.error)
 
 
+    def test_07_autolink_attach_with_ext_addr(self):
+        """
+        Create the route-container connection and verify that the appropriate 
links are attached.
+        Disconnect, reconnect, and verify that the links are re-attached.  
Verify that the node addresses
+        in the links are the configured external address.
+        """
+        test = AutolinkAttachTest('container.4', self.route_address, 'ext.2')
+        test.run()
+        self.assertEqual(None, test.error)
+
+
+    def test_08_autolink_sender_with_ext_addr(self):
+        """
+        Create a route-container connection and a normal sender.  Ensure that 
messages sent on the sender
+        link are received by the route container and that settlement 
propagates back to the sender.
+        """
+        test = AutolinkSenderTest('container.4', self.normal_address, 
self.route_address, 'node.2', 'ext.2')
+        test.run()
+        self.assertEqual(None, test.error)
+
+
+    def test_09_autolink_receiver_with_ext_addr(self):
+        """
+        Create a route-container connection and a normal receiver.  Ensure 
that messages sent from the
+        route-container are received by the receiver and that settlement 
propagates back to the sender.
+        """
+        test = AutolinkReceiverTest('container.4', self.normal_address, 
self.route_address, 'node.2', 'ext.2')
+        test.run()
+        self.assertEqual(None, test.error)
+
+
 class Timeout(object):
     def __init__(self, parent):
         self.parent = parent
@@ -134,12 +175,14 @@ class Timeout(object):
 
 
 class AutolinkAttachTest(MessagingHandler):
-    def __init__(self, address):
+    def __init__(self, cid, address, node_addr):
         super(AutolinkAttachTest, self).__init__(prefetch=0)
-        self.address  = address
-        self.error    = None
-        self.sender   = None
-        self.receiver = None
+        self.cid       = cid
+        self.address   = address
+        self.node_addr = node_addr
+        self.error     = None
+        self.sender    = None
+        self.receiver  = None
 
         self.n_rx_attach = 0
         self.n_tx_attach = 0
@@ -159,14 +202,14 @@ class AutolinkAttachTest(MessagingHandler):
     def on_link_opened(self, event):
         if event.sender:
             self.n_tx_attach += 1
-            if event.sender.remote_source.address != 'node.1':
-                self.error = "Expected sender address 'node.1', got '%s'" % 
event.sender.remote_source.address
+            if event.sender.remote_source.address != self.node_addr:
+                self.error = "Expected sender address '%s', got '%s'" % 
(self.node_addr, event.sender.remote_source.address)
                 self.timer.cancel()
                 self.conn.close()
         elif event.receiver:
             self.n_rx_attach += 1
-            if event.receiver.remote_target.address != 'node.1':
-                self.error = "Expected receiver address 'node.1', got '%s'" % 
event.receiver.remote_target.address
+            if event.receiver.remote_target.address != self.node_addr:
+                self.error = "Expected receiver address '%s', got '%s'" % 
(self.node_addr, event.receiver.remote_target.address)
                 self.timer.cancel()
                 self.conn.close()
         if self.n_tx_attach == 1 and self.n_rx_attach == 1:
@@ -177,7 +220,7 @@ class AutolinkAttachTest(MessagingHandler):
 
     def run(self):
         container = Container(self)
-        container.container_id = 'container.1'
+        container.container_id = self.cid
         container.run()
 
 
@@ -231,11 +274,13 @@ class AutolinkCreditTest(MessagingHandler):
 
 
 class AutolinkSenderTest(MessagingHandler):
-    def __init__(self, normal_address, route_address):
+    def __init__(self, cid, normal_address, route_address, addr, ext_addr):
         super(AutolinkSenderTest, self).__init__()
+        self.cid            = cid
         self.normal_address = normal_address
         self.route_address  = route_address
-        self.dest           = 'node.1'
+        self.dest           = addr
+        self.ext_addr       = ext_addr
         self.count          = 275
         self.normal_conn    = None
         self.route_conn     = None
@@ -290,16 +335,18 @@ class AutolinkSenderTest(MessagingHandler):
 
     def run(self):
         container = Container(self)
-        container.container_id = 'container.1'
+        container.container_id = self.cid
         container.run()
 
 
 class AutolinkReceiverTest(MessagingHandler):
-    def __init__(self, normal_address, route_address):
+    def __init__(self, cid, normal_address, route_address, addr, ext_addr):
         super(AutolinkReceiverTest, self).__init__()
+        self.cid            = cid
         self.normal_address = normal_address
         self.route_address  = route_address
-        self.dest           = 'node.1'
+        self.dest           = addr
+        self.ext_addr       = ext_addr
         self.count          = 275
         self.normal_conn    = None
         self.route_conn     = None
@@ -355,7 +402,7 @@ class AutolinkReceiverTest(MessagingHandler):
 
     def run(self):
         container = Container(self)
-        container.container_id = 'container.1'
+        container.container_id = self.cid
         container.run()
 
 


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

Reply via email to