qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject [2/2] qpid-dispatch git commit: DISPATCH-179 - Updated and refined the core api for management queries
Date Wed, 04 Nov 2015 20:27:13 GMT
DISPATCH-179 - Updated and refined the core api for management queries


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

Branch: refs/heads/tross-DISPATCH-179-1
Commit: 65231431a2fa7459f138b0cf0d839cf12c44cd23
Parents: afd9a04
Author: Ted Ross <tross@redhat.com>
Authored: Wed Nov 4 15:26:27 2015 -0500
Committer: Ted Ross <tross@redhat.com>
Committed: Wed Nov 4 15:26:27 2015 -0500

----------------------------------------------------------------------
 include/qpid/dispatch/router_core.h   | 26 +++++++++++++---
 src/router_core/agent.c               | 49 ++++++++++++++++++++----------
 src/router_core/agent_address.c       | 11 +++++++
 src/router_core/agent_address.h       |  1 +
 src/router_core/router_core_private.h |  1 +
 5 files changed, 68 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/65231431/include/qpid/dispatch/router_core.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/router_core.h b/include/qpid/dispatch/router_core.h
index fd19c82..ad06cb0 100644
--- a/include/qpid/dispatch/router_core.h
+++ b/include/qpid/dispatch/router_core.h
@@ -151,10 +151,28 @@ void qdr_manage_create(qdr_core_t *core, void *context, qd_router_entity_type_t
 void qdr_manage_delete(qdr_core_t *core, void *context, qd_router_entity_type_t type, qd_parsed_field_t
*attributes);
 void qdr_manage_read(qdr_core_t *core, void *context, qd_router_entity_type_t type, qd_parsed_field_t
*attributes);
 
-qdr_query_t *qdr_manage_get_first(qdr_core_t *core, void *context, qd_router_entity_type_t
type, int offset,
-                                  qd_parsed_field_t *attribute_names, qd_composed_field_t
*body);
-void qdr_manage_get_next(qdr_core_t *core, qdr_query_t *query);
-void qdr_query_cancel(qdr_core_t *core, qdr_query_t *query);
+/**
+ * Sequence for running a query:
+ *
+ * 1) Locate the attributeNames field in the body of the QUERY request
+ * 2) Create a composed field for the body of the reply message
+ * 3) Call qdr_manage_query with the attributeNames field and the response body
+ * 4) Start the body map, add the "attributeNames" key, start the value list
+ * 5) Call qdr_query_add_attribute_names.  This will fill in the attribute names
+ * 6) Close out the list
+ * 7) Add the "results" key, start the outer list
+ * 8) Call qdr_query_get_first.  This will asynchronously add the first inner list.
+ * 9) When the qdr_manage_response_t callback is invoked:
+ *    a) if more is true and count is not exceeded, call qdr_query_get_next
+ *    b) if more is false or count is exceeded, call qdr_query_free, close the outer list,
close the map
+ */
+
+qdr_query_t *qdr_manage_query(qdr_core_t *core, void *context, qd_router_entity_type_t type,

+                              qd_parsed_field_t *attribute_names, qd_composed_field_t *body);
+void qdr_query_add_attribute_names(qdr_query_t *query);
+void qdr_query_get_first(qdr_query_t *query, int offset);
+void qdr_query_get_next(qdr_query_t *query);
+void qdr_query_free(qdr_query_t *query);
 
 typedef void (*qdr_manage_response_t) (void *context, const qd_amqp_error_t *status, bool
more);
 void qdr_manage_handler(qdr_core_t *core, qdr_manage_response_t response_handler);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/65231431/src/router_core/agent.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent.c b/src/router_core/agent.c
index a42232b..11f8fc2 100644
--- a/src/router_core/agent.c
+++ b/src/router_core/agent.c
@@ -62,8 +62,8 @@ void qdr_agent_enqueue_response_CT(qdr_core_t *core, qdr_query_t *query)
         qd_timer_schedule(core->agent_timer, 0);
 }
 
-static void qdrh_manage_get_first_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
-static void qdrh_manage_get_next_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
+static void qdrh_query_get_first_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
+static void qdrh_query_get_next_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
 
 
 //==================================================================================
@@ -85,12 +85,12 @@ void qdr_manage_read(qdr_core_t *core, void *context, qd_router_entity_type_t
ty
 }
 
 
