summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorCharles E. Rolke <chug@apache.org>2012-07-13 15:08:56 +0000
committerCharles E. Rolke <chug@apache.org>2012-07-13 15:08:56 +0000
commitbd6444f1b8255a59e79645135b4fef579ef4948b (patch)
tree190d01186baa7a32fd1143b9c3cbf0a7d17a85d3 /cpp
parentd6f984ad6aa4a931806816d03b81c624e9ab6a70 (diff)
downloadqpid-python-bd6444f1b8255a59e79645135b4fef579ef4948b.tar.gz
QPID-4079 log entries track managed object life cycles
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1361262 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/qpid/log/Statement.h5
-rwxr-xr-xcpp/managementgen/qmf-gen7
-rwxr-xr-xcpp/managementgen/qmfgen/generate.py3
-rw-r--r--cpp/managementgen/qmfgen/templates/Class.cpp24
-rw-r--r--cpp/src/CMakeLists.txt2
-rw-r--r--cpp/src/Makefile.am2
-rw-r--r--cpp/src/qpid/broker/Broker.cpp31
-rw-r--r--cpp/src/qpid/broker/Connection.cpp6
-rw-r--r--cpp/src/qpid/broker/ConnectionHandler.cpp26
-rw-r--r--cpp/src/qpid/broker/Queue.cpp3
-rw-r--r--cpp/src/qpid/broker/SessionAdapter.cpp23
-rw-r--r--cpp/src/qpid/log/Statement.cpp2
12 files changed, 120 insertions, 14 deletions
diff --git a/cpp/include/qpid/log/Statement.h b/cpp/include/qpid/log/Statement.h
index f61596917a..ad84d66db6 100644
--- a/cpp/include/qpid/log/Statement.h
+++ b/cpp/include/qpid/log/Statement.h
@@ -72,10 +72,11 @@ struct LevelTraits {
* Store store
* Network tcp rdma AsynchIO socket epoll
* Test
- * Unspecified
+ * Model <not related to a directory>
+ * Unspecified <must be last in enum>
*/
enum Category { security, broker, management, protocol, system, ha, messaging,
- store, network, test, client, unspecified };
+ store, network, test, client, model, unspecified };
struct CategoryTraits {
static const int COUNT=unspecified+1;
diff --git a/cpp/managementgen/qmf-gen b/cpp/managementgen/qmf-gen
index 6e8f864256..2f0cc0d8fd 100755
--- a/cpp/managementgen/qmf-gen
+++ b/cpp/managementgen/qmf-gen
@@ -49,6 +49,8 @@ parser.add_option("-b", "--broker-plugin", dest="brokerplugin", default=False, a
help="Generate code for use in a qpid broker plugin")
parser.add_option("-2", "--v2-style", dest="v2_style", default=False, action="store_true",
help="Generate code for use with the QMFv2 Agent API")
+parser.add_option("-l", "--qpid-logs", dest="qpidlogs", default=False, action="store_true",
+ help="Generate code for QPID_LOG statements in classes constructor/destructor")
(opts, args) = parser.parse_args()
@@ -70,6 +72,11 @@ else:
vargs["agentHeaderDir"] = "agent"
vargs["genQmfV1"] = None
+if opts.qpidlogs:
+ vargs["genLogs"] = True
+else:
+ vargs["genLogs"] = False
+
for schemafile in args:
package = SchemaPackage(typefile, schemafile, opts)
diff --git a/cpp/managementgen/qmfgen/generate.py b/cpp/managementgen/qmfgen/generate.py
index 4e688e3bc7..61111be01d 100755
--- a/cpp/managementgen/qmfgen/generate.py
+++ b/cpp/managementgen/qmfgen/generate.py
@@ -304,6 +304,9 @@ class Generator:
def testGenQMFv1 (self, variables):
return variables["genQmfV1"]
+ def testGenLogs (self, variables):
+ return variables["genLogs"]
+
def genDisclaimer (self, stream, variables):
prefix = variables["commentPrefix"]
stream.write (prefix + " This source file was created by a code generator.\n")
diff --git a/cpp/managementgen/qmfgen/templates/Class.cpp b/cpp/managementgen/qmfgen/templates/Class.cpp
index 396812f2e0..d3033db7e1 100644
--- a/cpp/managementgen/qmfgen/templates/Class.cpp
+++ b/cpp/managementgen/qmfgen/templates/Class.cpp
@@ -7,9 +7,9 @@
// 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
@@ -27,6 +27,9 @@
#include "qpid//*MGEN:Class.AgentHeaderLocation*//ManagementAgent.h"
#include "/*MGEN:Class.NameCap*/.h"
/*MGEN:Class.MethodArgIncludes*/
+/*MGEN:IF(Root.GenLogs)*/
+#include "qpid/log/Statement.h"
+/*MGEN:ENDIF*/
#include <iostream>
#include <sstream>
#include <string.h>
@@ -59,10 +62,26 @@ uint8_t /*MGEN:Class.NameCap*/::md5Sum[MD5_LEN] =
for (int idx = 0; idx < maxThreads; idx++)
perThreadStatsArray[idx] = 0;
/*MGEN:ENDIF*/
+/*MGEN:IF(Root.GenLogs)*/
+ QPID_LOG_CAT(trace, model, "Mgmt create " << className
+ << ". id:" << getKey());
+/*MGEN:ENDIF*/
}
/*MGEN:Class.NameCap*/::~/*MGEN:Class.NameCap*/ ()
{
+/*MGEN:IF(Root.GenLogs)*/
+ bool logEnabled;
+ QPID_LOG_TEST_CAT(trace, model, logEnabled);
+ if (logEnabled)
+ {
+ ::qpid::types::Variant::Map map;
+ mapEncodeValues(map, false, true);
+ QPID_LOG_CAT(trace, model, "Mgmt delete " << className
+ << ". id:" << getKey()
+ << " Statistics: " << map);
+ }
+/*MGEN:ENDIF*/
/*MGEN:IF(Class.ExistPerThreadStats)*/
for (int idx = 0; idx < maxThreads; idx++)
if (perThreadStatsArray[idx] != 0)
@@ -275,7 +294,6 @@ std::string /*MGEN:Class.NameCap*/::getKey() const
}
-
void /*MGEN:Class.NameCap*/::mapEncodeValues (::qpid::types::Variant::Map& _map,
bool includeProperties,
bool includeStatistics)
diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt
index e27aca0630..c06b21029f 100644
--- a/cpp/src/CMakeLists.txt
+++ b/cpp/src/CMakeLists.txt
@@ -220,7 +220,7 @@ execute_process(COMMAND ${RUBY_EXECUTABLE} -I ${rgen_dir} ${rgen_dir}/generate $
endforeach (spec_file ${mgmt_specs})
if (regen_mgmt)
message(STATUS "Regenerating Qpid Management Framework sources")
-execute_process(COMMAND ${PYTHON_EXECUTABLE} ${mgen_dir}/qmf-gen -c managementgen.cmake -b -q -o ${CMAKE_CURRENT_BINARY_DIR}/qmf ${mgmt_specs}
+execute_process(COMMAND ${PYTHON_EXECUTABLE} ${mgen_dir}/qmf-gen -c managementgen.cmake -b -l -q -o ${CMAKE_CURRENT_BINARY_DIR}/qmf ${mgmt_specs}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else (regen_mgmt)
message(STATUS "No need to generate Qpid Management Framework sources")
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am
index 276612b10b..924d810b44 100644
--- a/cpp/src/Makefile.am
+++ b/cpp/src/Makefile.am
@@ -107,7 +107,7 @@ mgen_xml=$(top_srcdir)/../specs/management-schema.xml \
$(srcdir)/qpid/cluster/management-schema.xml \
$(srcdir)/qpid/ha/management-schema.xml
mgen_cmd=$(mgen_dir)/qmf-gen -m $(srcdir)/managementgen.mk \
- -c $(srcdir)/managementgen.cmake -q -b -o qmf \
+ -c $(srcdir)/managementgen.cmake -q -b -l -o qmf \
$(mgen_xml)
$(srcdir)/managementgen.mk $(mgen_broker_cpp) $(dist_qpid_management_HEADERS): mgen.timestamp
diff --git a/cpp/src/qpid/broker/Broker.cpp b/cpp/src/qpid/broker/Broker.cpp
index c202d9c4e8..fba5299169 100644
--- a/cpp/src/qpid/broker/Broker.cpp
+++ b/cpp/src/qpid/broker/Broker.cpp
@@ -1099,6 +1099,13 @@ std::pair<boost::shared_ptr<Queue>, bool> Broker::createQueue(
ManagementAgent::toMap(arguments),
"created"));
}
+ QPID_LOG_CAT(debug, model, "Create queue. name:" << name
+ << " user:" << userId
+ << " rhost:" << connectionId
+ << " durable:" << (durable ? "T" : "F")
+ << " owner:" << owner
+ << " autodelete:" << (autodelete ? "T" : "F")
+ << " alternateExchange:" << alternateExchange );
}
return result;
}
@@ -1121,6 +1128,10 @@ void Broker::deleteQueue(const std::string& name, const std::string& userId,
if (managementAgent.get())
managementAgent->raiseEvent(_qmf::EventQueueDelete(connectionId, userId, name));
+ QPID_LOG_CAT(debug, model, "Delete queue. name:" << name
+ << " user:" << userId
+ << " rhost:" << connectionId
+ );
}
@@ -1172,6 +1183,12 @@ std::pair<Exchange::shared_ptr, bool> Broker::createExchange(
ManagementAgent::toMap(arguments),
"created"));
}
+ QPID_LOG_CAT(debug, model, "Create exchange. name:" << name
+ << " user:" << userId
+ << " rhost:" << connectionId
+ << " type:" << type
+ << " alternateExchange:" << alternateExchange
+ << " durable:" << (durable ? "T" : "F"));
}
return result;
}
@@ -1196,7 +1213,9 @@ void Broker::deleteExchange(const std::string& name, const std::string& userId,
if (managementAgent.get())
managementAgent->raiseEvent(_qmf::EventExchangeDelete(connectionId, userId, name));
-
+ QPID_LOG_CAT(debug, model, "Delete exchange. name:" << name
+ << " user:" << userId
+ << " rhost:" << connectionId);
}
void Broker::bind(const std::string& queueName,
@@ -1231,6 +1250,11 @@ void Broker::bind(const std::string& queueName,
managementAgent->raiseEvent(_qmf::EventBind(connectionId, userId, exchangeName,
queueName, key, ManagementAgent::toMap(arguments)));
}
+ QPID_LOG_CAT(debug, model, "Create binding. exchange:" << exchangeName
+ << " queue:" << queueName
+ << " key:" << key
+ << " user:" << userId
+ << " rhost:" << connectionId);
}
}
}
@@ -1267,6 +1291,11 @@ void Broker::unbind(const std::string& queueName,
if (managementAgent.get()) {
managementAgent->raiseEvent(_qmf::EventUnbind(connectionId, userId, exchangeName, queueName, key));
}
+ QPID_LOG_CAT(debug, model, "Delete binding. exchange:" << exchangeName
+ << " queue:" << queueName
+ << " key:" << key
+ << " user:" << userId
+ << " rhost:" << connectionId);
}
}
}
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp
index 85914b6b3a..8d250a32e5 100644
--- a/cpp/src/qpid/broker/Connection.cpp
+++ b/cpp/src/qpid/broker/Connection.cpp
@@ -143,6 +143,8 @@ Connection::~Connection()
// a cluster-unsafe context. Don't raise an event in that case.
if (!link && isClusterSafe())
agent->raiseEvent(_qmf::EventClientDisconnect(mgmtId, ConnectionState::getUserId()));
+ QPID_LOG_CAT(debug, model, "Delete connection. user:" << ConnectionState::getUserId()
+ << " rhost:" << mgmtId );
}
broker.getConnectionObservers().closed(*this);
@@ -287,6 +289,10 @@ void Connection::raiseConnectEvent() {
mgmtObject->set_authIdentity(userId);
agent->raiseEvent(_qmf::EventClientConnect(mgmtId, userId));
}
+
+ QPID_LOG_CAT(debug, model, "Create connection. user:" << userId
+ << " rhost:" << mgmtId );
+
}
void Connection::setUserProxyAuth(bool b)
diff --git a/cpp/src/qpid/broker/ConnectionHandler.cpp b/cpp/src/qpid/broker/ConnectionHandler.cpp
index 4af4692f78..06f442a47f 100644
--- a/cpp/src/qpid/broker/ConnectionHandler.cpp
+++ b/cpp/src/qpid/broker/ConnectionHandler.cpp
@@ -152,12 +152,20 @@ void ConnectionHandler::Handler::startOk(const ConnectionStartOkBody& body)
authenticator->start(body.getMechanism(), body.hasResponse() ? &body.getResponse() : 0);
} catch (std::exception& /*e*/) {
management::ManagementAgent* agent = connection.getAgent();
- if (agent) {
+ bool logEnabled;
+ QPID_LOG_TEST_CAT(debug, model, logEnabled);
+ if (logEnabled || agent)
+ {
string error;
string uid;
authenticator->getError(error);
authenticator->getUid(uid);
- agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, error));
+ if (agent) {
+ agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, error));
+ }
+ QPID_LOG_CAT(debug, model, "Failed connection. rhost:" << connection.getMgmtId()
+ << " user:" << uid
+ << " reason:" << error );
}
throw;
}
@@ -200,12 +208,20 @@ void ConnectionHandler::Handler::secureOk(const string& response)
authenticator->step(response);
} catch (std::exception& /*e*/) {
management::ManagementAgent* agent = connection.getAgent();
- if (agent) {
+ bool logEnabled;
+ QPID_LOG_TEST_CAT(debug, model, logEnabled);
+ if (logEnabled || agent)
+ {
string error;
string uid;
authenticator->getError(error);
authenticator->getUid(uid);
- agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, error));
+ if (agent) {
+ agent->raiseEvent(_qmf::EventClientConnectFail(connection.getMgmtId(), uid, error));
+ }
+ QPID_LOG_CAT(debug, model, "Failed connection. rhost:" << connection.getMgmtId()
+ << " user:" << uid
+ << " reason:" << error );
}
throw;
}
@@ -283,7 +299,7 @@ void ConnectionHandler::Handler::start(const FieldTable& serverProperties,
service,
host,
0, // TODO -- mgoulish Fri Sep 24 2010
- 256,
+ 256,
false ); // disallow interaction
}
std::string supportedMechanismsList;
diff --git a/cpp/src/qpid/broker/Queue.cpp b/cpp/src/qpid/broker/Queue.cpp
index 3202a2676f..f2e2150a5a 100644
--- a/cpp/src/qpid/broker/Queue.cpp
+++ b/cpp/src/qpid/broker/Queue.cpp
@@ -1494,6 +1494,9 @@ void tryAutoDeleteImpl(Broker& broker, Queue::shared_ptr queue, const std::strin
if (broker.getManagementAgent())
broker.getManagementAgent()->raiseEvent(_qmf::EventQueueDelete(connectionId, userId, queue->getName()));
+ QPID_LOG_CAT(debug, model, "Delete queue. name:" << queue->getName()
+ << " user:" << userId
+ << " rhost:" << connectionId );
}
}
diff --git a/cpp/src/qpid/broker/SessionAdapter.cpp b/cpp/src/qpid/broker/SessionAdapter.cpp
index 7469fb3af3..ae994a6bd5 100644
--- a/cpp/src/qpid/broker/SessionAdapter.cpp
+++ b/cpp/src/qpid/broker/SessionAdapter.cpp
@@ -109,6 +109,12 @@ void SessionAdapter::ExchangeHandlerImpl::declare(const string& exchange, const
false,
ManagementAgent::toMap(args),
"existing"));
+ QPID_LOG_CAT(debug, model, "Create exchange. name:" << exchange
+ << " user:" << getConnection().getUserId()
+ << " rhost:" << getConnection().getUrl()
+ << " type:" << type
+ << " alternateExchange:" << alternateExchange
+ << " durable:" << (durable ? "T" : "F"));
}
}catch(UnknownExchangeTypeException& /*e*/){
throw NotFoundException(QPID_MSG("Exchange type not implemented: " << type));
@@ -312,6 +318,14 @@ void SessionAdapter::QueueHandlerImpl::declare(const string& name, const string&
agent->raiseEvent(_qmf::EventQueueDeclare(getConnection().getUrl(), getConnection().getUserId(),
name, durable, exclusive, autoDelete, alternateExchange, ManagementAgent::toMap(arguments),
"existing"));
+ QPID_LOG_CAT(debug, model, "Create queue. name:" << name
+ << " user:" << getConnection().getUserId()
+ << " rhost:" << getConnection().getUrl()
+ << " durable:" << (durable ? "T" : "F")
+ << " exclusive:" << (exclusive ? "T" : "F")
+ << " autodelete:" << (autoDelete ? "T" : "F")
+ << " alternateExchange:" << alternateExchange
+ );
}
}
@@ -416,6 +430,12 @@ SessionAdapter::MessageHandlerImpl::subscribe(const string& queueName,
if (agent)
agent->raiseEvent(_qmf::EventSubscribe(getConnection().getUrl(), getConnection().getUserId(),
queueName, destination, exclusive, ManagementAgent::toMap(arguments)));
+ QPID_LOG_CAT(debug, model, "Create subscription. queue:" << queueName
+ << " destination:" << destination
+ << " user:" << getConnection().getUserId()
+ << " rhost:" << getConnection().getUrl()
+ << " exclusive:" << (exclusive ? "T" : "F")
+ );
}
void
@@ -428,6 +448,9 @@ SessionAdapter::MessageHandlerImpl::cancel(const string& destination )
ManagementAgent* agent = getBroker().getManagementAgent();
if (agent)
agent->raiseEvent(_qmf::EventUnsubscribe(getConnection().getUrl(), getConnection().getUserId(), destination));
+ QPID_LOG_CAT(debug, model, "Delete subscription. destination:" << destination
+ << " user:" << getConnection().getUserId()
+ << " rhost:" << getConnection().getUrl() );
}
void
diff --git a/cpp/src/qpid/log/Statement.cpp b/cpp/src/qpid/log/Statement.cpp
index b0a58fabe7..09ef458547 100644
--- a/cpp/src/qpid/log/Statement.cpp
+++ b/cpp/src/qpid/log/Statement.cpp
@@ -143,7 +143,7 @@ const char* names[LevelTraits::COUNT] = {
const char* catNames[CategoryTraits::COUNT] = {
"Security", "Broker", "Management", "Protocol", "System", "HA", "Messaging",
- "Store", "Network", "Test", "Client", "Unspecified"
+ "Store", "Network", "Test", "Client", "Model", "Unspecified"
};
} // namespace