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 2016/02/22 23:02:42 UTC

[3/3] qpid-dispatch git commit: DISPATCH-179 - Connected linkRoutePattern configuration to the core.

DISPATCH-179 - Connected linkRoutePattern configuration to the core.


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

Branch: refs/heads/tross-DISPATCH-179-1
Commit: 75390ae35f478de59f5705f18279e39d31525fec
Parents: b0c0b04
Author: Ted Ross <tr...@redhat.com>
Authored: Mon Feb 22 16:18:33 2016 -0500
Committer: Ted Ross <tr...@redhat.com>
Committed: Mon Feb 22 16:18:33 2016 -0500

----------------------------------------------------------------------
 src/router_config.c                 | 140 +++++++------------------------
 src/router_core/agent_provisioned.c |  34 ++++++--
 2 files changed, 58 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75390ae3/src/router_config.c
----------------------------------------------------------------------
diff --git a/src/router_config.c b/src/router_config.c
index 94da8fc..9064c2e 100644
--- a/src/router_config.c
+++ b/src/router_config.c
@@ -93,6 +93,7 @@ qd_error_t qd_router_configure_address(qd_router_t *router, qd_entity_t *entity)
 
     qdr_manage_create(router->router_core, 0, QD_ROUTER_PROVISIONED, 0, in_body, 0);
 
+    free(prefix);
     return qd_error_code();
 }
 
