qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmur...@apache.org
Subject qpid-dispatch git commit: DISPATCH-500 - Fixed code to use qdr_field_t to pass around the name and identity of management objects
Date Wed, 14 Sep 2016 18:37:24 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 62899c0b4 -> 91837164d


DISPATCH-500 - Fixed code to use qdr_field_t to pass around the name and identity of management
objects

(cherry picked from commit 52b5a19aca807b4b3abe8b9e81a9b4819e2d8773)


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

Branch: refs/heads/master
Commit: 91837164df71f9155fd50a962fa1d6e151213529
Parents: 62899c0
Author: Ganesh Murthy <gmurthy@redhat.com>
Authored: Wed Sep 14 14:10:32 2016 -0400
Committer: Ganesh Murthy <gmurthy@redhat.com>
Committed: Wed Sep 14 14:34:52 2016 -0400

----------------------------------------------------------------------
 src/router_config.c                   | 27 ++++++++++++++++++---
 src/router_core/agent.c               | 39 ++++++++++++++++++------------
 src/router_core/router_core.c         | 11 +++++++++
 src/router_core/router_core_private.h |  5 ++--
 tests/system_tests_qdmanage.py        | 27 +++++++++++++++++++++
 5 files changed, 89 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/91837164/src/router_config.c
----------------------------------------------------------------------
diff --git a/src/router_config.c b/src/router_config.c
index 1c37851..a100bbf 100644
--- a/src/router_config.c
+++ b/src/router_config.c
@@ -280,7 +280,14 @@ qd_error_t qd_router_configure_address(qd_router_t *router, qd_entity_t
*entity)
         qd_parsed_field_t   *in_body = qd_parse(iter);
         qd_field_iterator_free(iter);
 
-        qdr_manage_create(router->router_core, 0, QD_ROUTER_CONFIG_ADDRESS, 0, in_body,
0);
+        qd_field_iterator_t *name_iter = 0;
+
+        if (name)
+            name_iter = qd_field_iterator_string(name);
+
+        qdr_manage_create(router->router_core, 0, QD_ROUTER_CONFIG_ADDRESS, name_iter,
in_body, 0);
+
+        qd_field_iterator_free(name_iter);
 
 
     } while(0);
@@ -365,7 +372,14 @@ qd_error_t qd_router_configure_link_route(qd_router_t *router, qd_entity_t
*enti
         qd_parsed_field_t   *in_body = qd_parse(iter);
         qd_field_iterator_free(iter);
 
-        qdr_manage_create(router->router_core, 0, QD_ROUTER_CONFIG_LINK_ROUTE, 0, in_body,
0);
+        qd_field_iterator_t *name_iter = 0;
+
+        if (name)
+            name_iter = qd_field_iterator_string(name);
+
+        qdr_manage_create(router->router_core, 0, QD_ROUTER_CONFIG_LINK_ROUTE, name_iter,
in_body, 0);
+
+        qd_field_iterator_free(name_iter);
 
     } while(0);
 
