Author: tross
Date: Fri Jan 23 18:44:28 2015
New Revision: 1654305

URL: http://svn.apache.org/r1654305
Log:
DISPATCH-6 - Added configuration support for external containers

Added:
    qpid/dispatch/trunk/src/ext_container.c   (with props)
    qpid/dispatch/trunk/src/ext_container_private.h   (with props)
    qpid/dispatch/trunk/tests/config-2-broker/
    qpid/dispatch/trunk/tests/config-2-broker/A.conf
    qpid/dispatch/trunk/tests/config-2-broker/B.conf
Modified:
    qpid/dispatch/trunk/include/qpid/dispatch/ctools.h
    qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json
    qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py
    qpid/dispatch/trunk/src/CMakeLists.txt
    qpid/dispatch/trunk/src/dispatch.c
    qpid/dispatch/trunk/src/dispatch_private.h
    qpid/dispatch/trunk/src/router_config.c
    qpid/dispatch/trunk/src/router_private.h

Modified: qpid/dispatch/trunk/include/qpid/dispatch/ctools.h
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/include/qpid/dispatch/ctools.h?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/include/qpid/dispatch/ctools.h (original)
+++ qpid/dispatch/trunk/include/qpid/dispatch/ctools.h Fri Jan 23 18:44:28 2015
@@ -42,6 +42,7 @@
     } d
 
 #define DEQ_LINKS(t) t *prev; t *next
+#define DEQ_EMPTY {0,0,0,0}
 
 #define DEQ_INIT(d) do { (d).head = 0; (d).tail = 0; (d).scratch = 0; (d).size 
= 0; } while (0)
 #define DEQ_ITEM_INIT(i) do { (i)->next = 0; (i)->prev = 0; } while(0)

Modified: qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json Fri Jan 
23 18:44:28 2015
@@ -362,6 +362,24 @@
             }
         },
 
