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 2018/08/24 17:57:27 UTC
qpid-dispatch git commit: DISPATCH-930 - Initial groundwork for
edge-router: - Added configuration elements for edge router mode and
edge-uplink connection role - Added iterator changes needed for interpreting
edge summary addresses and uplinks - A
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 6defbd86a -> b652fd408
DISPATCH-930 - Initial groundwork for edge-router:
- Added configuration elements for edge router mode and edge-uplink connection role
- Added iterator changes needed for interpreting edge summary addresses and uplinks
- Added test configuration for an edge with two interiors
- Added new system tests for edge router functionality
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/b652fd40
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/b652fd40
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/b652fd40
Branch: refs/heads/master
Commit: b652fd408a0ccfaeec4dd8f06c2e011a6eb86b55
Parents: 6defbd8
Author: Ted Ross <tr...@redhat.com>
Authored: Fri Aug 24 13:54:59 2018 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Fri Aug 24 13:54:59 2018 -0400
----------------------------------------------------------------------
include/qpid/dispatch/iterator.h | 22 +-
include/qpid/dispatch/router_core.h | 2 +-
python/qpid_dispatch/management/qdrouter.json | 15 +-
python/qpid_dispatch_internal/router/engine.py | 4 +-
src/iterator.c | 100 +++++--
src/python_embedded.c | 2 +-
src/router_core/agent_connection.c | 1 +
src/router_core/connections.c | 134 +++++++--
src/router_core/route_control.c | 4 +
src/router_core/route_tables.c | 4 +
src/router_core/router_core.c | 34 +++
src/router_core/router_core_private.h | 17 +-
src/router_node.c | 104 ++++---
tests/CMakeLists.txt | 1 +
tests/config-2-edge/EDGE25.conf | 39 +++
tests/config-2-edge/INTA.conf | 49 ++++
tests/config-2-edge/INTB.conf | 48 ++++
tests/field_test.c | 61 +++-
tests/parse_test.c | 2 +-
tests/system_tests_edge_router.py | 301 ++++++++++++++++++++
tools/qdstat.in | 11 +-
21 files changed, 829 insertions(+), 126 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/include/qpid/dispatch/iterator.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/iterator.h b/include/qpid/dispatch/iterator.h
index 2d4f922..fa4267c 100644
--- a/include/qpid/dispatch/iterator.h
+++ b/include/qpid/dispatch/iterator.h
@@ -44,6 +44,21 @@
*/
typedef struct qd_iterator_t qd_iterator_t;
+/**
+ * Address Hash Prefix Values
+ */
+#define QD_ITER_HASH_PREFIX_TOPOLOGICAL 'T'
+#define QD_ITER_HASH_PREFIX_LOCAL 'L'
+#define QD_ITER_HASH_PREFIX_AREA 'A'
+#define QD_ITER_HASH_PREFIX_ROUTER 'R'
+#define QD_ITER_HASH_PREFIX_MOBILE 'M'
+#define QD_ITER_HASH_PREFIX_LINKROUTE_ADDR_IN 'C'
+#define QD_ITER_HASH_PREFIX_LINKROUTE_ADDR_OUT 'D'
+#define QD_ITER_HASH_PREFIX_LINKROUTE_PATTERN_IN 'E'
+#define QD_ITER_HASH_PREFIX_LINKROUTE_PATTERN_OUT 'F'
+#define QD_ITER_HASH_PREFIX_GLOBAL_PLACEHOLDER 'G'
+#define QD_ITER_HASH_PREFIX_EDGE_SUMMARY 'H'
+
/**
* qd_iterator_view_t
@@ -80,6 +95,11 @@ typedef struct qd_iterator_t qd_iterator_t;
* L^^^^^^^
* amqp:/<mobile>
* M0^^^^^^^^
+ * amqp:/_edge/<my-router>/<local>
+ * L^^^^^^^
+ * amqp:/_edge/<router>/<local>
+ * H^^^^^^^^ [ interior mode ]
+ * L_uplink [ edge mode ]
*
* ITER_VIEW_NODE_HASH - Isolate the hashable part of a router-id, used for headers
*
@@ -125,7 +145,7 @@ typedef struct {
* @param area The name of the router's area
* @param router The identifier of the router in the area
*/
-void qd_iterator_set_address(const char *area, const char *router);
+void qd_iterator_set_address(bool edge_mode, const char *area, const char *router);
/** @} */
/** \name lifecycle
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/include/qpid/dispatch/router_core.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/router_core.h b/include/qpid/dispatch/router_core.h
index 5990ac1..695e7e5 100644
--- a/include/qpid/dispatch/router_core.h
+++ b/include/qpid/dispatch/router_core.h
@@ -151,7 +151,7 @@ typedef enum {
QDR_ROLE_NORMAL,
QDR_ROLE_INTER_ROUTER,
QDR_ROLE_ROUTE_CONTAINER,
- QDR_ROLE_ON_DEMAND
+ QDR_ROLE_EDGE_UPLINK
} qdr_connection_role_t;
typedef void (*qdr_connection_bind_context_t) (qdr_connection_t *context, void* token);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json
index fa29d94..0511343 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -382,10 +382,11 @@
"mode": {
"type": [
"standalone",
- "interior"
+ "interior",
+ "edge"
],
"default": "standalone",
- "description": "In standalone mode, the router operates as a single component. It does not participate in the routing protocol and therefore will not cooperate with other routers. In interior mode, the router operates in cooperation with other interior routers in an interconnected network.",
+ "description": "In standalone mode, the router operates as a single component. It does not participate in the routing protocol and therefore will not cooperate with other routers. In interior mode, the router operates in cooperation with other interior routers in an interconnected network. In edge mode, the router can make an uplink to an interior router and join a network without causing that network to recompute paths.",
"create": true
},
"area": {
@@ -703,10 +704,11 @@
"type": [
"normal",
"inter-router",
- "route-container"
+ "route-container",
+ "edge-uplink"
],
"default": "normal",
- "description": "The role of an established connection. In the normal role, the connection is assumed to be used for AMQP clients that are doing normal message delivery over the connection. In the inter-router role, the connection is assumed to be to another router in the network. Inter-router discovery and routing protocols can only be used over inter-router connections. route-container role can be used for router-container connections, for example, a router-broker connection.",
+ "description": "The role of an established connection. In the normal role, the connection is assumed to be used for AMQP clients that are doing normal message delivery over the connection. In the inter-router role, the connection is assumed to be to another router in the network. Inter-router discovery and routing protocols can only be used over inter-router connections. route-container role can be used for router-container connections, for example, a router-broker connection. In the edge-uplink role, the connection is assumed to be between an edge router and an interior router.",
"create": true
},
"cost": {
@@ -867,10 +869,11 @@
"type": [
"normal",
"inter-router",
- "route-container"
+ "route-container",
+ "edge-uplink"
],
"default": "normal",
- "description": "The role of an established connection. In the normal role, the connection is assumed to be used for AMQP clients that are doing normal message delivery over the connection. In the inter-router role, the connection is assumed to be to another router in the network. Inter-router discovery and routing protocols can only be used over inter-router connections. route-container role can be used for router-container connections, for example, a router-broker connection.",
+ "description": "The role of an established connection. In the normal role, the connection is assumed to be used for AMQP clients that are doing normal message delivery over the connection. In the inter-router role, the connection is assumed to be to another router in the network. Inter-router discovery and routing protocols can only be used over inter-router connections. route-container role can be used for router-container connections, for example, a router-broker connection. In the edge-uplink role, the connection is assumed to be between and edge router and an interior router.",
"create": true
},
"cost": {
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/python/qpid_dispatch_internal/router/engine.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/router/engine.py b/python/qpid_dispatch_internal/router/engine.py
index 31fad2c..13d7a78 100644
--- a/python/qpid_dispatch_internal/router/engine.py
+++ b/python/qpid_dispatch_internal/router/engine.py
@@ -102,7 +102,7 @@ class RouterEngine(object):
"""
"""
try:
- if addr[0] in 'MCDEF':
+ if addr[0] in 'MCDEFH':
self.mobile_address_engine.add_local_address(addr)
except Exception:
self.log_ma(LOG_ERROR, "Exception in new-address processing\n%s" % format_exc(LOG_STACK_LIMIT))
@@ -111,7 +111,7 @@ class RouterEngine(object):
"""
"""
try:
- if addr[0] in 'MCDEF':
+ if addr[0] in 'MCDEFH':
self.mobile_address_engine.del_local_address(addr)
except Exception:
self.log_ma(LOG_ERROR, "Exception in del-address processing\n%s" % format_exc(LOG_STACK_LIMIT))
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/iterator.c
----------------------------------------------------------------------
diff --git a/src/iterator.c b/src/iterator.c
index 8923643..8889b17 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -80,6 +80,7 @@ typedef enum {
} state_t;
+static bool edge_mode = false;
static char *my_area = "";
static char *my_router = "";
@@ -87,6 +88,18 @@ static const char *SEPARATORS = "./";
static const uint32_t HASH_INIT = 5381;
+static void set_to_uplink(qd_iterator_t *iter)
+{
+ static const char *UPLINK = "_uplink";
+ iter->prefix = QD_ITER_HASH_PREFIX_LOCAL;
+ iter->state = STATE_AT_PREFIX;
+ iter->view_start_pointer.buffer = 0;
+ iter->view_start_pointer.cursor = (unsigned char*) UPLINK;
+ iter->view_start_pointer.remaining = (int) strlen(UPLINK);
+ iter->view_pointer = iter->view_start_pointer;
+}
+
+
static void parse_address_view(qd_iterator_t *iter)
{
//
@@ -107,7 +120,7 @@ static void parse_address_view(qd_iterator_t *iter)
}
if (qd_iterator_prefix(iter, "local/")) {
- iter->prefix = 'L';
+ iter->prefix = QD_ITER_HASH_PREFIX_LOCAL;
iter->state = STATE_AT_PREFIX;
return;
}
@@ -115,32 +128,58 @@ static void parse_address_view(qd_iterator_t *iter)
if (qd_iterator_prefix(iter, "topo/")) {
if (qd_iterator_prefix(iter, "all/") || qd_iterator_prefix(iter, my_area)) {
if (qd_iterator_prefix(iter, "all/")) {
- iter->prefix = 'T';
+ iter->prefix = QD_ITER_HASH_PREFIX_TOPOLOGICAL;
iter->state = STATE_AT_PREFIX;
return;
} else if (qd_iterator_prefix(iter, my_router)) {
- iter->prefix = 'L';
+ iter->prefix = QD_ITER_HASH_PREFIX_LOCAL;
iter->state = STATE_AT_PREFIX;
return;
}
- iter->prefix = 'R';
+ if (edge_mode)
+ set_to_uplink(iter);
+ else {
+ iter->prefix = QD_ITER_HASH_PREFIX_ROUTER;
+ iter->state = STATE_AT_PREFIX;
+ iter->mode = MODE_TO_SLASH;
+ }
+ return;
+ }
+
+ if (edge_mode)
+ set_to_uplink(iter);
+ else {
+ iter->prefix = QD_ITER_HASH_PREFIX_AREA;
iter->state = STATE_AT_PREFIX;
iter->mode = MODE_TO_SLASH;
+ }
+ return;
+ }
+
+ if (qd_iterator_prefix(iter, "edge/")) {
+ if (qd_iterator_prefix(iter, my_router)) {
+ iter->prefix = QD_ITER_HASH_PREFIX_LOCAL;
+ iter->state = STATE_AT_PREFIX;
return;
}
- iter->prefix = 'A';
- iter->state = STATE_AT_PREFIX;
- iter->mode = MODE_TO_SLASH;
- return;
+ if (edge_mode) {
+ set_to_uplink(iter);
+ return;
+ } else {
+ iter->prefix = QD_ITER_HASH_PREFIX_EDGE_SUMMARY;
+ iter->state = STATE_AT_PREFIX;
+ iter->mode = MODE_TO_SLASH;
+ return;
+ }
}
}
- iter->prefix = iter->prefix_override ? iter->prefix_override : 'M';
+ iter->prefix = iter->prefix_override ? iter->prefix_override : QD_ITER_HASH_PREFIX_MOBILE;
iter->state = STATE_AT_PREFIX;
iter->view_space = true;
- iter->annotation_length = iter->space_length + (iter->prefix == 'M' ? 2 : 1);
+ iter->annotation_length = iter->space_length + (iter->prefix == QD_ITER_HASH_PREFIX_MOBILE ? 2 : 1);
}
@@ -150,7 +189,7 @@ static void adjust_address_with_space(qd_iterator_t *iter)
// Convert an ADDRESS_HASH view to an ADDRESS_WITH_SPACE view
//
if (iter->view_space) {
- iter->annotation_length -= iter->prefix == 'M' ? 2 : 1;
+ iter->annotation_length -= iter->prefix == QD_ITER_HASH_PREFIX_MOBILE ? 2 : 1;
iter->state = iter->space ? STATE_IN_SPACE : STATE_IN_BODY;
} else {
iter->annotation_length = 0;
@@ -170,13 +209,13 @@ static void parse_node_view(qd_iterator_t *iter)
iter->annotation_length = 1;
if (qd_iterator_prefix(iter, my_area)) {
- iter->prefix = 'R';
+ iter->prefix = QD_ITER_HASH_PREFIX_ROUTER;
iter->state = STATE_AT_PREFIX;
iter->mode = MODE_TO_END;
return;
}
- iter->prefix = 'A';
+ iter->prefix = QD_ITER_HASH_PREFIX_AREA;
iter->state = STATE_AT_PREFIX;
iter->mode = MODE_TO_SLASH;
}
@@ -348,21 +387,21 @@ static void qd_iterator_free_hash_segments(qd_iterator_t *iter)
}
-void qd_iterator_set_address(const char *area, const char *router)
+void qd_iterator_set_address(bool _edge_mode, const char *area, const char *router)
{
- static char buf[2048]; /* Static buffer, should usually be Big Enough */
- static char *ptr = buf;
-#define FMT "%s/%c%s/", area, '\0', router /* "area/\0router/\0" */
- size_t size = snprintf(buf, sizeof(buf), FMT);
- if (size < sizeof(buf)) {
- ptr = buf;
- } else {
- if (ptr && ptr != buf) free(ptr);
- ptr = malloc(size + 1);
- snprintf(buf, sizeof(buf), FMT);
- }
- my_area = ptr;
- my_router = ptr + strlen(my_area) + 1;
+ static char buf[64];
+ static char *ptr = buf;
+ size_t area_size = strlen(area);
+ size_t router_size = strlen(router);
+
+ if (area_size + router_size + 1 >= sizeof(buf))
+ ptr = (char*) malloc(area_size + router_size + 2);
+
+ sprintf(ptr, "%s/%c%s/", area, '\0', router);
+
+ edge_mode = _edge_mode;
+ my_area = ptr;
+ my_router = ptr + area_size + 2;
}
@@ -504,7 +543,7 @@ void qd_iterator_annotate_space(qd_iterator_t *iter, const char* space, int spac
iter->space = space;
iter->space_length = space_length;
if (iter->view == ITER_VIEW_ADDRESS_HASH)
- iter->annotation_length = (iter->view_space ? space_length : 0) + (iter->prefix == 'M' ? 2 : 1);
+ iter->annotation_length = (iter->view_space ? space_length : 0) + (iter->prefix == QD_ITER_HASH_PREFIX_MOBILE ? 2 : 1);
else if (iter->view == ITER_VIEW_ADDRESS_WITH_SPACE) {
if (iter->view_space)
iter->annotation_length = space_length;
@@ -519,7 +558,7 @@ unsigned char qd_iterator_octet(qd_iterator_t *iter)
return 0;
if (iter->state == STATE_AT_PREFIX) {
- iter->state = iter->prefix == 'M' ? STATE_AT_PHASE : (iter->view_space && iter->space) ? STATE_IN_SPACE : STATE_IN_BODY;
+ iter->state = iter->prefix == QD_ITER_HASH_PREFIX_MOBILE ? STATE_AT_PHASE : (iter->view_space && iter->space) ? STATE_IN_SPACE : STATE_IN_BODY;
iter->space_cursor = 0;
iter->annotation_remaining--;
return iter->prefix;
@@ -614,7 +653,8 @@ bool qd_iterator_equal(qd_iterator_t *iter, const unsigned char *string)
qd_iterator_reset(iter);
while (!qd_iterator_end(iter) && *string) {
- if (*string != qd_iterator_octet(iter))
+ unsigned char octet = qd_iterator_octet(iter);
+ if (*string != octet)
break;
string++;
}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/python_embedded.c
----------------------------------------------------------------------
diff --git a/src/python_embedded.c b/src/python_embedded.c
index af88f1d..e4b4073 100644
--- a/src/python_embedded.c
+++ b/src/python_embedded.c
@@ -537,7 +537,7 @@ static void qd_io_rx_handler(void *context, qd_message_t *msg, int link_id, int
iter_to_py_attr(qd_message_field_iterator(msg, QD_FIELD_APPLICATION_PROPERTIES), py_iter_parse, py_msg, "properties");
iter_to_py_attr(qd_message_field_iterator(msg, QD_FIELD_BODY), py_iter_parse, py_msg, "body");
- PyObject *value = PyObject_CallFunction(self->handler, "Oll", py_msg, link_id, inter_router_cost);
+ PyObject *value = PyObject_CallFunction(self->handler, "Oil", py_msg, link_id, inter_router_cost);
Py_DECREF(py_msg);
Py_XDECREF(value);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/router_core/agent_connection.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_connection.c b/src/router_core/agent_connection.c
index 32da4c6..6c19345 100644
--- a/src/router_core/agent_connection.c
+++ b/src/router_core/agent_connection.c
@@ -48,6 +48,7 @@ const char *qdr_connection_roles[] =
{"normal",
"inter-router",
"route-container",
+ "edge-uplink",
0};
const char *qdr_connection_columns[] =
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index eafe413..482f600 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -603,7 +603,10 @@ static void qdr_generate_temp_addr(qdr_core_t *core, char *buffer, size_t length
{
char discriminator[QDR_DISCRIMINATOR_SIZE];
qdr_generate_discriminator(discriminator);
- snprintf(buffer, length, "amqp:/_topo/%s/%s/temp.%s", core->router_area, core->router_id, discriminator);
+ if (core->router_mode == QD_ROUTER_MODE_EDGE)
+ snprintf(buffer, length, "amqp:/_edge/%s/temp.%s", core->router_id, discriminator);
+ else
+ snprintf(buffer, length, "amqp:/_topo/%s/%s/temp.%s", core->router_area, core->router_id, discriminator);
}
@@ -1011,7 +1014,7 @@ qd_address_treatment_t qdr_treatment_for_address_hash_CT(qdr_core_t *core, qd_it
//
trt = QD_TREATMENT_LINK_BALANCED;
- else if (copy[0] == 'M') {
+ else if (copy[0] == QD_ITER_HASH_PREFIX_MOBILE) {
//
// Handle the mobile address case
//
@@ -1047,7 +1050,7 @@ void qdr_check_addr_CT(qdr_core_t *core, qdr_address_t *addr, bool was_local)
//
if (was_local && DEQ_SIZE(addr->rlinks) == 0) {
const char *key = (const char*) qd_hash_key_by_handle(addr->hash_handle);
- if (key && *key == 'M')
+ if (key && (*key == QD_ITER_HASH_PREFIX_MOBILE || *key == QD_ITER_HASH_PREFIX_EDGE_SUMMARY))
qdr_post_mobile_removed_CT(core, key);
}
@@ -1253,7 +1256,7 @@ static void qdr_connection_opened_CT(qdr_core_t *core, qdr_action_t *action, boo
if (!conn->incoming) {
//
- // The connector-side of inter-router connections is responsible for setting up the
+ // The connector-side of inter-router/edge-uplink 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, qdr_terminus_router_control(), qdr_terminus_router_control());
@@ -1361,6 +1364,7 @@ static void qdr_connection_closed_CT(qdr_core_t *core, qdr_action_t *action, boo
qdr_connection_free(conn);
}
+
static char* disambiguated_link_name(qdr_connection_info_t *conn, char *original)
{
size_t olen = strlen(original);
@@ -1373,6 +1377,92 @@ static char* disambiguated_link_name(qdr_connection_info_t *conn, char *original
return name;
}
+
+//
+// Handle the attachment and detachment of an inter-router control link
+//
+static void qdr_attach_link_control_CT(qdr_core_t *core, qdr_connection_t *conn, qdr_link_t *link)
+{
+ if (conn->role == QDR_ROLE_INTER_ROUTER) {
+ link->owning_addr = core->hello_addr;
+ qdr_add_link_ref(&core->hello_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
+ core->control_links_by_mask_bit[conn->mask_bit] = link;
+ }
+}
+
+
+static void qdr_detach_link_control_CT(qdr_core_t *core, qdr_connection_t *conn, qdr_link_t *link)
+{
+ if (conn->role == QDR_ROLE_INTER_ROUTER) {
+ qdr_del_link_ref(&core->hello_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
+ core->control_links_by_mask_bit[conn->mask_bit] = 0;
+ qdr_post_link_lost_CT(core, conn->mask_bit);
+ }
+}
+
+
+//
+// Handle the attachment and detachment of an inter-router data link
+//
+static void qdr_attach_link_data_CT(qdr_core_t *core, qdr_connection_t *conn, qdr_link_t *link)
+{
+ if (conn->role == QDR_ROLE_INTER_ROUTER)
+ core->data_links_by_mask_bit[conn->mask_bit] = link;
+
+ //
+ // TODO - This needs to be refactored in terms of a non-inter-router link type
+ //
+ else if (conn->role == QDR_ROLE_EDGE_UPLINK) {
+ if (core->router_mode == QD_ROUTER_MODE_EDGE) {
+ //
+ // Associate this link with the uplink address.
+ //
+ link->owning_addr = core->uplink_addr;
+ qdr_add_link_ref(&core->uplink_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
+ qd_log(core->log, QD_LOG_INFO, "Edge-uplink established to interior router: %s", conn->connection_info->container);
+ } else if (core->router_mode == QD_ROUTER_MODE_INTERIOR) {
+ //
+ // This is a down-link to an edge router. Create a mobile address of the form
+ // H<edge-router-id>, associate the link to that address, and advertise
+ // the address on the network.
+ //
+ const char *edge_id = conn->connection_info->container;
+ qdr_address_t *addr = qdr_add_mobile_address_CT(core, "", edge_id, QD_TREATMENT_ANYCAST_BALANCED, true);
+ link->owning_addr = addr;
+ qdr_add_link_ref(&addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
+ if (DEQ_SIZE(addr->rlinks) == 1) {
+ const char *key = (const char*) qd_hash_key_by_handle(addr->hash_handle);
+ if (key && (*key == QD_ITER_HASH_PREFIX_MOBILE || *key == QD_ITER_HASH_PREFIX_EDGE_SUMMARY))
+ qdr_post_mobile_added_CT(core, key);
+ qdr_addr_start_inlinks_CT(core, addr);
+ }
+
+ qd_log(core->log, QD_LOG_INFO, "Downlink established to edge router: %s", edge_id);
+ }
+ }
+}
+
+
+static void qdr_detach_link_data_CT(qdr_core_t *core, qdr_connection_t *conn, qdr_link_t *link)
+{
+ if (conn->role == QDR_ROLE_INTER_ROUTER)
+ core->data_links_by_mask_bit[conn->mask_bit] = 0;
+
+ //
+ // TODO - This needs to be refactored in terms of a non-inter-router link type
+ //
+ else if (conn->role == QDR_ROLE_EDGE_UPLINK) {
+ if (core->router_mode == QD_ROUTER_MODE_EDGE) {
+ qdr_del_link_ref(&core->uplink_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
+ qd_log(core->log, QD_LOG_INFO, "Edge-uplink lost");
+ } else if (core->router_mode == QD_ROUTER_MODE_INTERIOR) {
+ qdr_del_link_ref(&link->owning_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
+ qd_log(core->log, QD_LOG_INFO, "Downlink lost to edge router: %s", conn->connection_info->container);
+ }
+ }
+}
+
+
static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
{
if (discard)
@@ -1394,8 +1484,9 @@ static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *act
//
// Reject any attaches of inter-router links that arrive on connections that are not inter-router.
//
- if (((link->link_type == QD_LINK_CONTROL || link->link_type == QD_LINK_ROUTER) && conn->role != QDR_ROLE_INTER_ROUTER)) {
- link->link_type = QD_LINK_ENDPOINT; // Demote the link type to endpoint if this is not an inter-router connection
+ if (((link->link_type == QD_LINK_CONTROL || link->link_type == QD_LINK_ROUTER) &&
+ (conn->role != QDR_ROLE_INTER_ROUTER && conn->role != QDR_ROLE_EDGE_UPLINK))) {
+ link->link_type = QD_LINK_ENDPOINT; // Demote the link type to endpoint if this is not an inter-router/edge-uplink connection
qdr_link_outbound_detach_CT(core, link, 0, QDR_CONDITION_FORBIDDEN, true);
qdr_terminus_free(source);
qdr_terminus_free(target);
@@ -1407,6 +1498,8 @@ static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *act
// CONTROL link on the connection. This will prevent endpoints from using inter-router
// listeners for normal traffic but will not prevent routed-links from being established.
//
+ // EDGE_TODO: Prevent endpoint links on edge-uplink connections
+ //
if (conn->role == QDR_ROLE_INTER_ROUTER && link->link_type == QD_LINK_ENDPOINT &&
core->control_links_by_mask_bit[conn->mask_bit] == 0) {
qdr_link_outbound_detach_CT(core, link, 0, QDR_CONDITION_WRONG_ROLE, true);
@@ -1572,7 +1665,7 @@ static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *act
qdr_add_link_ref(&addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
if (DEQ_SIZE(addr->rlinks) == 1) {
const char *key = (const char*) qd_hash_key_by_handle(addr->hash_handle);
- if (key && *key == 'M')
+ if (key && *key == QD_ITER_HASH_PREFIX_MOBILE)
qdr_post_mobile_added_CT(core, key);
qdr_addr_start_inlinks_CT(core, addr);
}
@@ -1582,14 +1675,12 @@ static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *act
}
case QD_LINK_CONTROL:
- link->owning_addr = core->hello_addr;
- qdr_add_link_ref(&core->hello_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
- core->control_links_by_mask_bit[conn->mask_bit] = link;
+ qdr_attach_link_control_CT(core, conn, link);
qdr_link_outbound_second_attach_CT(core, link, source, target);
break;
case QD_LINK_ROUTER:
- core->data_links_by_mask_bit[conn->mask_bit] = link;
+ qdr_attach_link_data_CT(core, conn, link);
qdr_link_outbound_second_attach_CT(core, link, source, target);
break;
}
@@ -1673,7 +1764,7 @@ static void qdr_link_inbound_second_attach_CT(qdr_core_t *core, qdr_action_t *ac
link->owning_addr = link->auto_link->addr;
if (DEQ_SIZE(link->auto_link->addr->rlinks) == 1) {
const char *key = (const char*) qd_hash_key_by_handle(link->auto_link->addr->hash_handle);
- if (key && *key == 'M')
+ if (key && *key == QD_ITER_HASH_PREFIX_MOBILE)
qdr_post_mobile_added_CT(core, key);
qdr_addr_start_inlinks_CT(core, link->auto_link->addr);
}
@@ -1682,13 +1773,11 @@ static void qdr_link_inbound_second_attach_CT(qdr_core_t *core, qdr_action_t *ac
break;
case QD_LINK_CONTROL:
- link->owning_addr = core->hello_addr;
- qdr_add_link_ref(&core->hello_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
- core->control_links_by_mask_bit[conn->mask_bit] = link;
+ qdr_attach_link_control_CT(core, conn, link);
break;
case QD_LINK_ROUTER:
- core->data_links_by_mask_bit[conn->mask_bit] = link;
+ qdr_attach_link_data_CT(core, conn, link);
break;
}
}
@@ -1755,8 +1844,6 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
link->auto_link->last_error = qdr_error_description(error);
}
- link->owning_addr = 0;
-
if (link->link_direction == QD_INCOMING) {
//
// Handle incoming link cases
@@ -1795,20 +1882,17 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
break;
case QD_LINK_CONTROL:
- if (conn->role == QDR_ROLE_INTER_ROUTER) {
- qdr_del_link_ref(&core->hello_addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
- core->control_links_by_mask_bit[conn->mask_bit] = 0;
- qdr_post_link_lost_CT(core, conn->mask_bit);
- }
+ qdr_detach_link_control_CT(core, conn, link);
break;
case QD_LINK_ROUTER:
- if (conn->role == QDR_ROLE_INTER_ROUTER)
- core->data_links_by_mask_bit[conn->mask_bit] = 0;
+ qdr_detach_link_data_CT(core, conn, link);
break;
}
}
+ link->owning_addr = 0;
+
if (link->detach_count == 1) {
//
// Handle the disposition of any deliveries that remain on the link
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/router_core/route_control.c
----------------------------------------------------------------------
diff --git a/src/router_core/route_control.c b/src/router_core/route_control.c
index 4de2ba3..9c08d91 100644
--- a/src/router_core/route_control.c
+++ b/src/router_core/route_control.c
@@ -27,6 +27,10 @@ ALLOC_DEFINE(qdr_link_route_t);
ALLOC_DEFINE(qdr_auto_link_t);
ALLOC_DEFINE(qdr_conn_identifier_t);
+//
+// Note that these hash prefixes are in a different space than those listed in iterator.h.
+// These are used in a different hash table than the address hash.
+//
const char CONTAINER_PREFIX = 'C';
const char CONNECTION_PREFIX = 'L';
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/router_core/route_tables.c
----------------------------------------------------------------------
diff --git a/src/router_core/route_tables.c b/src/router_core/route_tables.c
index 2f7dd54..3072496 100644
--- a/src/router_core/route_tables.c
+++ b/src/router_core/route_tables.c
@@ -249,6 +249,10 @@ void qdr_route_table_setup_CT(qdr_core_t *core)
core->data_links_by_mask_bit[idx] = 0;
}
}
+
+ if (core->router_mode == QD_ROUTER_MODE_EDGE) {
+ core->uplink_addr = qdr_add_local_address_CT(core, 'L', "_uplink", QD_TREATMENT_ANYCAST_CLOSEST);
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/router_core/router_core.c
----------------------------------------------------------------------
diff --git a/src/router_core/router_core.c b/src/router_core/router_core.c
index 116839a..ef9e382 100644
--- a/src/router_core/router_core.c
+++ b/src/router_core/router_core.c
@@ -324,6 +324,40 @@ qdr_address_t *qdr_add_local_address_CT(qdr_core_t *core, char aclass, const cha
return addr;
}
+
+qdr_address_t *qdr_add_mobile_address_CT(qdr_core_t *core, const char *prefix, const char *address, qd_address_treatment_t treatment, bool edge)
+{
+ char addr_string_stack[1000];
+ char *addr_string = addr_string_stack;
+ bool allocated = false;
+ qdr_address_t *addr = 0;
+ qd_iterator_t *iter = 0;
+
+ size_t len = strlen(prefix) + strlen(address) + 3;
+ if (len > sizeof(addr_string_stack)) {
+ allocated = true;
+ addr_string = (char*) malloc(len);
+ }
+
+ snprintf(addr_string, len, "%s%s%s", edge ? "H" : "M0", prefix, address);
+ iter = qd_iterator_string(addr_string, ITER_VIEW_ALL);
+
+ qd_hash_retrieve(core->addr_hash, iter, (void**) &addr);
+ if (!addr) {
+ addr = qdr_address_CT(core, treatment);
+ if (addr) {
+ qd_hash_insert(core->addr_hash, iter, addr, &addr->hash_handle);
+ DEQ_INSERT_TAIL(core->addrs, addr);
+ }
+ }
+
+ qd_iterator_free(iter);
+ if (allocated)
+ free(addr_string);
+ return addr;
+}
+
+
bool qdr_is_addr_treatment_multicast(qdr_address_t *addr)
{
if (addr) {
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/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 2ebe38c..28f6b76 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -503,6 +503,7 @@ DEQ_DECLARE(qdr_address_t, qdr_address_list_t);
qdr_address_t *qdr_address_CT(qdr_core_t *core, qd_address_treatment_t treatment);
qdr_address_t *qdr_add_local_address_CT(qdr_core_t *core, char aclass, const char *addr, qd_address_treatment_t treatment);
+qdr_address_t *qdr_add_mobile_address_CT(qdr_core_t *core, const char* prefix, const char *addr, qd_address_treatment_t treatment, bool edge);
void qdr_core_remove_address(qdr_core_t *core, qdr_address_t *addr);
struct qdr_address_config_t {
@@ -574,18 +575,13 @@ struct qdr_connection_t {
ALLOC_DECLARE(qdr_connection_t);
DEQ_DECLARE(qdr_connection_t, qdr_connection_list_t);
-// Address hash prefixes for link routes:
-// 'C' old style prefix address, incoming
-// 'D' old style prefix address, outgoing
-// 'E' link route pattern address, incoming
-// 'F' link route pattern address, outgoing
-#define QDR_IS_LINK_ROUTE_PREFIX(p) ((p) == 'C' || (p) == 'D')
-#define QDR_IS_LINK_ROUTE(p) ((p) == 'E' || (p) == 'F' || QDR_IS_LINK_ROUTE_PREFIX(p))
-#define QDR_LINK_ROUTE_DIR(p) (((p) == 'C' || (p) == 'E') ? QD_INCOMING : QD_OUTGOING)
+#define QDR_IS_LINK_ROUTE_PREFIX(p) ((p) == QD_ITER_HASH_PREFIX_LINKROUTE_ADDR_IN || (p) == QD_ITER_HASH_PREFIX_LINKROUTE_ADDR_OUT)
+#define QDR_IS_LINK_ROUTE(p) ((p) == QD_ITER_HASH_PREFIX_LINKROUTE_PATTERN_IN || (p) == QD_ITER_HASH_PREFIX_LINKROUTE_PATTERN_OUT || QDR_IS_LINK_ROUTE_PREFIX(p))
+#define QDR_LINK_ROUTE_DIR(p) (((p) == QD_ITER_HASH_PREFIX_LINKROUTE_ADDR_IN || (p) == QD_ITER_HASH_PREFIX_LINKROUTE_PATTERN_IN) ? QD_INCOMING : QD_OUTGOING)
#define QDR_LINK_ROUTE_HASH(dir, is_prefix) \
(((dir) == QD_INCOMING) \
- ? ((is_prefix) ? 'C' : 'E') \
- : ((is_prefix) ? 'D' : 'F'))
+ ? ((is_prefix) ? QD_ITER_HASH_PREFIX_LINKROUTE_ADDR_IN : QD_ITER_HASH_PREFIX_LINKROUTE_PATTERN_IN) \
+ : ((is_prefix) ? QD_ITER_HASH_PREFIX_LINKROUTE_ADDR_OUT : QD_ITER_HASH_PREFIX_LINKROUTE_PATTERN_OUT))
struct qdr_link_route_t {
DEQ_LINKS(qdr_link_route_t);
@@ -731,6 +727,7 @@ struct qdr_core_t {
qdr_address_t *routerma_addr_L;
qdr_address_t *router_addr_T;
qdr_address_t *routerma_addr_T;
+ qdr_address_t *uplink_addr;
qdr_node_list_t routers; ///< List of routers, in order of cost, from lowest to highest
qd_bitmask_t *neighbor_free_mask;
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/src/router_node.c
----------------------------------------------------------------------
diff --git a/src/router_node.c b/src/router_node.c
index 5bbab94..5f5efc6 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -37,6 +37,7 @@ const char *QD_ROUTER_LINK_TYPE = "router.link";
static char *router_role = "inter-router";
static char *container_role = "route-container";
+static char *edge_role = "edge-uplink";
static char *direct_prefix;
static char *node_id;
@@ -138,11 +139,16 @@ static void qd_router_connection_get_config(const qd_connection_t *conn,
*strip_annotations_out = cf ? cf->strip_outbound_annotations : false;
*link_capacity = cf ? cf->link_capacity : 1;
- if (cf && strcmp(cf->role, router_role) == 0) {
+ if (cf && (strcmp(cf->role, router_role) == 0)) {
*strip_annotations_in = false;
*strip_annotations_out = false;
*role = QDR_ROLE_INTER_ROUTER;
*cost = cf->inter_router_cost;
+ } else if (cf && (strcmp(cf->role, edge_role) == 0)) {
+ *strip_annotations_in = false;
+ *strip_annotations_out = false;
+ *role = QDR_ROLE_EDGE_UPLINK;
+ *cost = cf->inter_router_cost;
} else if (cf && (strcmp(cf->role, container_role) == 0)) // backward compat
*role = QDR_ROLE_ROUTE_CONTAINER;
else
@@ -177,55 +183,60 @@ static qd_iterator_t *router_annotate_message(qd_router_t *router,
int *ingress_index)
{
qd_iterator_t *ingress_iter = 0;
+ bool edge_mode = router->router_mode == QD_ROUTER_MODE_EDGE;
+
+ *link_exclusions = 0;
+ *distance = 0;
qd_parsed_field_t *trace = qd_message_get_trace(msg);
qd_parsed_field_t *ingress = qd_message_get_ingress(msg);
qd_parsed_field_t *to = qd_message_get_to_override(msg);
qd_parsed_field_t *phase = qd_message_get_phase(msg);
- *link_exclusions = 0;
- *distance = 0;
-
//
// QD_MA_TRACE:
// If there is a trace field, append this router's ID to the trace.
// If the router ID is already in the trace the msg has looped.
// This code does not check for the loop condition.
//
- qd_composed_field_t *trace_field = qd_compose_subfield(0);
- qd_compose_start_list(trace_field);
- if (trace) {
- if (qd_parse_is_list(trace)) {
- //
- // Return the distance in hops that this delivery has traveled.
- //
- *distance = qd_parse_sub_count(trace);
+ // Edge routers do not add their IDs to the trace list.
+ //
+ if (!edge_mode) {
+ qd_composed_field_t *trace_field = qd_compose_subfield(0);
+ qd_compose_start_list(trace_field);
+ if (trace) {
+ if (qd_parse_is_list(trace)) {
+ //
+ // Return the distance in hops that this delivery has traveled.
+ //
+ *distance = qd_parse_sub_count(trace);
- //
- // Create a link-exclusion map for the items in the trace. This map will
- // contain a one-bit for each link that leads to a neighbor router that
- // the message has already passed through.
- //
- *link_exclusions = qd_tracemask_create(router->tracemask, trace, ingress_index);
+ //
+ // Create a link-exclusion map for the items in the trace. This map will
+ // contain a one-bit for each link that leads to a neighbor router that
+ // the message has already passed through.
+ //
+ *link_exclusions = qd_tracemask_create(router->tracemask, trace, ingress_index);
- //
- // Append this router's ID to the trace.
- //
- uint32_t idx = 0;
- qd_parsed_field_t *trace_item = qd_parse_sub_value(trace, idx);
- while (trace_item) {
- qd_iterator_t *iter = qd_parse_raw(trace_item);
- qd_iterator_reset_view(iter, ITER_VIEW_ALL);
- qd_compose_insert_string_iterator(trace_field, iter);
- idx++;
- trace_item = qd_parse_sub_value(trace, idx);
+ //
+ // Append this router's ID to the trace.
+ //
+ uint32_t idx = 0;
+ qd_parsed_field_t *trace_item = qd_parse_sub_value(trace, idx);
+ while (trace_item) {
+ qd_iterator_t *iter = qd_parse_raw(trace_item);
+ qd_iterator_reset_view(iter, ITER_VIEW_ALL);
+ qd_compose_insert_string_iterator(trace_field, iter);
+ idx++;
+ trace_item = qd_parse_sub_value(trace, idx);
+ }
}
}
- }
- qd_compose_insert_string(trace_field, node_id);
- qd_compose_end_list(trace_field);
- qd_message_set_trace_annotation(msg, trace_field);
+ qd_compose_insert_string(trace_field, node_id);
+ qd_compose_end_list(trace_field);
+ qd_message_set_trace_annotation(msg, trace_field);
+ }
//
// QD_MA_TO:
@@ -250,13 +261,17 @@ static qd_iterator_t *router_annotate_message(qd_router_t *router,
// If there is no ingress field, annotate the ingress as
// this router else keep the original field.
//
- qd_composed_field_t *ingress_field = qd_compose_subfield(0);
- if (ingress && qd_parse_is_scalar(ingress)) {
- ingress_iter = qd_parse_raw(ingress);
- qd_compose_insert_string_iterator(ingress_field, ingress_iter);
- } else
- qd_compose_insert_string(ingress_field, node_id);
- qd_message_set_ingress_annotation(msg, ingress_field);
+ // Edge routers do not annotate the ingress field.
+ //
+ if (!edge_mode) {
+ qd_composed_field_t *ingress_field = qd_compose_subfield(0);
+ if (ingress && qd_parse_is_scalar(ingress)) {
+ ingress_iter = qd_parse_raw(ingress);
+ qd_compose_insert_string_iterator(ingress_field, ingress_iter);
+ } else
+ qd_compose_insert_string(ingress_field, node_id);
+ qd_message_set_ingress_annotation(msg, ingress_field);
+ }
//
// Return the iterator to the ingress field _if_ it was present.
@@ -913,7 +928,7 @@ static void AMQP_opened_handler(qd_router_t *router, qd_connection_t *conn, bool
pn_data_t *props = pn_conn ? pn_connection_remote_properties(pn_conn) : 0;
- if (role == QDR_ROLE_INTER_ROUTER) {
+ if (role == QDR_ROLE_INTER_ROUTER || role == QDR_ROLE_EDGE_UPLINK) {
//
// Check the remote properties for an inter-router cost value.
//
@@ -1233,10 +1248,10 @@ qd_router_t *qd_router(qd_dispatch_t *qd, qd_router_mode_t mode, const char *are
router->timer = qd_timer(qd, qd_router_timer_handler, (void*) router);
//
- // Inform the field iterator module of this router's id and area. The field iterator
+ // Inform the field iterator module of this router's mode, id, and area. The field iterator
// uses this to offload some of the address-processing load from the router.
//
- qd_iterator_set_address(area, id);
+ qd_iterator_set_address(mode == QD_ROUTER_MODE_EDGE, area, id);
//
// Seed the random number generator
@@ -1252,6 +1267,9 @@ qd_router_t *qd_router(qd_dispatch_t *qd, qd_router_mode_t mode, const char *are
case QD_ROUTER_MODE_ENDPOINT: qd_log(router->log_source, QD_LOG_INFO, "Router started in Endpoint mode"); break;
}
+ if (router->router_mode == QD_ROUTER_MODE_EDGE)
+ qd_log(router->log_source, QD_LOG_WARNING, "Edge mode is not fully implemented");
+
qd_log(router->log_source, QD_LOG_INFO, "Version: %s", QPID_DISPATCH_VERSION);
return router;
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4185aa5..4c2cf11 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -117,6 +117,7 @@ foreach(py_test_module
system_tests_cmdline_parsing
system_tests_bad_configuration
system_tests_ssl
+ system_tests_edge_router
${SYSTEM_TESTS_HTTP}
${CONSOLE_TEST}
)
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tests/config-2-edge/EDGE25.conf
----------------------------------------------------------------------
diff --git a/tests/config-2-edge/EDGE25.conf b/tests/config-2-edge/EDGE25.conf
new file mode 100644
index 0000000..283c0a0
--- /dev/null
+++ b/tests/config-2-edge/EDGE25.conf
@@ -0,0 +1,39 @@
+##
+## 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
+##
+
+# See the qdrouterd.conf (5) manual page for information about this
+# file's format and options.
+
+router {
+ mode: edge
+ id: E.25
+}
+
+listener {
+ host: 0.0.0.0
+ port: 20025
+ authenticatePeer: no
+ saslMechanisms: ANONYMOUS
+}
+
+connector {
+ host: 127.0.0.1
+ port: 15001
+ role: edge-uplink
+}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tests/config-2-edge/INTA.conf
----------------------------------------------------------------------
diff --git a/tests/config-2-edge/INTA.conf b/tests/config-2-edge/INTA.conf
new file mode 100644
index 0000000..6f44f73
--- /dev/null
+++ b/tests/config-2-edge/INTA.conf
@@ -0,0 +1,49 @@
+##
+## 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
+##
+
+# See the qdrouterd.conf (5) manual page for information about this
+# file's format and options.
+
+router {
+ mode: interior
+ id: INT.A
+}
+
+listener {
+ host: 0.0.0.0
+ port: amqp
+ authenticatePeer: no
+ saslMechanisms: ANONYMOUS
+}
+
+listener {
+ host: 0.0.0.0
+ port: 10001
+ role: inter-router
+ authenticatePeer: no
+ saslMechanisms: ANONYMOUS
+}
+
+listener {
+ host: 0.0.0.0
+ port: 15001
+ role: edge-uplink
+ authenticatePeer: no
+ saslMechanisms: ANONYMOUS
+}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tests/config-2-edge/INTB.conf
----------------------------------------------------------------------
diff --git a/tests/config-2-edge/INTB.conf b/tests/config-2-edge/INTB.conf
new file mode 100644
index 0000000..a8525dd
--- /dev/null
+++ b/tests/config-2-edge/INTB.conf
@@ -0,0 +1,48 @@
+##
+## 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
+##
+
+# See the qdrouterd.conf (5) manual page for information about this
+# file's format and options.
+
+router {
+ mode: interior
+ id: INT.B
+}
+
+listener {
+ host: 0.0.0.0
+ port: 20002
+ authenticatePeer: no
+ saslMechanisms: ANONYMOUS
+}
+
+connector {
+ host: 127.0.0.1
+ port: 10001
+ role: inter-router
+}
+
+listener {
+ host: 0.0.0.0
+ port: 15002
+ role: edge-uplink
+ authenticatePeer: no
+ saslMechanisms: ANONYMOUS
+}
+
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tests/field_test.c
----------------------------------------------------------------------
diff --git a/tests/field_test.c b/tests/field_test.c
index 425d977..490b70e 100644
--- a/tests/field_test.c
+++ b/tests/field_test.c
@@ -291,6 +291,8 @@ static char* test_view_address_hash(void *context)
{"amqp:/mobile", "M1mobile"},
{"mobile", "M1mobile"},
{"/mobile", "M1mobile"},
+ {"amqp:/_edge/router/sub", "Hrouter"},
+ {"_edge/router/sub", "Hrouter"},
// Re-run the above tests to make sure trailing dots are ignored.
{"amqp:/_local/my-addr/sub.", "Lmy-addr/sub"},
@@ -338,6 +340,60 @@ static char* test_view_address_hash(void *context)
}
+static char* test_view_address_hash_edge(void *context)
+{
+ struct {const char *addr; const char *view;} cases[] = {
+ {"amqp:/_local/my-addr/sub", "Lmy-addr/sub"},
+ {"amqp:/_local/my-addr", "Lmy-addr"},
+ {"amqp:/_topo/area/router/local/sub", "L_uplink"},
+ {"amqp:/_topo/my-area/router/local/sub", "L_uplink"},
+ {"amqp:/_topo/my-area/my-router/local/sub", "Llocal/sub"},
+ {"amqp:/_topo/area/all/local/sub", "L_uplink"},
+ {"amqp:/_topo/my-area/all/local/sub", "Tlocal/sub"},
+ {"amqp:/_topo/all/all/local/sub", "Tlocal/sub"},
+ {"amqp://host:port/_local/my-addr", "Lmy-addr"},
+ {"_topo/area/router/my-addr", "L_uplink"},
+ {"_topo/my-area/router/my-addr", "L_uplink"},
+ {"_topo/my-area/my-router/my-addr", "Lmy-addr"},
+ {"_topo/my-area/router", "L_uplink"},
+ {"amqp:/mobile", "M1mobile"},
+ {"mobile", "M1mobile"},
+ {"/mobile", "M1mobile"},
+ {"amqp:/_edge/router/sub", "L_uplink"},
+ {"_edge/router/sub", "L_uplink"},
+ {"amqp:/_edge/my-router/sub", "Lsub"},
+ {"_edge/my-router/sub", "Lsub"},
+
+ {0, 0}
+ };
+ int idx;
+
+ for (idx = 0; cases[idx].addr; idx++) {
+ qd_iterator_t *iter = qd_iterator_string(cases[idx].addr, ITER_VIEW_ADDRESS_HASH);
+ qd_iterator_annotate_phase(iter, '1');
+ char *ret = verify_iterator(context, iter, cases[idx].addr, cases[idx].view);
+ qd_iterator_free(iter);
+ if (ret) return ret;
+ }
+
+ for (idx = 0; cases[idx].addr; idx++) {
+ qd_buffer_list_t chain;
+ DEQ_INIT(chain);
+ build_buffer_chain(&chain, cases[idx].addr, 3);
+ qd_iterator_t *iter = qd_iterator_buffer(DEQ_HEAD(chain), 0,
+ strlen(cases[idx].addr),
+ ITER_VIEW_ADDRESS_HASH);
+ qd_iterator_annotate_phase(iter, '1');
+ char *ret = verify_iterator(context, iter, cases[idx].addr, cases[idx].view);
+ release_buffer_chain(&chain);
+ qd_iterator_free(iter);
+ if (ret) return ret;
+ }
+
+ return 0;
+}
+
+
static char* test_view_address_with_space(void *context)
{
struct {const char *addr; const char *view;} cases[] = {
@@ -989,7 +1045,7 @@ int field_tests(void)
int result = 0;
char *test_group = "field_tests";
- qd_iterator_set_address("my-area", "my-router");
+ qd_iterator_set_address(false, "my-area", "my-router");
TEST_CASE(test_view_global_dns, 0);
TEST_CASE(test_view_global_non_dns, 0);
@@ -1016,5 +1072,8 @@ int field_tests(void)
TEST_CASE(test_prefix_hash, 0);
TEST_CASE(test_prefix_hash_with_space, 0);
+ qd_iterator_set_address(true, "my-area", "my-router");
+ TEST_CASE(test_view_address_hash_edge, 0);
+
return result;
}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tests/parse_test.c
----------------------------------------------------------------------
diff --git a/tests/parse_test.c b/tests/parse_test.c
index 85ce936..9186796 100644
--- a/tests/parse_test.c
+++ b/tests/parse_test.c
@@ -266,7 +266,7 @@ static char *test_tracemask(void *context)
qd_buffer_list_t list;
static char error[1024];
- qd_iterator_set_address("0", "ROUTER");
+ qd_iterator_set_address(false, "0", "ROUTER");
qd_tracemask_add_router(tm, "amqp:/_topo/0/Router.A", 0);
qd_tracemask_add_router(tm, "amqp:/_topo/0/Router.B", 1);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tests/system_tests_edge_router.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_edge_router.py b/tests/system_tests_edge_router.py
new file mode 100644
index 0000000..1c11a27
--- /dev/null
+++ b/tests/system_tests_edge_router.py
@@ -0,0 +1,301 @@
+#
+# 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.
+#
+
+import unittest2 as unittest
+from proton import Message, Timeout
+from system_test import TestCase, Qdrouterd, main_module, TIMEOUT
+from proton.handlers import MessagingHandler
+from proton.reactor import Container, DynamicNodeProperties
+
+# PROTON-828:
+try:
+ from proton import MODIFIED
+except ImportError:
+ from proton import PN_STATUS_MODIFIED as MODIFIED
+
+
+class RouterTest(TestCase):
+
+ inter_router_port = None
+
+ @classmethod
+ def setUpClass(cls):
+ """Start a router"""
+ super(RouterTest, cls).setUpClass()
+
+ def router(name, mode, connection, extra=None):
+ config = [
+ ('router', {'mode': mode, 'id': name}),
+ ('listener', {'port': cls.tester.get_port(), 'stripAnnotations': 'no'}),
+ ('listener', {'port': cls.tester.get_port(), 'stripAnnotations': 'no', 'multiTenant': 'yes'}),
+ ('listener', {'port': cls.tester.get_port(), 'stripAnnotations': 'no', 'role': 'route-container'}),
+ ('linkRoute', {'prefix': '0.0.0.0/link', 'dir': 'in', 'containerId': 'LRC'}),
+ ('linkRoute', {'prefix': '0.0.0.0/link', 'dir': 'out', 'containerId': 'LRC'}),
+ ('autoLink', {'addr': '0.0.0.0/queue.waypoint', 'containerId': 'ALC', 'dir': 'in'}),
+ ('autoLink', {'addr': '0.0.0.0/queue.waypoint', 'containerId': 'ALC', 'dir': 'out'}),
+ ('address', {'prefix': 'closest', 'distribution': 'closest'}),
+ ('address', {'prefix': 'spread', 'distribution': 'balanced'}),
+ ('address', {'prefix': 'multicast', 'distribution': 'multicast'}),
+ ('address', {'prefix': '0.0.0.0/queue', 'waypoint': 'yes'}),
+ connection
+ ]
+
+ if extra:
+ config.append(extra)
+ config = Qdrouterd.Config(config)
+ cls.routers.append(cls.tester.qdrouterd(name, config, wait=True))
+
+ cls.routers = []
+
+ inter_router_port = cls.tester.get_port()
+ edge_port_A = cls.tester.get_port()
+ edge_port_B = cls.tester.get_port()
+
+ router('INT.A', 'interior', ('listener', {'role': 'inter-router', 'port': inter_router_port}),
+ ('listener', {'role': 'edge-uplink', 'port': edge_port_A}))
+ router('INT.B', 'interior', ('connector', {'name': 'connectorToA', 'role': 'inter-router', 'port': inter_router_port}),
+ ('listener', {'role': 'edge-uplink', 'port': edge_port_B}))
+ router('EA1', 'edge', ('connector', {'name': 'uplink', 'role': 'edge-uplink', 'port': edge_port_A}))
+ router('EA2', 'edge', ('connector', {'name': 'uplink', 'role': 'edge-uplink', 'port': edge_port_A}))
+ router('EB1', 'edge', ('connector', {'name': 'uplink', 'role': 'edge-uplink', 'port': edge_port_B}))
+ router('EB2', 'edge', ('connector', {'name': 'uplink', 'role': 'edge-uplink', 'port': edge_port_B}))
+
+ cls.routers[0].wait_router_connected('INT.B')
+ cls.routers[1].wait_router_connected('INT.A')
+
+
+ def test_01_connectivity_INTA_EA1(self):
+ test = ConnectivityTest(self.routers[0].addresses[0],
+ self.routers[2].addresses[0],
+ 'EA1')
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_02_connectivity_INTA_EA2(self):
+ test = ConnectivityTest(self.routers[0].addresses[0],
+ self.routers[3].addresses[0],
+ 'EA2')
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_03_connectivity_INTB_EB1(self):
+ test = ConnectivityTest(self.routers[1].addresses[0],
+ self.routers[4].addresses[0],
+ 'EB1')
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_04_connectivity_INTB_EB2(self):
+ test = ConnectivityTest(self.routers[1].addresses[0],
+ self.routers[5].addresses[0],
+ 'EB2')
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_05_dynamic_address_same_edge(self):
+ test = DynamicAddressTest(self.routers[2].addresses[0],
+ self.routers[2].addresses[0])
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_06_dynamic_address_interior_to_edge(self):
+ self.skipTest("Temporarily disabled")
+ test = DynamicAddressTest(self.routers[2].addresses[0],
+ self.routers[0].addresses[0])
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_07_dynamic_address_edge_to_interior(self):
+ self.skipTest("Temporarily disabled")
+ test = DynamicAddressTest(self.routers[0].addresses[0],
+ self.routers[2].addresses[0])
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_08_dynamic_address_edge_to_edge_one_interior(self):
+ self.skipTest("Temporarily disabled")
+ test = DynamicAddressTest(self.routers[2].addresses[0],
+ self.routers[3].addresses[0])
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_09_dynamic_address_edge_to_edge_two_interior(self):
+ self.skipTest("Temporarily disabled")
+ test = DynamicAddressTest(self.routers[2].addresses[0],
+ self.routers[4].addresses[0])
+ test.run()
+ self.assertEqual(None, test.error)
+
+
+class Entity(object):
+ def __init__(self, status_code, status_description, body):
+ self.status_code = status_code
+ self.status_description = status_description
+ if body.__class__ == dict and len(body.keys()) == 2 and 'attributeNames' in body.keys() and 'results' in body.keys():
+ results = []
+ names = body['attributeNames']
+ for result in body['results']:
+ result_map = {}
+ for i in range(len(names)):
+ result_map[names[i]] = result[i]
+ results.append(Entity(status_code, status_description, result_map))
+ self.attrs = {'results': results}
+ else:
+ self.attrs = body
+
+ def __getattr__(self, key):
+ return self.attrs[key]
+
+
+class RouterProxy(object):
+ def __init__(self, reply_addr):
+ self.reply_addr = reply_addr
+
+ def response(self, msg):
+ ap = msg.properties
+ return Entity(ap['statusCode'], ap['statusDescription'], msg.body)
+
+ def query_connections(self):
+ ap = {'operation': 'QUERY', 'type': 'org.apache.qpid.dispatch.connection'}
+ return Message(properties=ap, reply_to=self.reply_addr)
+
+ def query_links(self):
+ ap = {'operation': 'QUERY', 'type': 'org.apache.qpid.dispatch.router.link'}
+ return Message(properties=ap, reply_to=self.reply_addr)
+
+
+class Timeout(object):
+ def __init__(self, parent):
+ self.parent = parent
+
+ def on_timer_task(self, event):
+ self.parent.timeout()
+
+
+class PollTimeout(object):
+ def __init__(self, parent):
+ self.parent = parent
+
+ def on_timer_task(self, event):
+ self.parent.poll_timeout()
+
+
+class ConnectivityTest(MessagingHandler):
+ def __init__(self, interior_host, edge_host, edge_id):
+ super(ConnectivityTest, self).__init__()
+ self.interior_host = interior_host
+ self.edge_host = edge_host
+ self.edge_id = edge_id
+
+ self.interior_conn = None
+ self.edge_conn = None
+ self.error = None
+ self.proxy = None
+ self.query_sent = False
+
+ def timeout(self):
+ self.error = "Timeout Expired"
+ self.interior_conn.close()
+ self.edge_conn.close()
+
+ def on_start(self, event):
+ self.timer = event.reactor.schedule(10.0, Timeout(self))
+ self.interior_conn = event.container.connect(self.interior_host)
+ self.edge_conn = event.container.connect(self.edge_host)
+ self.reply_receiver = event.container.create_receiver(self.interior_conn, dynamic=True)
+
+ def on_link_opened(self, event):
+ if event.receiver == self.reply_receiver:
+ self.proxy = RouterProxy(self.reply_receiver.remote_source.address)
+ self.agent_sender = event.container.create_sender(self.interior_conn, "$management")
+
+ def on_sendable(self, event):
+ if not self.query_sent:
+ self.query_sent = True
+ self.agent_sender.send(self.proxy.query_connections())
+
+ def on_message(self, event):
+ if event.receiver == self.reply_receiver:
+ response = self.proxy.response(event.message)
+ if response.status_code != 200:
+ self.error = "Unexpected error code from agent: %d - %s" % (response.status_code, response.status_description)
+ connections = response.results
+ count = 0
+ for conn in connections:
+ if conn.role == 'edge-uplink' and conn.container == self.edge_id:
+ count += 1
+ if count != 1:
+ self.error = "Incorrect uplink count for container-id. Expected 1, got %d" % count
+ self.interior_conn.close()
+ self.edge_conn.close()
+ self.timer.cancel()
+
+ def run(self):
+ Container(self).run()
+
+
+class DynamicAddressTest(MessagingHandler):
+ def __init__(self, receiver_host, sender_host):
+ super(DynamicAddressTest, self).__init__()
+ self.receiver_host = receiver_host
+ self.sender_host = sender_host
+
+ self.receiver_conn = None
+ self.sender_conn = None
+ self.receiver = None
+ self.address = None
+ self.count = 10
+ self.n_rcvd = 0
+ self.n_sent = 0
+ self.error = None
+
+ def timeout(self):
+ self.error = "Timeout Expired - n_sent=%d n_rcvd=%d addr=%s" % (self.n_sent, self.n_rcvd, self.address)
+ self.receiver_conn.close()
+ self.sender_conn.close()
+
+ def on_start(self, event):
+ self.timer = event.reactor.schedule(5.0, Timeout(self))
+ self.receiver_conn = event.container.connect(self.receiver_host)
+ self.sender_conn = event.container.connect(self.sender_host)
+ self.receiver = event.container.create_receiver(self.receiver_conn, dynamic=True)
+
+ def on_link_opened(self, event):
+ if event.receiver == self.receiver:
+ self.address = self.receiver.remote_source.address
+ self.sender = event.container.create_sender(self.sender_conn, self.address)
+
+ def on_sendable(self, event):
+ while self.n_sent < self.count:
+ self.sender.send(Message(body="Message %d" % self.n_sent))
+ self.n_sent += 1
+
+ def on_message(self, event):
+ self.n_rcvd += 1
+ if self.n_rcvd == self.count:
+ self.receiver_conn.close()
+ self.sender_conn.close()
+ self.timer.cancel()
+
+ def run(self):
+ Container(self).run()
+
+
+if __name__ == '__main__':
+ unittest.main(main_module())
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b652fd40/tools/qdstat.in
----------------------------------------------------------------------
diff --git a/tools/qdstat.in b/tools/qdstat.in
index d0ed533..2086310 100755
--- a/tools/qdstat.in
+++ b/tools/qdstat.in
@@ -188,13 +188,14 @@ class BusManager(Node):
def _addr_class(self, addr):
if not addr:
return ""
- if addr[0] == 'M' : return "mobile"
- if addr[0] == 'R' : return "router"
- if addr[0] == 'A' : return "area"
- if addr[0] == 'L' : return "local"
- if addr[0] == 'T' : return "topo"
+ if addr[0] == 'M' : return "mobile"
+ if addr[0] == 'R' : return "router"
+ if addr[0] == 'A' : return "area"
+ if addr[0] == 'L' : return "local"
+ if addr[0] == 'T' : return "topo"
if addr[0] in 'CE' : return "link-in"
if addr[0] in 'DF' : return "link-out"
+ if addr[0] == 'H' : return "edge"
return "unknown: %s" % addr[0]
def _addr_text(self, addr):
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org