@@ -450,7 +464,14 @@ qd_error_t qd_router_configure_auto_link(qd_router_t *router, qd_entity_t
*entit
         qd_parsed_field_t   *in_body = qd_parse(iter);
         qd_field_iterator_free(iter);
 
-        qdr_manage_create(router->router_core, 0, QD_ROUTER_CONFIG_AUTO_LINK, 0, in_body,
0);
+        qd_field_iterator_t *name_iter = 0;
+
+        if (name)
+            name_iter = qd_field_iterator_string(name);
+
+        qdr_manage_create(router->router_core, 0, QD_ROUTER_CONFIG_AUTO_LINK, name_iter,
in_body, 0);
+
+        qd_field_iterator_free(name_iter);
 
     } while (0);
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/91837164/src/router_core/agent.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent.c b/src/router_core/agent.c
index 272b75c..16dd30b 100644
--- a/src/router_core/agent.c
+++ b/src/router_core/agent.c
@@ -112,7 +112,7 @@ void qdr_manage_create(qdr_core_t              *core,
 
     // Create a query object here
     action->args.agent.query = qdr_query(core, context, type, out_body);
-    action->args.agent.name = name;
+    action->args.agent.name = qdr_field_from_iter(name);
     action->args.agent.in_body = in_body;
 
     qdr_action_enqueue(core, action);
@@ -129,8 +129,8 @@ void qdr_manage_delete(qdr_core_t *core,
 
     // Create a query object here
     action->args.agent.query = qdr_query(core, context, type, 0);
-    action->args.agent.name = name;
-    action->args.agent.identity = identity;
+    action->args.agent.name = qdr_field_from_iter(name);
+    action->args.agent.identity = qdr_field_from_iter(identity);
 
     qdr_action_enqueue(core, action);
 }
@@ -147,8 +147,8 @@ void qdr_manage_read(qdr_core_t *core,
 
     // Create a query object here
     action->args.agent.query = qdr_query(core, context, entity_type, body);
-    action->args.agent.identity  = identity;
-    action->args.agent.name = name;
+    action->args.agent.identity  = qdr_field_from_iter(identity);
+    action->args.agent.name = qdr_field_from_iter(name);
 
     qdr_action_enqueue(core, action);
 }
@@ -164,8 +164,8 @@ void qdr_manage_update(qdr_core_t              *core,
 {
     qdr_action_t *action = qdr_action(qdr_manage_update_CT, "manage_update");
     action->args.agent.query = qdr_query(core, context, type, out_body);
-    action->args.agent.name = name;
-    action->args.agent.identity = identity;
+    action->args.agent.name = qdr_field_from_iter(name);
+    action->args.agent.identity = qdr_field_from_iter(identity);
     action->args.agent.in_body = in_body;
 
     qdr_action_enqueue(core, action);
@@ -330,8 +330,8 @@ static void qdr_agent_forbidden(qdr_core_t *core, qdr_query_t *query,
bool op_qu
 
 static void qdr_manage_read_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
-    qd_field_iterator_t     *identity   = action->args.agent.identity;
-    qd_field_iterator_t     *name       = action->args.agent.name;
+    qd_field_iterator_t     *identity   = qdr_field_iterator(action->args.agent.identity);
+    qd_field_iterator_t     *name       = qdr_field_iterator(action->args.agent.name);
     qdr_query_t             *query      = action->args.agent.query;
 
     switch (query->entity_type) {
@@ -345,12 +345,15 @@ static void qdr_manage_read_CT(qdr_core_t *core, qdr_action_t *action,
bool disc
     case QD_ROUTER_EXCHANGE:          break;
     case QD_ROUTER_BINDING:           break;
    }
+
+    qdr_field_free(action->args.agent.name);
+    qdr_field_free(action->args.agent.identity);
 }
 
 
 static void qdr_manage_create_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
-    qd_field_iterator_t     *name       = action->args.agent.name;
+    qd_field_iterator_t     *name       = qdr_field_iterator(action->args.agent.name);
     qdr_query_t             *query      = action->args.agent.query;
     qd_parsed_field_t       *in_body    = action->args.agent.in_body;
 
@@ -367,14 +370,15 @@ static void qdr_manage_create_CT(qdr_core_t *core, qdr_action_t *action,
bool di
 
    }
 
+   qdr_field_free(action->args.agent.name);
    qd_parse_free(in_body);
 }
 
 
 static void qdr_manage_delete_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
-    qd_field_iterator_t     *name       = action->args.agent.name;
-    qd_field_iterator_t     *identity   = action->args.agent.identity;
+    qd_field_iterator_t     *name       = qdr_field_iterator(action->args.agent.name);
+    qd_field_iterator_t     *identity   = qdr_field_iterator(action->args.agent.identity);
     qdr_query_t             *query      = action->args.agent.query;
 
     switch (query->entity_type) {
@@ -388,12 +392,15 @@ static void qdr_manage_delete_CT(qdr_core_t *core, qdr_action_t *action,
bool di
     case QD_ROUTER_EXCHANGE:          break;
     case QD_ROUTER_BINDING:           break;
    }
+
+   qdr_field_free(action->args.agent.name);
+   qdr_field_free(action->args.agent.identity);
 }
 
 static void qdr_manage_update_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
-    qd_field_iterator_t     *identity   = action->args.agent.identity;
-    qd_field_iterator_t     *name       = action->args.agent.name;
+    qd_field_iterator_t     *identity   = qdr_field_iterator(action->args.agent.identity);
+    qd_field_iterator_t     *name       = qdr_field_iterator(action->args.agent.name);
     qdr_query_t             *query      = action->args.agent.query;
     qd_parsed_field_t       *in_body    = action->args.agent.in_body;
 
@@ -409,7 +416,9 @@ static void qdr_manage_update_CT(qdr_core_t *core, qdr_action_t *action,
bool di
     case QD_ROUTER_BINDING:           break;
    }
 
-    qd_parse_free(in_body);
+   qdr_field_free(action->args.agent.name);
+   qdr_field_free(action->args.agent.identity);
+   qd_parse_free(in_body);
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/91837164/src/router_core/router_core.c
----------------------------------------------------------------------
diff --git a/src/router_core/router_core.c b/src/router_core/router_core.c
index 937e112..07b7035 100644
--- a/src/router_core/router_core.c
+++ b/src/router_core/router_core.c
@@ -144,6 +144,9 @@ qdr_field_t *qdr_field(const char *text)
 
 qdr_field_t *qdr_field_from_iter(qd_field_iterator_t *iter)
 {
+    if (!iter)
+        return 0;
+
     qdr_field_t *field = new_qdr_field_t();
     qd_buffer_t *buf;
     int          remaining;
@@ -167,6 +170,14 @@ qdr_field_t *qdr_field_from_iter(qd_field_iterator_t *iter)
     return field;
 }
 
+qd_field_iterator_t *qdr_field_iterator(qdr_field_t *field)
+{
+    if (!field)
+        return 0;
+
+    return field->iterator;
+}
+
 
 void qdr_field_free(qdr_field_t *field)
 {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/91837164/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 fc0673b..594e200 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -61,6 +61,7 @@ typedef struct {
 
 qdr_field_t *qdr_field(const char *string);
 qdr_field_t *qdr_field_from_iter(qd_field_iterator_t *iter);
+qd_field_iterator_t *qdr_field_iterator(qdr_field_t *field);
 void qdr_field_free(qdr_field_t *field);
 char *qdr_field_copy(qdr_field_t *field);
 
@@ -137,8 +138,8 @@ struct qdr_action_t {
         struct {
             qdr_query_t             *query;
             int                      offset;
-            qd_field_iterator_t     *identity;
-            qd_field_iterator_t     *name;
+            qdr_field_t             *identity;
+            qdr_field_t             *name;
             qd_parsed_field_t       *in_body;
         } agent;
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/91837164/tests/system_tests_qdmanage.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_qdmanage.py b/tests/system_tests_qdmanage.py
index 262e16a..346bd72 100644
--- a/tests/system_tests_qdmanage.py
+++ b/tests/system_tests_qdmanage.py
@@ -47,6 +47,9 @@ class QdmanageTest(TestCase):
                              'password': 'server-password'}),
             ('listener', {'port': cls.tester.get_port()}),
             ('connector', {'role': 'inter-router', 'port': cls.inter_router_port}),
+            ('address', {'name': 'test-address', 'prefix': 'abcd', 'distribution': 'multicast'}),
+            ('linkRoute', {'name': 'test-link-route', 'prefix': 'xyz', 'dir': 'in'}),
+            ('autoLink', {'name': 'test-auto-link', 'addr': 'mnop', 'dir': 'out'}),
             ('listener', {'port': cls.tester.get_port(), 'sslProfile': 'server-ssl'})
         ])
 
@@ -210,6 +213,30 @@ class QdmanageTest(TestCase):
         connector = json.loads(self.run_qdmanage(create_command))
         return connector
 
+    def test_check_address_name(self):
+        long_type = 'org.apache.qpid.dispatch.router.config.address'
+        query_command = 'QUERY --type=' + long_type
+        output = json.loads(self.run_qdmanage(query_command))
+        self.assertEqual(output[0]['name'], "test-address")
+        self.assertEqual(output[0]['distribution'], "multicast")
+        self.assertEqual(output[0]['prefix'], "abcd")
+
+    def test_check_link_route_name(self):
+        long_type = 'org.apache.qpid.dispatch.router.config.linkRoute'
+        query_command = 'QUERY --type=' + long_type
+        output = json.loads(self.run_qdmanage(query_command))
+        self.assertEqual(output[0]['name'], "test-link-route")
+        self.assertEqual(output[0]['dir'], "in")
+        self.assertEqual(output[0]['prefix'], "xyz")
+
+    def test_check_auto_link_name(self):
+        long_type = 'org.apache.qpid.dispatch.router.config.autoLink'
+        query_command = 'QUERY --type=' + long_type
+        output = json.loads(self.run_qdmanage(query_command))
+        self.assertEqual(output[0]['name'], "test-auto-link")
+        self.assertEqual(output[0]['dir'], "out")
+        self.assertEqual(output[0]['addr'], "mnop")
+
     def test_create_delete_connector(self):
         long_type = 'org.apache.qpid.dispatch.connector'
         query_command = 'QUERY --type=' + long_type


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


Mime
View raw message