@@ -131,128 +132,45 @@ qd_error_t qd_router_configure_waypoint(qd_router_t *router, qd_entity_t *entity
 
 qd_error_t qd_router_configure_lrp(qd_router_t *router, qd_entity_t *entity)
 {
-    /*
     char *prefix    = qd_entity_get_string(entity, "prefix"); QD_ERROR_RET();
     char *connector = qd_entity_get_string(entity, "connector"); QD_ERROR_RET();
     char *direction = qd_entity_get_string(entity, "dir"); QD_ERROR_RET();
-    bool inbound    = true;
-    bool outbound   = true;
-
-    if (direction && strcmp(direction, "in") == 0)
-        outbound = false;
-    if (direction && strcmp(direction, "out") == 0)
-        inbound = false;
-
-    sys_mutex_lock(router->lock);
-    if (connector && connector[0]) {
-        //
-        // Look for an existing lrp_container for the same connector name
-        //
-        qd_lrp_container_t *lrpc = DEQ_HEAD(router->lrp_containers);
-        while (lrpc) {
-            if (strcmp(qd_config_connector_name(lrpc->cc), connector) == 0)
-                break;
-            lrpc = DEQ_NEXT(lrpc);
-        }
-
-        //
-        // If no lrp_container was found, create one and add it to the list
-        //
-        if (lrpc == 0) {
-            qd_config_connector_t *cc = qd_connection_manager_find_on_demand(router->qd, connector);
-            if (cc) {
-                lrpc = NEW(qd_lrp_container_t);
-                DEQ_ITEM_INIT(lrpc);
-                lrpc->qd    = router->qd;
-                lrpc->cc    = cc;
-                lrpc->timer = qd_timer(router->qd, qd_lrpc_timer_handler, lrpc);
-                lrpc->conn  = 0;
-                DEQ_INIT(lrpc->lrps);
-                DEQ_INSERT_TAIL(router->lrp_containers, lrpc);
-
-                qd_timer_schedule(lrpc->timer, 0);
-            }
-        }
-
-        if (lrpc == 0) {
-            sys_mutex_unlock(router->lock);
-            free(prefix);
-            free(connector);
-            return qd_error(QD_ERROR_CONFIG, "Link-route-pattern configured with unknown connector: %s", connector);
-        }
-
-        qd_lrp_t *lrp = qd_lrp_LH(prefix, inbound, outbound, lrpc);
-
-        if (!lrp) {
-            sys_mutex_unlock(router->lock);
-            qd_error_t err = qd_error(QD_ERROR_CONFIG,
-                                      "Failed to create link-route-pattern: prefix=%s connector=%s",
-                                      prefix, connector);
-            free(prefix);
-            free(connector);
-            return err;
-        }
-
-        qd_log(router->log_source, QD_LOG_INFO,
-               "Configured Link-route-pattern: prefix=%s dir=%s connector=%s", prefix, direction, connector);
-    } else
-        qd_log(router->log_source, QD_LOG_INFO,
-               "Configured Remote Link-route-pattern: prefix=%s dir=%s", prefix, direction);
 
     //
-    // Create an address iterator for the prefix address with the namespace
-    // prefix for link-attach routed addresses.
+    // Formulate this configuration as a router.provisioned and create it through the core management API.
     //
-    char                 unused;
-    qd_address_t        *addr;
-    qd_field_iterator_t *iter = qd_address_iterator_string(prefix, ITER_VIEW_ADDRESS_HASH);
-
-    if (inbound) {
-        //
-        // Find the address in the router's hash table.  If not found, create one
-        // and hash it into the table.
-        //
-        qd_address_iterator_override_prefix(iter, 'C');
-        qd_hash_retrieve(router->addr_hash, iter, (void**) &addr);
-        if (!addr) {
-            addr = qd_address(router_semantics_for_addr(router, iter, '\0', &unused));
-            qd_hash_insert(router->addr_hash, iter, addr, &addr->hash_handle);
-            DEQ_INSERT_TAIL(router->addrs, addr);
-            qd_entity_cache_add(QD_ROUTER_ADDRESS_TYPE, addr);
-        }
-
-        //
-        // Since this is a configured address, block its deletion.
-        //
-        addr->block_deletion = true;
-    }
+    qd_composed_field_t *body = qd_compose_subfield(0);
+    qd_compose_start_map(body);
+    qd_compose_insert_string(body, "objectType");
+    qd_compose_insert_string(body, "linkDestination");
+
+    qd_compose_insert_string(body, "address");
+    qd_compose_insert_string(body, prefix);
+
+    qd_compose_insert_string(body, "direction");
+    qd_compose_insert_string(body, direction);
+    qd_compose_end_map(body);
+
+    int              length = 0;
+    qd_buffer_list_t buffers;
+
+    qd_compose_take_buffers(body, &buffers);
+    qd_compose_free(body);
 
-    if (outbound) {
-        //
-        // Find the address in the router's hash table.  If not found, create one
-        // and hash it into the table.
-        //
-        qd_address_iterator_reset_view(iter, ITER_VIEW_ADDRESS_HASH);
-        qd_address_iterator_override_prefix(iter, 'D');
-        qd_hash_retrieve(router->addr_hash, iter, (void**) &addr);
-        if (!addr) {
-            addr = qd_address(router_semantics_for_addr(router, iter, '\0', &unused));
-            qd_hash_insert(router->addr_hash, iter, addr, &addr->hash_handle);
-            DEQ_INSERT_TAIL(router->addrs, addr);
-            qd_entity_cache_add(QD_ROUTER_ADDRESS_TYPE, addr);
-        }
-
-        //
-        // Since this is a configured address, block its deletion.
-        //
-        addr->block_deletion = true;
+    qd_buffer_t *buf = DEQ_HEAD(buffers);
+    while (buf) {
+        length += qd_buffer_size(buf);
+        buf = DEQ_NEXT(buf);
     }
 
-    sys_mutex_unlock(router->lock);
-    qd_field_iterator_free(iter);
+    qd_field_iterator_t *iter = qd_field_iterator_buffer(DEQ_HEAD(buffers), 0, length);
+    qd_parsed_field_t   *in_body = qd_parse(iter);
+
+    qdr_manage_create(router->router_core, 0, QD_ROUTER_PROVISIONED, 0, in_body, 0);
+
     free(prefix);
     free(connector);
-    */
+    free(direction);
     return qd_error_code();
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75390ae3/src/router_core/agent_provisioned.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_provisioned.c b/src/router_core/agent_provisioned.c
index 1c99c7a..5b58c7f 100644
--- a/src/router_core/agent_provisioned.c
+++ b/src/router_core/agent_provisioned.c
@@ -179,10 +179,12 @@ void qdra_provisioned_get_next_CT(qdr_core_t *core, qdr_query_t *query)
 
 static qd_address_semantics_t qdra_semantics(qd_parsed_field_t *field)
 {
-    qd_field_iterator_t *iter = qd_parse_raw(field);
-    if (qd_field_iterator_equal(iter, (unsigned char*) "multi"))       return QD_SEMANTICS_MULTICAST_ONCE;
-    if (qd_field_iterator_equal(iter, (unsigned char*) "anyClosest"))  return QD_SEMANTICS_ANYCAST_CLOSEST;
-    if (qd_field_iterator_equal(iter, (unsigned char*) "anyBalanced")) return QD_SEMANTICS_ANYCAST_BALANCED;
+    if (field) {
+        qd_field_iterator_t *iter = qd_parse_raw(field);
+        if (qd_field_iterator_equal(iter, (unsigned char*) "multi"))       return QD_SEMANTICS_MULTICAST_ONCE;
+        if (qd_field_iterator_equal(iter, (unsigned char*) "anyClosest"))  return QD_SEMANTICS_ANYCAST_CLOSEST;
+        if (qd_field_iterator_equal(iter, (unsigned char*) "anyBalanced")) return QD_SEMANTICS_ANYCAST_BALANCED;
+    }
     return QD_SEMANTICS_ANYCAST_BALANCED;
 }
 
@@ -221,7 +223,29 @@ static qdr_address_config_t *qdra_configure_address_prefix_CT(qdr_core_t *core,
 static qdr_address_t *qdra_configure_address_CT(qdr_core_t *core, qd_parsed_field_t *addr_field, char cls,
                                                 qd_address_semantics_t semantics)
 {
-    return 0;
+    if (!addr_field)
+        return 0;
+
+    qd_field_iterator_t *iter = qd_parse_raw(addr_field);
+    qd_address_iterator_override_prefix(iter, cls);
+    qd_address_iterator_reset_view(iter, ITER_VIEW_ADDRESS_HASH);
+
+    qdr_address_t *addr = 0;
+    qd_hash_retrieve(core->addr_hash, iter, (void**) &addr);
+    if (addr) {
+        // Log error TODO
+        return 0;
+    }
+
+    addr = qdr_address_CT(core, semantics);
+
+    if (!!addr) {
+        qd_field_iterator_reset(iter);
+        qd_hash_insert(core->addr_hash, iter, addr, &addr->hash_handle);
+        DEQ_INSERT_TAIL(core->addrs, addr);
+    }
+
+    return addr;
 }
 
 


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