Author: kgiusti
Date: Mon Sep 10 13:32:07 2012
New Revision: 1382830

URL: http://svn.apache.org/viewvc?rev=1382830&view=rev
Log:
QPID-4174: add client properties to client-related events.  Original patch from 
Pavel Moravec

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp
    qpid/trunk/qpid/specs/management-schema.xml

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp?rev=1382830&r1=1382829&r2=1382830&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp Mon Sep 10 13:32:07 2012
@@ -142,7 +142,7 @@ Connection::~Connection()
         // In a cluster, Connections destroyed during shutdown are in
         // a cluster-unsafe context. Don't raise an event in that case.
         if (!link && isClusterSafe())
-            agent->raiseEvent(_qmf::EventClientDisconnect(mgmtId, 
ConnectionState::getUserId()));
+            agent->raiseEvent(_qmf::EventClientDisconnect(mgmtId, 
ConnectionState::getUserId(), mgmtObject->get_remoteProperties()));
         QPID_LOG_CAT(debug, model, "Delete connection. user:" << 
ConnectionState::getUserId()
             << " rhost:" << mgmtId );
     }
@@ -287,7 +287,7 @@ void Connection::setUserId(const string&
 void Connection::raiseConnectEvent() {
     if (mgmtObject != 0) {
         mgmtObject->set_authIdentity(userId);
-        agent->raiseEvent(_qmf::EventClientConnect(mgmtId, userId));
+        agent->raiseEvent(_qmf::EventClientConnect(mgmtId, userId, 
mgmtObject->get_remoteProperties()));
     }
 
     QPID_LOG_CAT(debug, model, "Create connection. user:" << userId

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp?rev=1382830&r1=1382829&r2=1382830&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp Mon Sep 10 
13:32:07 2012
@@ -32,6 +32,7 @@
 #include "qpid/log/Statement.h"
 #include "qpid/sys/SecurityLayer.h"
 #include "qpid/broker/AclModule.h"
+#include "qpid/amqp_0_10/Codecs.h"
 #include "qmf/org/apache/qpid/broker/EventClientConnectFail.h"
 
 using namespace qpid;
@@ -148,6 +149,24 @@ void ConnectionHandler::Handler::startOk
 
 void ConnectionHandler::Handler::startOk(const ConnectionStartOkBody& body)
 {
+    const framing::FieldTable& clientProperties = body.getClientProperties();
+    qmf::org::apache::qpid::broker::Connection* mgmtObject = 
connection.getMgmtObject();
+
+    if (mgmtObject != 0) {
+        string procName = clientProperties.getAsString(CLIENT_PROCESS_NAME);
+        uint32_t pid = clientProperties.getAsInt(CLIENT_PID);
+        uint32_t ppid = clientProperties.getAsInt(CLIENT_PPID);
+
+        types::Variant::Map properties;
+        amqp_0_10::translate(clientProperties, properties);
+        mgmtObject->set_remoteProperties(properties);
+        if (!procName.empty())
+            mgmtObject->set_remoteProcessName(procName);
+        if (pid != 0)
+            mgmtObject->set_remotePid(pid);
+        if (ppid != 0)
+            mgmtObject->set_remoteParentPid(ppid);
+    }
     try {
         authenticator->start(body.getMechanism(), body.hasResponse() ? 
&body.getResponse() : 0);
     } catch (std::exception& /*e*/) {
@@ -160,8 +179,9 @@ void ConnectionHandler::Handler::startOk
             string uid;
             authenticator->getError(error);
             authenticator->getUid(uid);
-            if (agent) {
-                
agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, 
error));
+            if (agent && mgmtObject) {
+                
agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, 
error,
+                                                               
mgmtObject->get_remoteProperties()));
             }
             QPID_LOG_CAT(debug, model, "Failed connection. rhost:" << 
connection.getMgmtId()
                 << " user:" << uid
@@ -169,9 +189,8 @@ void ConnectionHandler::Handler::startOk
         }
         throw;
     }
-    const framing::FieldTable& clientProperties = body.getClientProperties();
-    connection.setClientProperties(clientProperties);
 
+    connection.setClientProperties(clientProperties);
     connection.setFederationLink(clientProperties.get(QPID_FED_LINK));
     if (clientProperties.isSet(QPID_FED_TAG)) {
         
connection.setFederationPeerTag(clientProperties.getAsString(QPID_FED_TAG));
@@ -187,19 +206,6 @@ void ConnectionHandler::Handler::startOk
         }
         QPID_LOG(info, "Connection is a federation link");
     }
