You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2016/03/04 19:59:17 UTC
[2/2] qpid-dispatch git commit: DISPATCH-179 - Added configuration
support for the "route" entity. Implemented link-route activation.
DISPATCH-179 - Added configuration support for the "route" entity.
Implemented link-route activation.
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/0d603e1b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/0d603e1b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/0d603e1b
Branch: refs/heads/tross-DISPATCH-179-1
Commit: 0d603e1bc67db18387d4f8491228540d106d16a5
Parents: da00ebc
Author: Ted Ross <tr...@redhat.com>
Authored: Fri Mar 4 13:58:04 2016 -0500
Committer: Ted Ross <tr...@redhat.com>
Committed: Fri Mar 4 13:58:04 2016 -0500
----------------------------------------------------------------------
python/qpid_dispatch/management/qdrouter.json | 15 ++-
python/qpid_dispatch_internal/dispatch.py | 1 +
.../qpid_dispatch_internal/management/agent.py | 4 +
.../qpid_dispatch_internal/management/config.py | 4 +-
src/dispatch.c | 6 ++
src/dispatch_private.h | 5 +
src/router_config.c | 100 +++++++++++++++++++
src/router_core/agent_address.c | 18 ++--
src/router_core/agent_address.h | 2 +-
src/router_core/agent_route.c | 2 +-
src/router_core/management_agent.c | 2 +-
src/router_core/route_control.c | 18 ++++
src/router_private.h | 1 +
tools/qdstat | 2 +
14 files changed, 164 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json
index 14a087a..58e7f75 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -835,7 +835,7 @@
}
},
- "router.route": {
+ "route": {
"description": "Provisioned route that affects the treatment of message deliveries and link attaches",
"extends": "configurationEntity",
"operations": ["CREATE", "DELETE", "ADD-CONTAINER", "REMOVE-CONTAINER-CLEAN", "REMOVE-CONTAINER-HARD"],
@@ -859,14 +859,14 @@
"default": "balanced"
},
"connectors": {
- "type": "list",
- "description": "List of labels associated with the connector leading to the target containers",
+ "type": "string",
+ "description": "Comma-separated list of labels associated with the connector leading to the target containers",
"create": true,
"required": false
},
"containers": {
- "type": "list",
- "description": "List of container-IDs for target containers",
+ "type": "string",
+ "description": "Comma-separated list of container-IDs for target containers",
"create": true,
"required": false
},
@@ -953,6 +953,11 @@
"description": "The number of remote routers that have at least one subscriber to this address",
"graph": true
},
+ "containerCount": {
+ "type": "integer",
+ "description": "The number of attached containers that serve this route address",
+ "graph": true
+ },
"deliveriesIngress": {
"type": "integer",
"description": "The number of deliveries to this address that entered the router network on this router",
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/python/qpid_dispatch_internal/dispatch.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/dispatch.py b/python/qpid_dispatch_internal/dispatch.py
index fdc6835..a1b6e8b 100644
--- a/python/qpid_dispatch_internal/dispatch.py
+++ b/python/qpid_dispatch_internal/dispatch.py
@@ -64,6 +64,7 @@ class QdDll(ctypes.PyDLL):
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_lrp, None, [self.qd_dispatch_p, py_object])
+ self._prototype(self.qd_dispatch_configure_route, 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])
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/python/qpid_dispatch_internal/management/agent.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/agent.py b/python/qpid_dispatch_internal/management/agent.py
index 886157d..c396366 100644
--- a/python/qpid_dispatch_internal/management/agent.py
+++ b/python/qpid_dispatch_internal/management/agent.py
@@ -301,6 +301,10 @@ class LinkRoutePatternEntity(EntityAdapter):
def create(self):
self._qd.qd_dispatch_configure_lrp(self._dispatch, self)
+class RouteEntity(EntityAdapter):
+ def create(self):
+ self._qd.qd_dispatch_configure_route(self._dispatch, self)
+
class ConsoleEntity(EntityAdapter):
def create(self):
# if a named listener is present, use its addr:port
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/python/qpid_dispatch_internal/management/config.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/config.py b/python/qpid_dispatch_internal/management/config.py
index 1ecae6b..c5818b4 100644
--- a/python/qpid_dispatch_internal/management/config.py
+++ b/python/qpid_dispatch_internal/management/config.py
@@ -124,7 +124,7 @@ def configure_dispatch(dispatch, lib_handle, filename):
dispatch = qd.qd_dispatch_p(dispatch)
config = Config(filename)
- # NOTE: Can't import agent till till dispatch C extension module is initialized.
+ # NOTE: Can't import agent till dispatch C extension module is initialized.
from .agent import Agent
agent = Agent(dispatch, qd)
qd.qd_dispatch_set_agent(dispatch, agent)
@@ -150,7 +150,7 @@ def configure_dispatch(dispatch, lib_handle, filename):
agent.activate("$_management_internal")
# Remaining configuration
- for t in "fixedAddress", "listener", "connector", "waypoint", "linkRoutePattern":
+ for t in "fixedAddress", "listener", "connector", "waypoint", "linkRoutePattern", "route":
for a in config.by_type(t): configure(a)
for e in config.entities:
configure(e)
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/dispatch.c
----------------------------------------------------------------------
diff --git a/src/dispatch.c b/src/dispatch.c
index 0a0d776..ad2d621 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -138,6 +138,12 @@ qd_error_t qd_dispatch_configure_lrp(qd_dispatch_t *qd, qd_entity_t *entity) {
return qd_error_code();
}
+qd_error_t qd_dispatch_configure_route(qd_dispatch_t *qd, qd_entity_t *entity) {
+ if (!qd->router) return qd_error(QD_ERROR_NOT_FOUND, "No router available");
+ qd_router_configure_route(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, qd->sasl_config_path, qd->sasl_config_name);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/dispatch_private.h
----------------------------------------------------------------------
diff --git a/src/dispatch_private.h b/src/dispatch_private.h
index cc7df08..b955e10 100644
--- a/src/dispatch_private.h
+++ b/src/dispatch_private.h
@@ -102,6 +102,11 @@ qd_error_t qd_dispatch_configure_waypoint(qd_dispatch_t *qd, qd_entity_t *entity
qd_error_t qd_dispatch_configure_lrp(qd_dispatch_t *qd, qd_entity_t *entity);
/**
+ * Configure a route, must be called after qd_dispatch_prepare
+ */
+qd_error_t qd_dispatch_configure_route(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.
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/router_config.c
----------------------------------------------------------------------
diff --git a/src/router_config.c b/src/router_config.c
index 8039efe..30ff89b 100644
--- a/src/router_config.c
+++ b/src/router_config.c
@@ -178,6 +178,106 @@ qd_error_t qd_router_configure_lrp(qd_router_t *router, qd_entity_t *entity)
}
+static void qd_router_insert_items(qd_composed_field_t *body, char *list)
+{
+ char *saveptr;
+ char *token;
+ char *delim = ", ";
+
+ token = strtok_r(list, delim, &saveptr);
+ while (token) {
+ qd_compose_insert_string(body, token);
+ token = strtok_r(0, delim, &saveptr);
+ }
+}
+
+
+qd_error_t qd_router_configure_route(qd_router_t *router, qd_entity_t *entity)
+{
+ char *name = qd_entity_opt_string(entity, "name", 0); QD_ERROR_RET();
+ char *address = qd_entity_opt_string(entity, "address", 0); QD_ERROR_RET();
+ char *path = qd_entity_opt_string(entity, "path", 0); QD_ERROR_RET();
+ char *treatment = qd_entity_opt_string(entity, "treatment", 0); QD_ERROR_RET();
+ char *connectors = qd_entity_opt_string(entity, "connectors", 0); QD_ERROR_RET();
+ char *containers = qd_entity_opt_string(entity, "containers", 0); QD_ERROR_RET();
+ char *route_address = qd_entity_opt_string(entity, "route_address", 0); QD_ERROR_RET();
+
+ //
+ // Formulate this configuration as a route and create it through the core management API.
+ //
+ qd_composed_field_t *body = qd_compose_subfield(0);
+ qd_compose_start_map(body);
+
+ if (name) {
+ qd_compose_insert_string(body, "name");
+ qd_compose_insert_string(body, name);
+ }
+
+ if (address) {
+ qd_compose_insert_string(body, "address");
+ qd_compose_insert_string(body, address);
+ }
+
+ if (path) {
+ qd_compose_insert_string(body, "path");
+ qd_compose_insert_string(body, path);
+ }
+
+ if (treatment) {
+ qd_compose_insert_string(body, "treatment");
+ qd_compose_insert_string(body, treatment);
+ }
+
+ if (connectors) {
+ qd_compose_insert_string(body, "connectors");
+ qd_compose_start_list(body);
+ qd_router_insert_items(body, connectors);
+ qd_compose_end_list(body);
+ }
+
+ if (containers) {
+ qd_compose_insert_string(body, "containers");
+ qd_compose_start_list(body);
+ qd_router_insert_items(body, containers);
+ qd_compose_end_list(body);
+ }
+
+ if (route_address) {
+ qd_compose_insert_string(body, "routeAddress");
+ qd_compose_insert_string(body, route_address);
+ }
+
+ qd_compose_end_map(body);
+
+ int length = 0;
+ qd_buffer_list_t buffers;
+
+ qd_compose_take_buffers(body, &buffers);
+ qd_compose_free(body);
+
+ qd_buffer_t *buf = DEQ_HEAD(buffers);
+ while (buf) {
+ length += qd_buffer_size(buf);
+ buf = DEQ_NEXT(buf);
+ }
+
+ qd_field_iterator_t *iter = qd_field_iterator_buffer(DEQ_HEAD(buffers), 0, length);
+ qd_parsed_field_t *in_body = qd_parse(iter);
+
+ qdr_manage_create(router->router_core, 0, QD_ROUTER_ROUTE, 0, in_body, 0);
+
+ free(name);
+ free(address);
+ free(path);
+ free(treatment);
+ free(connectors);
+ free(containers);
+ free(route_address);
+
+ return qd_error_code();
+}
+
+
void qd_router_configure_free(qd_router_t *router)
{
if (!router) return;
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/router_core/agent_address.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_address.c b/src/router_core/agent_address.c
index 1ed1614..1a9a44c 100644
--- a/src/router_core/agent_address.c
+++ b/src/router_core/agent_address.c
@@ -28,12 +28,13 @@
#define QDR_ADDRESS_IN_PROCESS 5
#define QDR_ADDRESS_SUBSCRIBER_COUNT 6
#define QDR_ADDRESS_REMOTE_COUNT 7
-#define QDR_ADDRESS_HOST_ROUTERS 8
-#define QDR_ADDRESS_DELIVERIES_INGRESS 9
-#define QDR_ADDRESS_DELIVERIES_EGRESS 10
-#define QDR_ADDRESS_DELIVERIES_TRANSIT 11
-#define QDR_ADDRESS_DELIVERIES_TO_CONTAINER 12
-#define QDR_ADDRESS_DELIVERIES_FROM_CONTAINER 13
+#define QDR_ADDRESS_CONTAINER_COUNT 8
+#define QDR_ADDRESS_HOST_ROUTERS 9
+#define QDR_ADDRESS_DELIVERIES_INGRESS 10
+#define QDR_ADDRESS_DELIVERIES_EGRESS 11
+#define QDR_ADDRESS_DELIVERIES_TRANSIT 12
+#define QDR_ADDRESS_DELIVERIES_TO_CONTAINER 13
+#define QDR_ADDRESS_DELIVERIES_FROM_CONTAINER 14
const char *qdr_address_columns[] =
{"name",
@@ -44,6 +45,7 @@ const char *qdr_address_columns[] =
"inProcess",
"subscriberCount",
"remoteCount",
+ "containerCount",
"hostRouters",
"deliveriesIngress",
"deliveriesEgress",
@@ -94,6 +96,10 @@ static void qdr_insert_address_columns_CT(qdr_address_t *addr,
qd_compose_insert_uint(body, qd_bitmask_cardinality(addr->rnodes));
break;
+ case QDR_ADDRESS_CONTAINER_COUNT:
+ qd_compose_insert_uint(body, DEQ_SIZE(addr->conns));
+ break;
+
case QDR_ADDRESS_HOST_ROUTERS:
qd_compose_insert_null(body); // TEMP
break;
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/router_core/agent_address.h
----------------------------------------------------------------------
diff --git a/src/router_core/agent_address.h b/src/router_core/agent_address.h
index 77d6dcc..abe6d89 100644
--- a/src/router_core/agent_address.h
+++ b/src/router_core/agent_address.h
@@ -36,7 +36,7 @@ void qdra_address_delete_CT(qdr_core_t *core,
qdr_query_t *query);
-#define QDR_ADDRESS_COLUMN_COUNT 14
+#define QDR_ADDRESS_COLUMN_COUNT 15
const char *qdr_address_columns[QDR_ADDRESS_COLUMN_COUNT + 1];
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/router_core/agent_route.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_route.c b/src/router_core/agent_route.c
index acf397b..97e70cf 100644
--- a/src/router_core/agent_route.c
+++ b/src/router_core/agent_route.c
@@ -67,7 +67,7 @@ static void qdr_route_insert_column_CT(qdr_route_config_t *route, int col, qd_co
}
case QDR_ROUTE_TYPE:
- qd_compose_insert_string(body, "org.apache.qpid.dispatch.router.route");
+ qd_compose_insert_string(body, "org.apache.qpid.dispatch.route");
break;
case QDR_ROUTE_ADDRESS:
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/router_core/management_agent.c
----------------------------------------------------------------------
diff --git a/src/router_core/management_agent.c b/src/router_core/management_agent.c
index 72f7d70..82f8c53 100644
--- a/src/router_core/management_agent.c
+++ b/src/router_core/management_agent.c
@@ -39,7 +39,7 @@ const char *IDENTITY = "identity";
const char *OPERATION = "operation";
const char *ATTRIBUTE_NAMES = "attributeNames";
-const unsigned char *route_entity_type = (unsigned char*) "org.apache.qpid.dispatch.router.route";
+const unsigned char *route_entity_type = (unsigned char*) "org.apache.qpid.dispatch.route";
const unsigned char *waypoint_entity_type = (unsigned char*) "org.apache.qpid.dispatch.waypoint";
const unsigned char *address_entity_type = (unsigned char*) "org.apache.qpid.dispatch.router.address";
const unsigned char *link_entity_type = (unsigned char*) "org.apache.qpid.dispatch.router.link";
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/router_core/route_control.c
----------------------------------------------------------------------
diff --git a/src/router_core/route_control.c b/src/router_core/route_control.c
index 2f66d14..96b5ef9 100644
--- a/src/router_core/route_control.c
+++ b/src/router_core/route_control.c
@@ -132,11 +132,27 @@ static void qdr_route_check_id_for_deletion_CT(qdr_core_t *core, qdr_conn_identi
}
+static void qdr_route_log_CT(qdr_core_t *core, const char *text, qdr_route_config_t *route, qdr_connection_t *conn)
+{
+ const char *key = (const char*) qd_hash_key_by_handle(conn->conn_id->hash_handle);
+ char id_string[64];
+ const char *name = route->name ? route->name : id_string;
+
+ if (!route->name)
+ snprintf(id_string, 64, "%ld", route->identity);
+
+ qd_log(core->log, QD_LOG_INFO, "Route '%s' %s on %s %s",
+ name, text, key[0] == 'L' ? "connection" : "container", &key[1]);
+}
+
+
static void qdr_route_activate_CT(qdr_core_t *core, qdr_route_active_t *active, qdr_connection_t *conn)
{
qdr_route_config_t *route = active->config;
const char *key;
+ qdr_route_log_CT(core, "Activated", route, conn);
+
if (route->treatment == QD_TREATMENT_LINK_BALANCED) {
//
// Activate the address(es) for link-routed destinations. If this is the first
@@ -168,6 +184,8 @@ static void qdr_route_deactivate_CT(qdr_core_t *core, qdr_route_active_t *active
qdr_route_config_t *route = active->config;
const char *key;
+ qdr_route_log_CT(core, "Deactivated", route, conn);
+
if (route->treatment == QD_TREATMENT_LINK_BALANCED) {
//
// Deactivate the address(es) for link-routed destinations.
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/src/router_private.h
----------------------------------------------------------------------
diff --git a/src/router_private.h b/src/router_private.h
index 5b14fc9..21497b4 100644
--- a/src/router_private.h
+++ b/src/router_private.h
@@ -41,6 +41,7 @@ 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_lrp(qd_router_t *router, qd_entity_t *entity);
+qd_error_t qd_router_configure_route(qd_router_t *router, qd_entity_t *entity);
void qd_router_configure_free(qd_router_t *router);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0d603e1b/tools/qdstat
----------------------------------------------------------------------
diff --git a/tools/qdstat b/tools/qdstat
index fd941cf..2144b1f 100755
--- a/tools/qdstat
+++ b/tools/qdstat
@@ -293,6 +293,7 @@ class BusManager(Node):
heads.append(Header("in-proc", Header.COMMAS))
heads.append(Header("local", Header.COMMAS))
heads.append(Header("remote", Header.COMMAS))
+ heads.append(Header("cntnr", Header.COMMAS))
heads.append(Header("in", Header.COMMAS))
heads.append(Header("out", Header.COMMAS))
heads.append(Header("thru", Header.COMMAS))
@@ -309,6 +310,7 @@ class BusManager(Node):
row.append(addr.inProcess)
row.append(addr.subscriberCount)
row.append(addr.remoteCount)
+ row.append(addr.containerCount)
row.append(addr.deliveriesIngress)
row.append(addr.deliveriesEgress)
row.append(addr.deliveriesTransit)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org