-qdr_query_t *qdr_manage_get_first(qdr_core_t *core, void *context, qd_router_entity_type_t
type,
-                                  int offset, qd_parsed_field_t *attribute_names, qd_composed_field_t
*body)
+qdr_query_t *qdr_manage_query(qdr_core_t *core, void *context, qd_router_entity_type_t type,
+                              qd_parsed_field_t *attribute_names, qd_composed_field_t *body)
 {
-    qdr_action_t *action = qdr_action(qdrh_manage_get_first_CT);
-    qdr_query_t  *query  = new_qdr_query_t();
+    qdr_query_t *query = new_qdr_query_t();
 
+    query->core        = core;
     query->entity_type = type;
     query->context     = context;
     query->body        = body;
@@ -108,24 +108,41 @@ qdr_query_t *qdr_manage_get_first(qdr_core_t *core, void *context, qd_router_ent
     case QD_ROUTER_BINDING:    break;
     }
 
-    action->args.agent.query  = query;
-    action->args.agent.offset = offset;
+    return query;
+}
 
-    qdr_action_enqueue(core, action);
 
-    return query;
+void qdr_query_add_attribute_names(qdr_query_t *query)
+{
+    switch (query->entity_type) {
+    case QD_ROUTER_CONNECTION: break;
+    case QD_ROUTER_LINK:       break;
+    case QD_ROUTER_ADDRESS:    qdra_address_emit_columns(query);
+    case QD_ROUTER_WAYPOINT:   break;
+    case QD_ROUTER_EXCHANGE:   break;
+    case QD_ROUTER_BINDING:    break;
+    }
+}
+
+
+void qdr_query_get_first(qdr_query_t *query, int offset)
+{
+    qdr_action_t *action = qdr_action(qdrh_query_get_first_CT);
+    action->args.agent.query  = query;
+    action->args.agent.offset = offset;
+    qdr_action_enqueue(query->core, action);
 }
 
 
-void qdr_manage_get_next(qdr_core_t *core, qdr_query_t *query)
+void qdr_query_get_next(qdr_query_t *query)
 {
-    qdr_action_t *action = qdr_action(qdrh_manage_get_next_CT);
+    qdr_action_t *action = qdr_action(qdrh_query_get_next_CT);
     action->args.agent.query = query;
-    qdr_action_enqueue(core, action);
+    qdr_action_enqueue(query->core, action);
 }
 
 
-void qdr_query_cancel(qdr_core_t *core, qdr_query_t *query)
+void qdr_query_free(qdr_query_t *query)
 {
 }
 
@@ -148,7 +165,7 @@ void qdr_agent_setup_CT(qdr_core_t *core)
 }
 
 
-static void qdrh_manage_get_first_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
+static void qdrh_query_get_first_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
     qdr_query_t *query  = action->args.agent.query;
     int          offset = action->args.agent.offset;
@@ -165,7 +182,7 @@ static void qdrh_manage_get_first_CT(qdr_core_t *core, qdr_action_t *action,
boo
 }
 
 
-static void qdrh_manage_get_next_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
+static void qdrh_query_get_next_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
     qdr_query_t *query  = action->args.agent.query;
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/65231431/src/router_core/agent_address.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_address.c b/src/router_core/agent_address.c
index 5ede5d1..4dd2845 100644
--- a/src/router_core/agent_address.c
+++ b/src/router_core/agent_address.c
@@ -171,6 +171,17 @@ void qdra_address_set_columns(qdr_query_t *query, qd_parsed_field_t *attribute_n
 }
 
 
+void qdra_address_emit_columns(qdr_query_t *query)
+{
+    int i = 0;
+    while (query->columns[i] >= 0) {
+        assert(query->columns[i] < QDR_ADDRESS_COLUMN_COUNT);
+        qd_compose_insert_string(query->body, qdr_address_columns[query->columns[i]]);
+        i++;
+    }
+}
+
+
 void qdra_address_get_first_CT(qdr_core_t *core, qdr_query_t *query, int offset)
 {
     //

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/65231431/src/router_core/agent_address.h
----------------------------------------------------------------------
diff --git a/src/router_core/agent_address.h b/src/router_core/agent_address.h
index 9d6c078..53d383a 100644
--- a/src/router_core/agent_address.h
+++ b/src/router_core/agent_address.h
@@ -22,6 +22,7 @@
 #include "router_core_private.h"
 
 void qdra_address_set_columns(qdr_query_t *query, qd_parsed_field_t *attribute_names);
+void qdra_address_emit_columns(qdr_query_t *query);
 void qdra_address_get_first_CT(qdr_core_t *core, qdr_query_t *query, int offset);
 void qdra_address_get_next_CT(qdr_core_t *core, qdr_query_t *query);
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/65231431/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 c7cff0c..11393a3 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -92,6 +92,7 @@ DEQ_DECLARE(qdr_action_t, qdr_action_list_t);
 
 struct qdr_query_t {
     DEQ_LINKS(qdr_query_t);
+    qdr_core_t              *core;
     qd_router_entity_type_t  entity_type;
     void                    *context;
     int                      columns[QDR_AGENT_MAX_COLUMNS];


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


Mime
View raw message