You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2015/11/16 19:45:51 UTC

qpid-dispatch git commit: DISPATCH-179 - Added management update operation. Added more core content.

Repository: qpid-dispatch
Updated Branches:
  refs/heads/tross-DISPATCH-179-1 ad27ead36 -> 58d9f3fc4


DISPATCH-179 - Added management update operation.  Added more core content.


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

Branch: refs/heads/tross-DISPATCH-179-1
Commit: 58d9f3fc4670194fee9169421334fe0f4cca008d
Parents: ad27ead
Author: Ted Ross <tr...@redhat.com>
Authored: Mon Nov 16 13:45:11 2015 -0500
Committer: Ted Ross <tr...@redhat.com>
Committed: Mon Nov 16 13:45:11 2015 -0500

----------------------------------------------------------------------
 include/qpid/dispatch/router_core.h   |  32 ++++++++
 src/router_core/agent.c               |   7 ++
 src/router_core/connections.c         | 123 ++++++++++++++++++++++++++++-
 src/router_core/route_tables.c        |  31 +++++---
 src/router_core/router_core_private.h |  17 ++--
 src/router_node.c                     |   2 +
 src/router_private.h                  |   3 +-
 7 files changed, 195 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/58d9f3fc/include/qpid/dispatch/router_core.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/router_core.h b/include/qpid/dispatch/router_core.h
