Repository: qpid-dispatch Updated Branches: refs/heads/master 387044be4 -> d5d9b6845
DISPATCH-284 - Added a connection id to the link which can be used to linked back to the identity of the connection Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/d5d9b684 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/d5d9b684 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/d5d9b684 Branch: refs/heads/master Commit: d5d9b6845af60eb833e878cfb7a8aff9d755ba10 Parents: 387044b Author: Ganesh Murthy <gmur...@redhat.com> Authored: Tue Apr 26 14:42:40 2016 -0400 Committer: Ganesh Murthy <gmur...@redhat.com> Committed: Tue Apr 26 14:42:40 2016 -0400 ---------------------------------------------------------------------- include/qpid/dispatch/router_core.h | 2 ++ include/qpid/dispatch/server.h | 9 +++++++++ python/qpid_dispatch_internal/management/agent.py | 10 ++++++++-- src/router_core/agent_link.c | 11 ++++++++--- src/router_core/agent_link.h | 2 +- src/router_core/connections.c | 2 ++ src/router_core/router_core_private.h | 1 + src/router_node.c | 3 ++- src/server.c | 6 ++++++ tests/system_test.py | 2 +- tests/system_tests_management.py | 6 +++++- tools/qdstat | 4 ++++ 12 files changed, 49 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/include/qpid/dispatch/router_core.h ---------------------------------------------------------------------- diff --git a/include/qpid/dispatch/router_core.h b/include/qpid/dispatch/router_core.h index 951bb21..6784b67 100644 --- a/include/qpid/dispatch/router_core.h +++ b/include/qpid/dispatch/router_core.h @@ -151,6 +151,7 @@ typedef enum { * @param incoming True iff this connection is associated with a listener, False if a connector * @param role The configured role of this connection * @param cost If the role is inter_router, this is the configured cost for the connection. + * @param management_id - A unique identifier that is used in management and logging operations. * @param label Optional label provided in the connection's configuration. This is used to * correlate the connection with waypoints and link-route destinations that use the connection. * @param strip_annotations_in True if configured to remove annotations on inbound messages. @@ -162,6 +163,7 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t *core, bool incoming, qdr_connection_role_t role, int cost, + uint64_t management_id, const char *label, const char *remote_container_id, bool strip_annotations_in, http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/include/qpid/dispatch/server.h ---------------------------------------------------------------------- diff --git a/include/qpid/dispatch/server.h b/include/qpid/dispatch/server.h index 4683288..2a8e34a 100644 --- a/include/qpid/dispatch/server.h +++ b/include/qpid/dispatch/server.h @@ -564,6 +564,15 @@ pn_collector_t *qd_connection_collector(qd_connection_t *conn); /** + * Get the connection id of a connection. + * + * @param conn Connection object supplied in QD_CONN_EVENT_{LISTENER,CONNETOR}_OPEN + * @return The connection_id associated with the connection. + */ +uint64_t qd_connection_connection_id(qd_connection_t *conn); + + +/** * Get the configuration that was used in the setup of this connection. * * @param conn Connection object supplied in QD_CONN_EVENT_{LISTENER,CONNETOR}_OPEN http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/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 b050b8a..1c91dc3 100644 --- a/python/qpid_dispatch_internal/management/agent.py +++ b/python/qpid_dispatch_internal/management/agent.py @@ -161,9 +161,15 @@ class EntityAdapter(SchemaEntity): def validate(self, **kwargs): """Set default identity and name if not already set, then do schema validation""" identity = self.attributes.get("identity") - if not identity: + name = self.attributes.get("name") + if identity: + if not name: + self.attributes[u"name"] = "%s/%s" % (self.entity_type.short_name, self._identifier()) + else: self.attributes[u"identity"] = "%s/%s" % (self.entity_type.short_name, self._identifier()) - self.attributes.setdefault(u'name', self.attributes[u'identity']) + if not name: + self.attributes.setdefault(u'name', self.attributes[u'identity']) + super(EntityAdapter, self).validate(**kwargs) def _identifier(self): http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/src/router_core/agent_link.c ---------------------------------------------------------------------- diff --git a/src/router_core/agent_link.c b/src/router_core/agent_link.c index 6830367..9204565 100644 --- a/src/router_core/agent_link.c +++ b/src/router_core/agent_link.c @@ -33,8 +33,9 @@ #define QDR_LINK_UNDELIVERED_COUNT 9 #define QDR_LINK_UNSETTLED_COUNT 10 #define QDR_LINK_DELIVERY_COUNT 11 -#define QDR_LINK_ADMIN_STATE 12 -#define QDR_LINK_OPER_STATE 13 +#define QDR_LINK_CONNECTION_ID 12 +#define QDR_LINK_ADMIN_STATE 13 +#define QDR_LINK_OPER_STATE 14 const char *qdr_link_columns[] = {"name", @@ -49,6 +50,7 @@ const char *qdr_link_columns[] = "undeliveredCount", "unsettledCount", "deliveryCount", + "connectionId", // The connection id of the owner connection "adminStatus", "operStatus", 0}; @@ -90,7 +92,6 @@ static void qdr_agent_write_column_CT(qd_composed_field_t *body, int col, qdr_li break; } - case QDR_LINK_TYPE: qd_compose_insert_string(body, "org.apache.qpid.dispatch.router.link"); break; @@ -139,6 +140,10 @@ static void qdr_agent_write_column_CT(qd_composed_field_t *body, int col, qdr_li qd_compose_insert_ulong(body, link->total_deliveries); break; + case QDR_LINK_CONNECTION_ID: + qd_compose_insert_ulong(body, link->conn->management_id); + break; + case QDR_LINK_ADMIN_STATE: text = link->admin_enabled ? "enabled" : "disabled"; qd_compose_insert_string(body, text); http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/src/router_core/agent_link.h ---------------------------------------------------------------------- diff --git a/src/router_core/agent_link.h b/src/router_core/agent_link.h index 9cdf391..db1f88a 100644 --- a/src/router_core/agent_link.h +++ b/src/router_core/agent_link.h @@ -29,7 +29,7 @@ void qdra_link_update_CT(qdr_core_t *core, qdr_query_t *query, qd_parsed_field_t *in_body); -#define QDR_LINK_COLUMN_COUNT 14 +#define QDR_LINK_COLUMN_COUNT 15 const char *qdr_link_columns[QDR_LINK_COLUMN_COUNT + 1]; http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/src/router_core/connections.c ---------------------------------------------------------------------- diff --git a/src/router_core/connections.c b/src/router_core/connections.c index e762a85..69379b1 100644 --- a/src/router_core/connections.c +++ b/src/router_core/connections.c @@ -59,6 +59,7 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t *core, bool incoming, qdr_connection_role_t role, int cost, + uint64_t management_id, const char *label, const char *remote_container_id, bool strip_annotations_in, @@ -77,6 +78,7 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t *core, conn->strip_annotations_in = strip_annotations_in; conn->strip_annotations_out = strip_annotations_out; conn->link_capacity = link_capacity; + conn->management_id = management_id; conn->mask_bit = -1; DEQ_INIT(conn->links); DEQ_INIT(conn->work_list); http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/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 061e346..a3e0b17 100644 --- a/src/router_core/router_core_private.h +++ b/src/router_core/router_core_private.h @@ -425,6 +425,7 @@ struct qdr_connection_t { bool strip_annotations_out; int link_capacity; int mask_bit; + uint64_t management_id; // A unique identifier for the qdr_connection_t copied over from qd_connection_t. qdr_connection_work_list_t work_list; sys_mutex_t *work_lock; qdr_link_ref_list_t links; http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/src/router_node.c ---------------------------------------------------------------------- diff --git a/src/router_node.c b/src/router_node.c index a6431fe..c3ef5c2 100644 --- a/src/router_node.c +++ b/src/router_node.c @@ -505,6 +505,7 @@ static void AMQP_opened_handler(qd_router_t *router, qd_connection_t *conn, bool bool strip_annotations_out = false; int link_capacity = 1; const char *name = 0; + uint64_t connection_id = qd_connection_connection_id(conn); pn_connection_t *pn_conn = qd_connection_pn(conn); qd_router_connection_get_config(conn, &role, &cost, &name, @@ -542,7 +543,7 @@ static void AMQP_opened_handler(qd_router_t *router, qd_connection_t *conn, bool cost = remote_cost; } - qdr_connection_t *qdrc = qdr_connection_opened(router->router_core, inbound, role, cost, name, + qdr_connection_t *qdrc = qdr_connection_opened(router->router_core, inbound, role, cost, connection_id, name, pn_connection_remote_container(pn_conn), strip_annotations_in, strip_annotations_out, link_capacity); http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/src/server.c ---------------------------------------------------------------------- diff --git a/src/server.c b/src/server.c index 7750056..c761720 100644 --- a/src/server.c +++ b/src/server.c @@ -368,6 +368,7 @@ qd_error_t qd_entity_refresh_connection(qd_entity_t* entity, void *impl) qd_entity_set_string(entity, "role", config->role) == 0 && qd_entity_set_string(entity, "dir", conn->connector ? "out" : "in") == 0 && qd_entity_set_string(entity, "user", user) == 0 && + qd_entity_set_long(entity, "identity", conn->connection_id) == 0 && qd_entity_set_bool(entity, "isAuthenticated", tport && pn_transport_is_authenticated(tport)) == 0 && qd_entity_set_bool(entity, "isEncrypted", tport && pn_transport_is_encrypted(tport)) == 0 && qd_entity_set_bool(entity, "ssl", ssl != 0) == 0) { @@ -1529,6 +1530,11 @@ pn_collector_t *qd_connection_collector(qd_connection_t *conn) return conn->collector; } +uint64_t qd_connection_connection_id(qd_connection_t *conn) +{ + return conn->connection_id; +} + const qd_server_config_t *qd_connection_config(const qd_connection_t *conn) { http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/tests/system_test.py ---------------------------------------------------------------------- diff --git a/tests/system_test.py b/tests/system_test.py index 3061e3e..be9b262 100755 --- a/tests/system_test.py +++ b/tests/system_test.py @@ -440,7 +440,7 @@ class Qdrouterd(Process): """If router has a connection to host:port return the management info. Otherwise return None""" try: - return self.management.read(identity="connection/%s:%s" % (host, port)) + return self.management.read(name="connection/%s:%s" % (host, port)) except: return False http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/tests/system_tests_management.py ---------------------------------------------------------------------- diff --git a/tests/system_tests_management.py b/tests/system_tests_management.py index c24ac35..ead40ac 100644 --- a/tests/system_tests_management.py +++ b/tests/system_tests_management.py @@ -364,7 +364,11 @@ class ManagementTest(system_test.TestCase): if e.type == MANAGEMENT: self.assertEqual(e.identity, "self") else: - self.assertRegexpMatches(e.identity, "^%s/" % short_name(e.type), e) + if e.type == 'org.apache.qpid.dispatch.connection': + # This will make sure that the identity of the connection object is always numeric + self.assertRegexpMatches(str(e.identity), "[1-9]+", e) + else: + self.assertRegexpMatches(e.identity, "^%s/" % short_name(e.type), e) def test_remote_node(self): """Test that we can access management info of remote nodes using get_mgmt_nodes addresses""" http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d5d9b684/tools/qdstat ---------------------------------------------------------------------- diff --git a/tools/qdstat b/tools/qdstat index 3dd1668..3d733d6 100755 --- a/tools/qdstat +++ b/tools/qdstat @@ -109,6 +109,7 @@ class BusManager(Node): def displayConnections(self): disp = Display(prefix=" ") heads = [] + heads.append(Header("Id")) heads.append(Header("host")) heads.append(Header("container")) heads.append(Header("role")) @@ -122,6 +123,7 @@ class BusManager(Node): for conn in objects: row = [] + row.append(conn.identity) row.append(conn.host) row.append(conn.container) row.append(conn.role) @@ -214,6 +216,7 @@ class BusManager(Node): heads = [] heads.append(Header("type")) heads.append(Header("dir")) + heads.append(Header("conn id")) heads.append(Header("id")) heads.append(Header("peer")) heads.append(Header("class")) @@ -235,6 +238,7 @@ class BusManager(Node): row = [] row.append(link.linkType) row.append(link.linkDir) + row.append(link.connectionId) row.append(link.identity) row.append(link.peer) row.append(self._addr_class(link.owningAddr)) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org