+        "externalContainer": {
+            "description":"A remote AMQP container that holds nodes that are 
endpoints for routed links.",
+            "extends": "configurationEntity",
+            "operations": ["CREATE", "READ"],
+            "attributes": {
+                "prefix": {
+                    "description":"The AMQP address prefix for nodes on the 
container.",
+                    "type": "String",
+                    "required": true
+                },
+                "connector": {
+                    "description":"The name of the on-demand connector used to 
reach the waypoint's container.",
+                    "type": "String",
+                    "required": true
+                }
+            }
+        },
+
         "dummy": {
             "description": "Dummy entity for test purposes.",
             "extends": "entity",

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py Fri Jan 23 
18:44:28 2015
@@ -52,6 +52,7 @@ class QdDll(ctypes.PyDLL):
         self._prototype(self.qd_dispatch_configure_connector, None, 
[self.qd_dispatch_p, py_object])
         self._prototype(self.qd_dispatch_configure_address, None, 
[self.qd_dispatch_p, py_object])
         self._prototype(self.qd_dispatch_configure_waypoint, None, 
[self.qd_dispatch_p, py_object])
+        self._prototype(self.qd_dispatch_configure_external_container, None, 
[self.qd_dispatch_p, py_object])
         self._prototype(self.qd_dispatch_set_agent, None, [self.qd_dispatch_p, 
py_object])
 
         self._prototype(self.qd_router_setup_late, None, [self.qd_dispatch_p])

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py Fri 
Jan 23 18:44:28 2015
@@ -246,6 +246,10 @@ class WaypointEntity(AgentEntity):
         self._qd.qd_dispatch_configure_waypoint(self._dispatch, self)
         self._qd.qd_waypoint_activate_all(self._dispatch)
 
+class ExternalContainerEntity(AgentEntity):
+    def create(self):
+        self._qd.qd_dispatch_configure_external_container(self._dispatch, self)
+
 class DummyEntity(AgentEntity):
 
     def callme(self, request):

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py Fri 
Jan 23 18:44:28 2015
@@ -154,7 +154,7 @@ def configure_dispatch(dispatch, lib_han
     qd.qd_router_setup_late(dispatch) # Actions requiring active management 
agent.
 
     # Remaining configuration
-    for t in "fixedAddress", "listener", "connector", "waypoint":
+    for t in "fixedAddress", "listener", "connector", "waypoint", 
"externalContainer":
         for a in config.by_type(t): configure(a)
     for e in config.entities:
         configure(e)

Modified: qpid/dispatch/trunk/src/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/CMakeLists.txt?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/CMakeLists.txt (original)
+++ qpid/dispatch/trunk/src/CMakeLists.txt Fri Jan 23 18:44:28 2015
@@ -54,6 +54,7 @@ set(qpid_dispatch_SOURCES
   dispatch.c
   entity.c
   entity_cache.c
+  ext_container.c
   hash.c
   iovec.c
   iterator.c

Modified: qpid/dispatch/trunk/src/dispatch.c
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/dispatch.c?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/dispatch.c (original)
+++ qpid/dispatch/trunk/src/dispatch.c Fri Jan 23 18:44:28 2015
@@ -125,6 +125,12 @@ qd_error_t qd_dispatch_configure_waypoin
     return qd_error_code();
 }
 
+qd_error_t qd_dispatch_configure_external_container(qd_dispatch_t *qd, 
qd_entity_t *entity) {
+    if (!qd->router) return qd_error(QD_ERROR_NOT_FOUND, "No router 
available");
+    qd_router_configure_external_container(qd->router, entity);
+    return qd_error_code();
+}
+
 qd_error_t qd_dispatch_prepare(qd_dispatch_t *qd)
 {
     qd->server             = qd_server(qd, qd->thread_count, 
qd->container_name);

Modified: qpid/dispatch/trunk/src/dispatch_private.h
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/dispatch_private.h?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/dispatch_private.h (original)
+++ qpid/dispatch/trunk/src/dispatch_private.h Fri Jan 23 18:44:28 2015
@@ -23,17 +23,18 @@
 // The following declarations are for types that are shared between modules 
yet are
 // not in the public API.
 //
-typedef struct qd_server_t          qd_server_t;
-typedef struct qd_container_t       qd_container_t;
-typedef struct qd_router_t          qd_router_t;
-typedef struct qd_waypoint_t        qd_waypoint_t;
-typedef struct qd_router_link_t     qd_router_link_t;
-typedef struct qd_router_node_t     qd_router_node_t;
-typedef struct qd_router_ref_t      qd_router_ref_t;
-typedef struct qd_router_link_ref_t qd_router_link_ref_t;
-typedef struct qd_router_conn_t     qd_router_conn_t;
-typedef struct qd_config_phase_t    qd_config_phase_t;
-typedef struct qd_config_address_t  qd_config_address_t;
+typedef struct qd_server_t             qd_server_t;
+typedef struct qd_container_t          qd_container_t;
+typedef struct qd_router_t             qd_router_t;
+typedef struct qd_waypoint_t           qd_waypoint_t;
+typedef struct qd_external_container_t qd_external_container_t;
+typedef struct qd_router_link_t        qd_router_link_t;
+typedef struct qd_router_node_t        qd_router_node_t;
+typedef struct qd_router_ref_t         qd_router_ref_t;
+typedef struct qd_router_link_ref_t    qd_router_link_ref_t;
+typedef struct qd_router_conn_t        qd_router_conn_t;
+typedef struct qd_config_phase_t       qd_config_phase_t;
+typedef struct qd_config_address_t     qd_config_address_t;
 
 #include <qpid/dispatch/container.h>
 #include <qpid/dispatch/router.h>
@@ -93,6 +94,11 @@ qd_error_t qd_dispatch_configure_address
 qd_error_t qd_dispatch_configure_waypoint(qd_dispatch_t *qd, qd_entity_t 
*entity);
 
 /**
+ * Configure an external container, must be called after qd_dispatch_prepare
+ */
+qd_error_t qd_dispatch_configure_external_container(qd_dispatch_t *qd, 
qd_entity_t *entity);
+
+/**
  * \brief Configure the logging module from the
  *        parsed configuration file.  This must be called after the
  *        call to qd_dispatch_prepare completes.

Added: qpid/dispatch/trunk/src/ext_container.c
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/ext_container.c?rev=1654305&view=auto
==============================================================================
--- qpid/dispatch/trunk/src/ext_container.c (added)
+++ qpid/dispatch/trunk/src/ext_container.c Fri Jan 23 18:44:28 2015
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "dispatch_private.h"
+#include "router_private.h"
+#include "entity_cache.h"
+#include <qpid/dispatch/ctools.h>
+#include <qpid/dispatch/connection_manager.h>
+#include <memory.h>
+#include <stdio.h>
+
+struct qd_external_container_t {
+    DEQ_LINKS(qd_external_container_t);
+    char *prefix;
+    char *connector_name;
+};
+
+DEQ_DECLARE(qd_external_container_t, qd_external_container_list_t);
+
+static qd_external_container_list_t ec_list = DEQ_EMPTY;
+
+qd_external_container_t *qd_external_container(qd_router_t *router, const char 
*prefix, const char *connector_name)
+{
+    qd_external_container_t *ec = NEW(qd_external_container_t);
+
+    if (ec) {
+        DEQ_ITEM_INIT(ec);
+        ec->prefix         = strdup(prefix);
+        ec->connector_name = strdup(connector_name);
+        DEQ_INSERT_TAIL(ec_list, ec);
+    }
+
+    return ec;
+}
+
+
+void qd_external_container_free(qd_external_container_t *ec)
+{
+    if (ec) {
+        free(ec->prefix);
+        free(ec->connector_name);
+        DEQ_REMOVE(ec_list, ec);
+        free(ec);
+    }
+}
+
+
+void qd_external_container_free_all(void)
+{
+    qd_external_container_t *ec = DEQ_HEAD(ec_list);
+    while (ec) {
+        DEQ_REMOVE_HEAD(ec_list);
+        qd_external_container_free(ec);
+        ec = DEQ_HEAD(ec_list);
+    }
+}
+

Propchange: qpid/dispatch/trunk/src/ext_container.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: qpid/dispatch/trunk/src/ext_container_private.h
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/ext_container_private.h?rev=1654305&view=auto
==============================================================================
--- qpid/dispatch/trunk/src/ext_container_private.h (added)
+++ qpid/dispatch/trunk/src/ext_container_private.h Fri Jan 23 18:44:28 2015
@@ -0,0 +1,41 @@
+#ifndef __ext_container_private_h__
+#define __ext_container_private_h__ 1
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "dispatch_private.h"
+
+/**
+ * @file
+ *
+ * An external container is an object that defines an address prefix for 
link-routing
+ * and associates that prefix with an on-demand connector.
+ *
+ * The address prefix is propagated across the network and can be used as a 
target for
+ * routed links destined for this external container.
+ */
+
+qd_external_container_t *qd_external_container(qd_router_t *router, const char 
*prefix, const char *connector_name);
+
+void qd_external_container_free(qd_external_container_t *ec);
+
+void qd_external_container_free_all(void);
+
+
+#endif

Propchange: qpid/dispatch/trunk/src/ext_container_private.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/dispatch/trunk/src/ext_container_private.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Modified: qpid/dispatch/trunk/src/router_config.c
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/router_config.c?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/router_config.c (original)
+++ qpid/dispatch/trunk/src/router_config.c Fri Jan 23 18:44:28 2015
@@ -22,6 +22,7 @@
 #include <qpid/dispatch/log.h>
 #include "dispatch_private.h"
 #include "router_private.h"
+#include "ext_container_private.h"
 #include "entity.h"
 #include "schema_enum.h"
 
@@ -135,6 +136,30 @@ qd_error_t qd_router_configure_waypoint(
 }
 
 
+qd_error_t qd_router_configure_external_container(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();
+
+    qd_external_container_t *ec = qd_external_container(router, prefix, 
connector);
+
+    if (!ec) {
+        free(prefix);
+        free(connector);
+        return qd_error(QD_ERROR_CONFIG, "Failed to create external container: 
prefix=%s connector=%s",
+                        prefix, connector);
+    }
+
+    qd_log(router->log_source, QD_LOG_INFO,
+           "Configured External Container: prefix=%s connector=%s",
+           prefix, connector);
+    free(prefix);
+    free(connector);
+    return qd_error_code();
+}
+
+
 void qd_router_configure_free(qd_router_t *router)
 {
     if (!router) return;
@@ -155,6 +180,8 @@ void qd_router_configure_free(qd_router_
         free(wp->connector_name);
         free(wp);
     }
+
+    qd_external_container_free_all();
 }
 
 

Modified: qpid/dispatch/trunk/src/router_private.h
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/router_private.h?rev=1654305&r1=1654304&r2=1654305&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/router_private.h (original)
+++ qpid/dispatch/trunk/src/router_private.h Fri Jan 23 18:44:28 2015
@@ -38,6 +38,7 @@ void qd_router_python_free(qd_router_t *
 qd_error_t qd_pyrouter_tick(qd_router_t *router);
 qd_error_t qd_router_configure_address(qd_router_t *router, qd_entity_t 
*entity);
 qd_error_t qd_router_configure_waypoint(qd_router_t *router, qd_entity_t 
*entity);
+qd_error_t qd_router_configure_external_container(qd_router_t *router, 
qd_entity_t *entity);
 
 void qd_router_configure_free(qd_router_t *router);
 

Added: qpid/dispatch/trunk/tests/config-2-broker/A.conf
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/config-2-broker/A.conf?rev=1654305&view=auto
==============================================================================
--- qpid/dispatch/trunk/tests/config-2-broker/A.conf (added)
+++ qpid/dispatch/trunk/tests/config-2-broker/A.conf Fri Jan 23 18:44:28 2015
@@ -0,0 +1,106 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License
+##
+
+
+##
+## Container section - Configures the general operation of the AMQP container.
+##
+container {
+    ##
+    ## worker-threads - The number of threads that will be created to
+    ## process message traffic and other application work (timers, non-amqp
+    ## file descriptors, etc.)
+    ##
+    ## The number of threads should be related to the number of available
+    ## processor cores.  To fully utilize a quad-core system, set the
+    ## number of threads to 4.
+    ##
+    worker-threads: 4
+
+    ##
+    ## container-name - The name of the AMQP container.  If not specified,
+    ## the container name will be set to a value of the container's
+    ## choosing.  The automatically assigned container name is not
+    ## guaranteed to be persistent across restarts of the container.
+    ##
+    container-name: Qpid.Dispatch.Router.A
+}
+
+
+##
+## Listeners and Connectors
+##
+listener {
+    addr: 0.0.0.0
+    port: amqp
+    sasl-mechanisms: ANONYMOUS
+}
+
+listener {
+    role: inter-router
+    addr: 0.0.0.0
+    port: 20102
+    sasl-mechanisms: ANONYMOUS
+}
+
+router {
+    mode: interior
+    router-id: QDR.A
+}
+
+connector {
+    name: broker
+    role: on-demand
+    addr: 0.0.0.0
+    port: 11000
+    sasl-mechanisms: ANONYMOUS
+}
+
+externalContainer {
+    prefix: /queue/
+    connector: broker
+}
+
+fixed-address {
+    prefix: /closest/
+    fanout: single
+    bias: closest
+}
+
+fixed-address {
+    prefix: /spread/
+    fanout: single
+    bias: spread
+}
+
+fixed-address {
+    prefix: /multicast/
+    fanout: multiple
+}
+
+fixed-address {
+    prefix: /
+    fanout: multiple
+}
+
+log {
+    module: ROUTER
+    enable: trace+
+}
+

Added: qpid/dispatch/trunk/tests/config-2-broker/B.conf
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/config-2-broker/B.conf?rev=1654305&view=auto
==============================================================================
--- qpid/dispatch/trunk/tests/config-2-broker/B.conf (added)
+++ qpid/dispatch/trunk/tests/config-2-broker/B.conf Fri Jan 23 18:44:28 2015
@@ -0,0 +1,92 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License
+##
+
+
+##
+## Container section - Configures the general operation of the AMQP container.
+##
+container {
+    ##
+    ## worker-threads - The number of threads that will be created to
+    ## process message traffic and other application work (timers, non-amqp
+    ## file descriptors, etc.)
+    ##
+    ## The number of threads should be related to the number of available
+    ## processor cores.  To fully utilize a quad-core system, set the
+    ## number of threads to 4.
+    ##
+    worker-threads: 4
+
+    ##
+    ## container-name - The name of the AMQP container.  If not specified,
+    ## the container name will be set to a value of the container's
+    ## choosing.  The automatically assigned container name is not
+    ## guaranteed to be persistent across restarts of the container.
+    ##
+    container-name: Qpid.Dispatch.Router.B
+}
+
+
+##
+## Listeners and Connectors
+##
+listener {
+    addr: 0.0.0.0
+    port: 20101
+    sasl-mechanisms: ANONYMOUS
+}
+
+connector {
+    role: inter-router
+    addr: 0.0.0.0
+    port: 20102
+    sasl-mechanisms: ANONYMOUS
+}
+
+router {
+    mode: interior
+    router-id: QDR.B
+}
+
+fixed-address {
+    prefix: /closest/
+    fanout: single
+    bias: closest
+}
+
+fixed-address {
+    prefix: /spread/
+    fanout: single
+    bias: spread
+}
+
+fixed-address {
+    prefix: /multicast/
+    fanout: multiple
+}
+
+fixed-address {
+    prefix: /
+    fanout: multiple
+}
+
+log {
+    module: ROUTER
+    enable: trace+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to