index 6688292..4a22bcf 100644
--- a/include/qpid/dispatch/router_core.h
+++ b/include/qpid/dispatch/router_core.h
@@ -154,6 +154,20 @@ typedef void (*qdr_connection_activate_t) (void *context, qdr_connection_t *conn
  */
 
 /**
+ * qdr_link_set_context
+ *
+ * Store an arbitrary void pointer in the link object.
+ */
+void qdr_link_set_context(qdr_link_t *link, void *context);
+
+/**
+ * qdr_link_get_context
+ *
+ * Retrieve the stored void pointer from the link object.
+ */
+void *qdr_link_get_context(qdr_link_t *link);
+
+/**
  * qdr_link_first_attach
  *
  * This function is invoked when a first-attach (not a response to an earlier attach)
@@ -267,6 +281,24 @@ void qdr_manage_read(qdr_core_t *core, void *context, qd_router_entity_type_t ty
 
 
 /**
+ * qdr_manage_update
+ *
+ * Request the update of a managed entity in the router core.
+ *
+ * @param core Pointer to the core object returned by qd_core()
+ * @param context An opaque context that will be passed back in the invocation of the response callback
+ * @param type The entity type for the update request
+ * @param name The name supplied with the request (or 0 if the identity was supplied)
+ * @param identity The identity supplied with the request (or 0 if the name was supplied)
+ * @param in_body The body of the request message
+ * @param out_body A composed field for the body of the response message
+ */
+void qdr_manage_update(qdr_core_t *core, void *context, qd_router_entity_type_t type,
+                       qd_field_iterator_t *name, qd_field_iterator_t *identity,
+                       qd_parsed_field_t *in_body, qd_composed_field_t *out_body);
+
+
+/**
  * Sequence for running a query:
  *
  * 1) Locate the attributeNames field in the body of the QUERY request

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/58d9f3fc/src/router_core/agent.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent.c b/src/router_core/agent.c
index 480f83a..80c6f9d 100644
--- a/src/router_core/agent.c
+++ b/src/router_core/agent.c
@@ -125,6 +125,13 @@ void qdr_manage_read(qdr_core_t *core, void *context, qd_router_entity_type_t ty
 }
 
 
+void qdr_manage_update(qdr_core_t *core, void *context, qd_router_entity_type_t type,
+                       qd_field_iterator_t *name, qd_field_iterator_t *identity,
+                       qd_parsed_field_t *in_body, qd_composed_field_t *out_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)
 {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/58d9f3fc/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 53e4550..4d98811 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -41,11 +41,13 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t *core, bool incoming, qdr_con
     qdr_action_t     *action = qdr_action(qdr_connection_opened_CT);
     qdr_connection_t *conn   = new_qdr_connection_t();
 
+    ZERO(conn);
     conn->core         = core;
     conn->user_context = 0;
     conn->incoming     = incoming;
     conn->role         = role;
     conn->label        = label;
+    conn->mask_bit     = -1;
 
     action->args.connection.conn = conn;
     qdr_action_enqueue(core, action);
@@ -75,11 +77,25 @@ void *qdr_connection_get_context(qdr_connection_t *conn)
 }
 
 
+void qdr_link_set_context(qdr_link_t *link, void *context)
+{
+    if (link)
+        link->user_context = context;
+}
+
+
+void *qdr_link_get_context(qdr_link_t *link)
+{
+    return link ? link->user_context : 0;
+}
+
+
 qdr_link_t *qdr_link_first_attach(qdr_connection_t *conn, qd_direction_t dir, pn_terminus_t *source, pn_terminus_t *target)
 {
     qdr_action_t *action = qdr_action(qdr_link_first_attach_CT);
     qdr_link_t   *link   = new_qdr_link_t();
 
+    ZERO(link);
     link->core = conn->core;
     link->conn = conn;
 
@@ -128,8 +144,34 @@ static void qdr_connection_opened_CT(qdr_core_t *core, qdr_action_t *action, boo
     DEQ_ITEM_INIT(conn);
     DEQ_INSERT_TAIL(core->open_connections, conn);
 
-    //
-    // If the role of this connection is NORMAL, there is no further work to do.
+    if (conn->role == QDR_ROLE_NORMAL) {
+        //
+        // No action needed for NORMAL connections
+        //
+        return;
+    }
+
+    if (conn->role == QDR_ROLE_INTER_ROUTER) {
+        //
+        // Assign a unique mask-bit to this connection as a reference to be used by
+        // the router module
+        //
+        if (qd_bitmask_first_set(core->neighbor_free_mask, &conn->mask_bit))
+            qd_bitmask_clear_bit(core->neighbor_free_mask, conn->mask_bit);
+        else {
+            qd_log(core->log, QD_LOG_CRITICAL, "Exceeded maximum inter-router connection count");
+            return;
+        }
+
+        if (!conn->incoming) {
+            //
+            // The connector-side of inter-router connections is responsible for setting up the
+            // inter-router links:  Two (in and out) for control, two for routed-message transfer
+            //
+            //(void) qdr_create_link_CT(core, conn, QD_LINK_CONTROL, QD_INCOMING, ...);
+        }
+    }
+
     // If the role is INTER_ROUTER:
     //    Assign this connection a neighbor mask-bit
     //    If the connection is not incoming:
@@ -166,16 +208,93 @@ static void qdr_connection_closed_CT(qdr_core_t *core, qdr_action_t *action, boo
 
 static void qdr_link_first_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
+    if (discard)
+        return;
+
+    //qdr_connection_t *conn   = action->args.connection.conn;
+    //qdr_link_t       *link   = action->args.connection.link;
+    //qd_direction_t    dir    = action->args.connection.dir;
+    //pn_terminus_t    *source = action->args.connection.source;
+    //pn_terminus_t    *target = action->args.connection.target;
+
+    //
+    // Cases to be handled:
+    //
+    // dir = Incoming or Outgoing:
+    //    Link is an router-control link
+    //       If this isn't an inter-router connection, close the link
+    //       Note the control link on the connection
+    //       Issue a second attach back to the originating node
+    //    Link is addressed (i.e. has a target/source address)
+    //       If this is a link-routed address, Issue a first attach to the next hop
+    //       If not link-routed, issue a second attach back to the originating node
+    //
+    // dir = Incoming:
+    //    Link is addressed (i.e. has a target address) and not link-routed
+    //       Lookup/Create address in the address table and associate the link to the address
+    //       Issue a second attach back to the originating node
+    //    Link is anonymous
+    //       Issue a second attach back to the originating node
+    //    Issue credit for the inbound fifo
+    //
+    // dir = Outgoing:
+    //    Link is a router-control link
+    //       Associate the link with the router-hello address
+    //       Associate the link with the link-mask-bit being used by the router
+    //    Link is addressed (i.e. has a non-dynamic source address)
+    //       If the address is appropriate for distribution, add it to the address table as a local destination
+    //       If this is the first local dest for this address, notify the router (mobile_added)
+    //       Issue a second attach back to the originating node
+    //
 }
 
 
 static void qdr_link_second_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
+    if (discard)
+        return;
+
+    //qdr_link_t    *link   = action->args.connection.link;
+    //pn_terminus_t *source = action->args.connection.source;
+    //pn_terminus_t *target = action->args.connection.target;
+
+    //
+    // Cases to be handled:
+    //
+    // Link is a router-control link:
+    //    Note the control link on the connection
+    //    Associate the link with the router-hello address
+    //    Associate the link with the link-mask-bit being used by the router
+    // Link is link-routed:
+    //    Propagate the second attach back toward the originating node
+    // Link is Incoming:
+    //    Issue credit for the inbound fifo
+    //
 }
 
 
 static void qdr_link_detach_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
+    if (discard)
+        return;
+
+    //qdr_link_t     *link      = action->args.connection.link;
+    //pn_condition_t *condition = action->args.connection.condition;
+
+    //
+    // Cases to be handled:
+    //
+    // Link is link-routed:
+    //    Propagate the detach along the link-chain
+    // Link is half-detached and not link-routed:
+    //    Issue a detach back to the originating node
+    // Link is fully detached:
+    //    Free the qdr_link object
+    //    Remove any address linkages associated with this link
+    //       If the last dest for a local address is lost, notify the router (mobile_removed)
+    // Link is a router-control link:
+    //    Issue a link-lost indication to the router
+    //
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/58d9f3fc/src/router_core/route_tables.c
----------------------------------------------------------------------
diff --git a/src/router_core/route_tables.c b/src/router_core/route_tables.c
index 05a6bd3..96ae528 100644
--- a/src/router_core/route_tables.c
+++ b/src/router_core/route_tables.c
@@ -162,11 +162,15 @@ void qdr_route_table_setup_CT(qdr_core_t *core)
     core->routerma_addr = qdr_add_local_address_CT(core, "qdrouter.ma", QD_SEMANTICS_DEFAULT);
     core->hello_addr    = qdr_add_local_address_CT(core, "qdhello",     QD_SEMANTICS_ROUTER_CONTROL);
 
-    core->routers_by_mask_bit   = NEW_PTR_ARRAY(qdr_node_t, qd_bitmask_width());
-    core->out_links_by_mask_bit = NEW_PTR_ARRAY(qdr_link_t, qd_bitmask_width());
+    core->neighbor_free_mask = qd_bitmask(1);
+
+    core->routers_by_mask_bit       = NEW_PTR_ARRAY(qdr_node_t, qd_bitmask_width());
+    core->control_links_by_mask_bit = NEW_PTR_ARRAY(qdr_link_t, qd_bitmask_width());
+    core->data_links_by_mask_bit    = NEW_PTR_ARRAY(qdr_link_t, qd_bitmask_width());
     for (int idx = 0; idx < qd_bitmask_width(); idx++) {
         core->routers_by_mask_bit[idx]   = 0;
-        core->out_links_by_mask_bit[idx] = 0;
+        core->control_links_by_mask_bit[idx] = 0;
+        core->data_links_by_mask_bit[idx] = 0;
     }
 }
 
@@ -279,12 +283,13 @@ static void qdrh_add_router_CT(qdr_core_t *core, qdr_action_t *action, bool disc
         //
         qdr_node_t *rnode = new_qdr_node_t();
         DEQ_ITEM_INIT(rnode);
-        rnode->owning_addr   = addr;
-        rnode->mask_bit      = router_maskbit;
-        rnode->next_hop      = 0;
-        rnode->peer_link     = 0;
-        rnode->ref_count     = 0;
-        rnode->valid_origins = qd_bitmask(0);
+        rnode->owning_addr       = addr;
+        rnode->mask_bit          = router_maskbit;
+        rnode->next_hop          = 0;
+        rnode->peer_control_link = 0;
+        rnode->peer_data_link    = 0;
+        rnode->ref_count         = 0;
+        rnode->valid_origins     = qd_bitmask(0);
 
         DEQ_INSERT_TAIL(core->routers, rnode);
 
@@ -373,7 +378,7 @@ static void qdrh_set_link_CT(qdr_core_t *core, qdr_action_t *action, bool discar
         return;
     }
 
-    if (core->out_links_by_mask_bit[link_maskbit] == 0) {
+    if (core->control_links_by_mask_bit[link_maskbit] == 0) {
         qd_log(core->log, QD_LOG_CRITICAL, "set_link: Invalid link reference: %d", link_maskbit);
         return;
     }
@@ -387,7 +392,8 @@ static void qdrh_set_link_CT(qdr_core_t *core, qdr_action_t *action, bool discar
     // Add the peer_link reference to the router record.
     //
     qdr_node_t *rnode = core->routers_by_mask_bit[router_maskbit];
-    rnode->peer_link = core->out_links_by_mask_bit[link_maskbit];
+    rnode->peer_control_link = core->control_links_by_mask_bit[link_maskbit];
+    rnode->peer_data_link    = core->data_links_by_mask_bit[link_maskbit];
 }
 
 
@@ -406,7 +412,8 @@ static void qdrh_remove_link_CT(qdr_core_t *core, qdr_action_t *action, bool dis
     }
 
     qdr_node_t *rnode = core->routers_by_mask_bit[router_maskbit];
-    rnode->peer_link = 0;
+    rnode->peer_control_link = 0;
+    rnode->peer_data_link    = 0;
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/58d9f3fc/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 19f6c15..5681fad 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -132,8 +132,9 @@ struct qdr_node_t {
     DEQ_LINKS(qdr_node_t);
     qdr_address_t    *owning_addr;
     int               mask_bit;
-    qdr_node_t       *next_hop;   ///< Next hop node _if_ this is not a neighbor node
-    qdr_link_t       *peer_link;  ///< Outgoing link _if_ this is a neighbor node
+    qdr_node_t       *next_hop;           ///< Next hop node _if_ this is not a neighbor node
+    qdr_link_t       *peer_control_link;  ///< Outgoing control link _if_ this is a neighbor node
+    qdr_link_t       *peer_data_link;     ///< Outgoing data link _if_ this is a neighbor node
     uint32_t          ref_count;
     qd_bitmask_t     *valid_origins;
 };
@@ -154,13 +155,14 @@ DEQ_DECLARE(qdr_router_ref_t, qdr_router_ref_list_t);
 struct qdr_link_t {
     DEQ_LINKS(qdr_link_t);
     qdr_core_t               *core;
-    qdr_connection_t         *conn;
+    void                     *user_context;
+    qdr_connection_t         *conn;            ///< [ref] Connection that owns this link
     int                       mask_bit;        ///< Unique mask bit if this is an inter-router link
     qd_link_type_t            link_type;
     qd_direction_t            link_direction;
     qdr_address_t            *owning_addr;     ///< [ref] Address record that owns this link
     //qd_waypoint_t            *waypoint;        ///< [ref] Waypoint that owns this link
-    qd_link_t                *link;            ///< [own] Link pointer
+    qd_link_t                *link;            ///< [own] Link pointer DEPRECATE
     qdr_link_t               *connected_link;  ///< [ref] If this is a link-route, reference the connected link
     qdr_link_ref_t           *ref;             ///< Pointer to a containing reference object
     char                     *target;          ///< Target address for incoming links
@@ -246,6 +248,9 @@ struct qdr_connection_t {
     bool                   incoming;
     qdr_connection_role_t  role;
     const char            *label;
+    int                    mask_bit;
+
+    // TODO - Add direct linkage to waypoints, link-route destinations, and links
 };
 
 ALLOC_DECLARE(qdr_connection_t);
@@ -290,8 +295,10 @@ struct qdr_core_t {
 
     qdr_link_list_t       links;
     qdr_node_list_t       routers;
+    qd_bitmask_t         *neighbor_free_mask;
     qdr_node_t          **routers_by_mask_bit;
-    qdr_link_t          **out_links_by_mask_bit;
+    qdr_link_t          **control_links_by_mask_bit;
+    qdr_link_t          **data_links_by_mask_bit;
 };
 
 void *router_core_thread(void *arg);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/58d9f3fc/src/router_node.c
----------------------------------------------------------------------
diff --git a/src/router_node.c b/src/router_node.c
index b776f28..acd25d0 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -346,6 +346,8 @@ static void qd_router_generate_temp_addr(qd_router_t *router, char *buffer, size
 /**
  * Assign a link-mask-bit to a new link.  Do this in such a way that all links on the same
  * connection share the same mask-bit value.
+ *
+ * DEPRECATE
  */
 static int qd_router_find_mask_bit_LH(qd_router_t *router, qd_link_t *link)
 {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/58d9f3fc/src/router_private.h
----------------------------------------------------------------------
diff --git a/src/router_private.h b/src/router_private.h
index a8ae67a..6ecaaa9 100644
--- a/src/router_private.h
+++ b/src/router_private.h
@@ -54,7 +54,8 @@ ENUM_DECLARE(qd_router_mode);
 typedef enum {
     QD_LINK_ENDPOINT,   ///< A link to a connected endpoint
     QD_LINK_WAYPOINT,   ///< A link to a configured waypoint
-    QD_LINK_ROUTER,     ///< A link to a peer router in the same area
+    QD_LINK_CONTROL,    ///< A link to a peer router for control messages
+    QD_LINK_ROUTER,     ///< A link to a peer router for routed messages
     QD_LINK_AREA        ///< A link to a peer router in a different area (area boundary)
 } qd_link_type_t;
 ENUM_DECLARE(qd_link_type);


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