diff options
| author | Ted Ross <tross@apache.org> | 2013-10-09 21:17:58 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2013-10-09 21:17:58 +0000 |
| commit | 94374b4bcdf57dd6186fbeba4787dd9395fb8c83 (patch) | |
| tree | 795128260fff375aac13d54a378d842112a2ad40 /qpid | |
| parent | 7e9151221f24c6fdb11e00bd79a01a51f7c24b82 (diff) | |
| download | qpid-python-94374b4bcdf57dd6186fbeba4787dd9395fb8c83.tar.gz | |
QPID-5220 - Added configuration support for three operational modes of the router.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1530798 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
| -rw-r--r-- | qpid/extras/dispatch/etc/qpid-dispatch.conf | 52 | ||||
| -rw-r--r-- | qpid/extras/dispatch/python/qpid/dispatch/config/schema.py | 1 | ||||
| -rw-r--r-- | qpid/extras/dispatch/src/dispatch.c | 27 | ||||
| -rw-r--r-- | qpid/extras/dispatch/src/router_node.c | 16 | ||||
| -rw-r--r-- | qpid/extras/dispatch/src/router_private.h | 7 | ||||
| -rw-r--r-- | qpid/extras/dispatch/src/router_pynode.c | 9 | ||||
| -rw-r--r-- | qpid/extras/dispatch/tests/threerouters-A.conf | 8 | ||||
| -rw-r--r-- | qpid/extras/dispatch/tests/threerouters-B.conf | 6 | ||||
| -rw-r--r-- | qpid/extras/dispatch/tests/threerouters-C.conf | 6 | ||||
| -rw-r--r-- | qpid/extras/dispatch/tests/tworouters-A.conf | 5 | ||||
| -rw-r--r-- | qpid/extras/dispatch/tests/tworouters-B.conf | 5 |
11 files changed, 92 insertions, 50 deletions
diff --git a/qpid/extras/dispatch/etc/qpid-dispatch.conf b/qpid/extras/dispatch/etc/qpid-dispatch.conf index ce7f5ed4c1..4e74f1e96b 100644 --- a/qpid/extras/dispatch/etc/qpid-dispatch.conf +++ b/qpid/extras/dispatch/etc/qpid-dispatch.conf @@ -125,49 +125,27 @@ connector { ## router { ## - ## area and router-id - Each router is assigned an area name and a - ## router-id that is unique within the area. - ## - area: all - router-id: Router.A - - ## - ## hello-interval - The interval, in seconds, between HELLO messages - ## sent between connected routers. This interval can be relatively - ## fast because HELLO messages do not propagate beyond one hop on the - ## network. A good value is 1 second. - ## - hello-interval: 1 - + ## Router Mode: ## - ## hello-max-age - The maximum time, in seconds, that can elapse - ## without receiving a HELLO message from a neighbor before that - ## neighbor is declared absent. A good value is 3 seconds. + ## standalone - Standalone router. In standalone mode, the router operates as + ## a single component. It does not participate in the routing protocol + ## and therefore will not coorperate with other routers. + ## interior - Interior router. The router operates in cooreration with other + ## interior routers in an interconnected network. + ## edge - Edge router. The router operates with an uplink into an interior + ## router network. Edge routers are typically used as connection concentrators + ## or as security firewalls for access into the interior network. ## - hello-max-age: 3 + mode: standalone ## - ## ra-interval - The interval, in seconds, between RA (Router - ## Advertisement) messages sent by this router. This interval should - ## be considerably longer than the hello interval because RA messages - ## propagate across the area. A good value is 30 seconds. + ## For Interior router mode only. ## - ra-interval: 30 - - ## - ## remote-ls-max-age - The maximum age, in seconds, of a remote - ## link-state record. Any such records that are not updated and time - ## out shall be removed from the set and the topology shall be - ## recomputed. A good value is 60 seconds. - ## - remote-ls-max-age: 60 - - ## - ## mobile-addr-max-age - The maximum age, in seconds, of a remote - ## mobile address record. Any record that exceeds this age shall be - ## removed from the routing table. A good value is 60 seconds. + ## area and router-id - Each router is assigned an area name and a + ## router-id that is unique within the area. ## - mobile-addr-max-age: 60 + area: all + router-id: Router.A } diff --git a/qpid/extras/dispatch/python/qpid/dispatch/config/schema.py b/qpid/extras/dispatch/python/qpid/dispatch/config/schema.py index 545139f0df..1b3fe885cb 100644 --- a/qpid/extras/dispatch/python/qpid/dispatch/config/schema.py +++ b/qpid/extras/dispatch/python/qpid/dispatch/config/schema.py @@ -71,6 +71,7 @@ config_schema = { 'allow-redirect' : (bool, None, "", True) }), 'router' : (True, { + 'mode' : (str, None, "", 'standalone'), 'router-id' : (str, None, "M"), 'area' : (str, None, "", None), 'hello-interval' : (int, None, "", 1), diff --git a/qpid/extras/dispatch/src/dispatch.c b/qpid/extras/dispatch/src/dispatch.c index 2e37f4c6e8..6e406de7fb 100644 --- a/qpid/extras/dispatch/src/dispatch.c +++ b/qpid/extras/dispatch/src/dispatch.c @@ -24,6 +24,7 @@ #include "dispatch_private.h" #include "alloc_private.h" #include "log_private.h" +#include "router_private.h" /** * Private Function Prototypes @@ -34,7 +35,7 @@ void dx_server_free(dx_server_t *server); dx_container_t *dx_container(dx_dispatch_t *dx); void dx_container_setup_agent(dx_dispatch_t *dx); void dx_container_free(dx_container_t *container); -dx_router_t *dx_router(dx_dispatch_t *dx, const char *area, const char *id); +dx_router_t *dx_router(dx_dispatch_t *dx, dx_router_mode_t mode, const char *area, const char *id); void dx_router_setup_late(dx_dispatch_t *dx); void dx_router_free(dx_router_t *router); dx_agent_t *dx_agent(dx_dispatch_t *dx); @@ -53,10 +54,13 @@ dx_dispatch_t *dx_dispatch(const char *config_path) { dx_dispatch_t *dx = NEW(dx_dispatch_t); - int thread_count = 0; - const char *container_name = 0; - const char *router_area = 0; - const char *router_id = 0; + int thread_count = 0; + const char *container_name = 0; + const char *router_mode_str = 0; + const char *router_area = 0; + const char *router_id = 0; + + dx_router_mode_t router_mode = DX_ROUTER_MODE_STANDALONE; DEQ_INIT(dx->config_listeners); DEQ_INIT(dx->config_connectors); @@ -78,8 +82,9 @@ dx_dispatch_t *dx_dispatch(const char *config_path) count = dx_config_item_count(dx->config, CONF_ROUTER); if (count == 1) { - router_area = dx_config_item_value_string(dx->config, CONF_ROUTER, 0, "area"); - router_id = dx_config_item_value_string(dx->config, CONF_ROUTER, 0, "router-id"); + router_mode_str = dx_config_item_value_string(dx->config, CONF_ROUTER, 0, "mode"); + router_area = dx_config_item_value_string(dx->config, CONF_ROUTER, 0, "area"); + router_id = dx_config_item_value_string(dx->config, CONF_ROUTER, 0, "router-id"); } } @@ -89,6 +94,12 @@ dx_dispatch_t *dx_dispatch(const char *config_path) if (!container_name) container_name = "00000000-0000-0000-0000-000000000000"; // TODO - gen a real uuid + if (router_mode_str && strcmp(router_mode_str, "interior") == 0) + router_mode = DX_ROUTER_MODE_INTERIOR; + + if (router_mode_str && strcmp(router_mode_str, "edge") == 0) + router_mode = DX_ROUTER_MODE_EDGE; + if (!router_area) router_area = "area"; @@ -97,7 +108,7 @@ dx_dispatch_t *dx_dispatch(const char *config_path) dx->server = dx_server(thread_count, container_name); dx->container = dx_container(dx); - dx->router = dx_router(dx, router_area, router_id); + dx->router = dx_router(dx, router_mode, router_area, router_id); dx->agent = dx_agent(dx); dx_alloc_setup_agent(dx); diff --git a/qpid/extras/dispatch/src/router_node.c b/qpid/extras/dispatch/src/router_node.c index 2493fcd0b9..b10e4d2d91 100644 --- a/qpid/extras/dispatch/src/router_node.c +++ b/qpid/extras/dispatch/src/router_node.c @@ -973,7 +973,7 @@ static dx_node_type_t router_node = {"router", 0, 0, static int type_registered = 0; -dx_router_t *dx_router(dx_dispatch_t *dx, const char *area, const char *id) +dx_router_t *dx_router(dx_dispatch_t *dx, dx_router_mode_t mode, const char *area, const char *id) { if (!type_registered) { type_registered = 1; @@ -994,6 +994,7 @@ dx_router_t *dx_router(dx_dispatch_t *dx, const char *area, const char *id) dx->router = router; router->dx = dx; + router->router_mode = mode; router->router_area = area; router->router_id = id; router->node = dx_container_set_default_node_type(dx, &router_node, (void*) router, DX_DIST_BOTH); @@ -1021,8 +1022,10 @@ dx_router_t *dx_router(dx_dispatch_t *dx, const char *area, const char *id) // Create addresses for all of the routers in the topology. It will be registered // locally later in the initialization sequence. // - router->router_addr = dx_router_register_address(dx, "qdxrouter", 0, 0); - router->hello_addr = dx_router_register_address(dx, "qdxhello", 0, 0); + if (router->router_mode == DX_ROUTER_MODE_INTERIOR) { + router->router_addr = dx_router_register_address(dx, "qdxrouter", 0, 0); + router->hello_addr = dx_router_register_address(dx, "qdxhello", 0, 0); + } // // Inform the field iterator module of this router's id and area. The field iterator @@ -1035,7 +1038,12 @@ dx_router_t *dx_router(dx_dispatch_t *dx, const char *area, const char *id) // dx_python_start(); - dx_log(module, LOG_INFO, "Router started, area=%s id=%s", area, id); + switch (router->router_mode) { + case DX_ROUTER_MODE_STANDALONE: dx_log(module, LOG_INFO, "Router started in Standalone mode"); break; + case DX_ROUTER_MODE_INTERIOR: dx_log(module, LOG_INFO, "Router started in Interior mode, area=%s id=%s", area, id); break; + case DX_ROUTER_MODE_EDGE: dx_log(module, LOG_INFO, "Router started in Edge mode"); break; + } + return router; } diff --git a/qpid/extras/dispatch/src/router_private.h b/qpid/extras/dispatch/src/router_private.h index 1457601b0b..35664f8e29 100644 --- a/qpid/extras/dispatch/src/router_private.h +++ b/qpid/extras/dispatch/src/router_private.h @@ -30,6 +30,12 @@ void dx_pyrouter_tick(dx_router_t *router); void dx_router_agent_setup(dx_router_t *router); typedef enum { + DX_ROUTER_MODE_STANDALONE, // Standalone router. No routing protocol participation + DX_ROUTER_MODE_INTERIOR, // Interior router. Full participation in routing protocol. + DX_ROUTER_MODE_EDGE // Edge router. No routing protocol participation, access via other protocols. +} dx_router_mode_t; + +typedef enum { DX_LINK_ENDPOINT, // A link to a connected endpoint DX_LINK_ROUTER, // A link to a peer router in the same area DX_LINK_AREA // A link to a peer router in a different area (area boundary) @@ -122,6 +128,7 @@ DEQ_DECLARE(dx_address_t, dx_address_list_t); struct dx_router_t { dx_dispatch_t *dx; + dx_router_mode_t router_mode; const char *router_area; const char *router_id; dx_node_t *node; diff --git a/qpid/extras/dispatch/src/router_pynode.c b/qpid/extras/dispatch/src/router_pynode.c index e195243a05..70882326af 100644 --- a/qpid/extras/dispatch/src/router_pynode.c +++ b/qpid/extras/dispatch/src/router_pynode.c @@ -444,6 +444,13 @@ static PyTypeObject RouterAdapterType = { void dx_router_python_setup(dx_router_t *router) { + // + // If we are not operating as an interior router, don't start the + // router module. + // + if (router->router_mode != DX_ROUTER_MODE_INTERIOR) + return; + PyObject *pDispatchModule = dx_python_module(); RouterAdapterType.tp_new = PyType_GenericNew; @@ -534,7 +541,7 @@ void dx_pyrouter_tick(dx_router_t *router) PyObject *pArgs; PyObject *pValue; - if (router->pyTick) { + if (router->pyTick && router->router_mode == DX_ROUTER_MODE_INTERIOR) { dx_python_lock(); pArgs = PyTuple_New(0); pValue = PyObject_CallObject(router->pyTick, pArgs); diff --git a/qpid/extras/dispatch/tests/threerouters-A.conf b/qpid/extras/dispatch/tests/threerouters-A.conf index 81e20365a9..c8c74d6eb2 100644 --- a/qpid/extras/dispatch/tests/threerouters-A.conf +++ b/qpid/extras/dispatch/tests/threerouters-A.conf @@ -59,3 +59,11 @@ connector { sasl-mechanisms: ANONYMOUS } +router { + mode: interior + area: A + router-id: QDR.A +} + + + diff --git a/qpid/extras/dispatch/tests/threerouters-B.conf b/qpid/extras/dispatch/tests/threerouters-B.conf index 40f3704ce3..12dfc11c54 100644 --- a/qpid/extras/dispatch/tests/threerouters-B.conf +++ b/qpid/extras/dispatch/tests/threerouters-B.conf @@ -59,3 +59,9 @@ connector { sasl-mechanisms: ANONYMOUS } + +router { + mode: interior + area: A + router-id: QDR.B +} diff --git a/qpid/extras/dispatch/tests/threerouters-C.conf b/qpid/extras/dispatch/tests/threerouters-C.conf index 3721653133..03ec5296f9 100644 --- a/qpid/extras/dispatch/tests/threerouters-C.conf +++ b/qpid/extras/dispatch/tests/threerouters-C.conf @@ -52,3 +52,9 @@ listener { sasl-mechanisms: ANONYMOUS } + +router { + mode: interior + area: A + router-id: QDR.C +} diff --git a/qpid/extras/dispatch/tests/tworouters-A.conf b/qpid/extras/dispatch/tests/tworouters-A.conf index b4a5770c2d..d46d47787b 100644 --- a/qpid/extras/dispatch/tests/tworouters-A.conf +++ b/qpid/extras/dispatch/tests/tworouters-A.conf @@ -52,3 +52,8 @@ listener { sasl-mechanisms: ANONYMOUS } +router { + mode: interior + area: A + router-id: QDR.A +} diff --git a/qpid/extras/dispatch/tests/tworouters-B.conf b/qpid/extras/dispatch/tests/tworouters-B.conf index d56bd45078..f0d689755a 100644 --- a/qpid/extras/dispatch/tests/tworouters-B.conf +++ b/qpid/extras/dispatch/tests/tworouters-B.conf @@ -59,3 +59,8 @@ connector { sasl-mechanisms: ANONYMOUS } +router { + mode: interior + area: A + router-id: QDR.B +} |