-
-    if (connection.getMgmtObject() != 0) {
-        string procName = clientProperties.getAsString(CLIENT_PROCESS_NAME);
-        uint32_t pid = clientProperties.getAsInt(CLIENT_PID);
-        uint32_t ppid = clientProperties.getAsInt(CLIENT_PPID);
-
-        if (!procName.empty())
-            connection.getMgmtObject()->set_remoteProcessName(procName);
-        if (pid != 0)
-            connection.getMgmtObject()->set_remotePid(pid);
-        if (ppid != 0)
-            connection.getMgmtObject()->set_remoteParentPid(ppid);
-    }
 }
 
 void ConnectionHandler::Handler::secureOk(const string& response)
@@ -216,8 +222,9 @@ void ConnectionHandler::Handler::secureO
             string uid;
             authenticator->getError(error);
             authenticator->getUid(uid);
-            if (agent) {
-                
agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, 
error));
+            if (agent && connection.getMgmtObject()) {
+                
agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, 
error,
+                                                               
connection.getMgmtObject()->get_remoteProperties()));
             }
             QPID_LOG_CAT(debug, model, "Failed connection. rhost:" << 
connection.getMgmtId()
                 << " user:" << uid

Modified: qpid/trunk/qpid/specs/management-schema.xml
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/specs/management-schema.xml?rev=1382830&r1=1382829&r2=1382830&view=diff
==============================================================================
--- qpid/trunk/qpid/specs/management-schema.xml (original)
+++ qpid/trunk/qpid/specs/management-schema.xml Mon Sep 10 13:32:07 2012
@@ -357,6 +357,7 @@
     <property name="shadow"             type="bool"   access="RO" desc="True 
for shadow connections"/>
     <property name="saslMechanism"      type="sstr"   access="RO" desc="SASL 
mechanism"/>
     <property name="saslSsf"            type="uint16"   access="RO" desc="SASL 
security strength factor"/>
+    <property name="remoteProperties"   type="map"    access="RO" 
desc="optional map of identifying information sent by the remote"/>
     <statistic name="closing"          type="bool" desc="This client is 
closing by management request"/>
     <statistic name="framesFromClient" type="count64"/>
     <statistic name="framesToClient"   type="count64"/>
@@ -496,11 +497,12 @@
     <arg name="user"    type="sstr"   desc="Authentication identity"/>
     <arg name="msgDepth" type="count64" desc="Current size of queue in 
messages"/>
     <arg name="byteDepth" type="count64" desc="Current size of queue in 
bytes"/>
+    <arg name="properties" type="map" desc="optional identifying information 
sent by the remote"/>
   </eventArguments>
 
-  <event name="clientConnect"     sev="inform" args="rhost, user"/>
-  <event name="clientConnectFail" sev="warn"   args="rhost, user, reason"/>
-  <event name="clientDisconnect"  sev="inform" args="rhost, user"/>
+  <event name="clientConnect"     sev="inform" args="rhost, user, properties"/>
+  <event name="clientConnectFail" sev="warn"   args="rhost, user, reason, 
properties"/>
+  <event name="clientDisconnect"  sev="inform" args="rhost, user, properties"/>
   <event name="brokerLinkUp"      sev="inform" args="rhost"/>
   <event name="brokerLinkDown"    sev="warn"   args="rhost"/>
   <event name="queueDeclare"      sev="inform" args="rhost, user, qName, 
durable, excl, autoDel, altEx, args, disp"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to