Author: tross
Date: Tue Dec 16 19:56:41 2008
New Revision: 727265
URL: http://svn.apache.org/viewvc?rev=727265&view=rev
Log:
Converted output to cout to proper QPID_LOG statements.
Modified:
qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
Modified: qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp?rev=727265&r1=727264&r2=727265&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp Tue Dec 16
19:56:41 2008
@@ -20,6 +20,7 @@
#include "qpid/management/Manageable.h"
#include "qpid/management/ManagementObject.h"
+#include "qpid/log/Statement.h"
#include "ManagementAgentImpl.h"
#include <list>
#include <string.h>
@@ -82,13 +83,10 @@
extThread(false), writeFd(-1), readFd(-1),
initialized(false), connected(false), lastFailure("never connected"),
clientWasAdded(true), requestedBrokerBank(0), requestedAgentBank(0),
- assignedBrokerBank(0), assignedAgentBank(0), bootSequence(0),
debugLevel(0),
+ assignedBrokerBank(0), assignedAgentBank(0), bootSequence(0),
connThreadBody(*this), connThread(connThreadBody),
pubThreadBody(*this), pubThread(pubThreadBody)
{
- char* debug = ::getenv("QMF_DEBUG_LEVEL");
- if (debug)
- debugLevel = ::atoi(debug);
}
ManagementAgentImpl::~ManagementAgentImpl()
@@ -137,9 +135,8 @@
connectionSettings.password = pwd;
connectionSettings.mechanism = mech;
- if (debugLevel)
- cout << "QMF Agent Initialized: broker=" << brokerHost << ":" <<
brokerPort <<
- " interval=" << intervalSeconds << " storeFile=" << _storeFile <<
endl;
+ QPID_LOG(info, "QMF Agent Initialized: broker=" << brokerHost << ":" <<
brokerPort <<
+ " interval=" << intervalSeconds << " storeFile=" << _storeFile);
// TODO: Abstract the socket calls for portability
if (extThread) {
@@ -265,10 +262,8 @@
uint32_t length = buffer.getPosition();
buffer.reset();
connThreadBody.sendBuffer(buffer, length, "qpid.management", "broker");
- if (debugLevel >= DEBUG_PROTO) {
- cout << "SENT AttachRequest: reqBroker=" << requestedBrokerBank <<
- " reqAgent=" << requestedAgentBank << endl;
- }
+ QPID_LOG(trace, "SENT AttachRequest: reqBroker=" << requestedBrokerBank <<
+ " reqAgent=" << requestedAgentBank);
}
void ManagementAgentImpl::storeData(bool requested)
@@ -316,9 +311,7 @@
outLen = MA_BUFFER_SIZE - outBuffer.available();
outBuffer.reset();
connThreadBody.sendBuffer(outBuffer, outLen, "amq.direct", replyToKey);
- if (debugLevel >= DEBUG_PROTO) {
- cout << "SENT CommandComplete: seq=" << sequence << " code=" << code
<< " text=" << text << endl;
- }
+ QPID_LOG(trace, "SENT CommandComplete: seq=" << sequence << " code=" <<
code << " text=" << text);
}
void ManagementAgentImpl::handleAttachResponse(Buffer& inBuffer)
@@ -328,19 +321,17 @@
assignedBrokerBank = inBuffer.getLong();
assignedAgentBank = inBuffer.getLong();
- if (debugLevel >= DEBUG_PROTO) {
- cout << "RCVD AttachResponse: broker=" << assignedBrokerBank <<
- " agent=" << assignedAgentBank << endl;
- }
+ QPID_LOG(trace, "RCVD AttachResponse: broker=" << assignedBrokerBank << "
agent=" << assignedAgentBank);
if ((assignedBrokerBank != requestedBrokerBank) ||
(assignedAgentBank != requestedAgentBank)) {
- if (requestedAgentBank == 0)
- cout << "Initial object-id bank assigned: " << assignedBrokerBank
<< "." <<
- assignedAgentBank << endl;
- else
- cout << "Collision in object-id! New bank assigned: " <<
assignedBrokerBank <<
- "." << assignedAgentBank << endl;
+ if (requestedAgentBank == 0) {
+ QPID_LOG(notice, "Initial object-id bank assigned: " <<
assignedBrokerBank << "." <<
+ assignedAgentBank);
+ } else {
+ QPID_LOG(warning, "Collision in object-id! New bank assigned: " <<
assignedBrokerBank <<
+ "." << assignedAgentBank);
+ }
storeData();
requestedBrokerBank = assignedBrokerBank;
requestedAgentBank = assignedAgentBank;
@@ -387,9 +378,7 @@
inBuffer.getShortString(key.name);
inBuffer.getBin128(key.hash);
- if (debugLevel >= DEBUG_PROTO) {
- cout << "RCVD SchemaRequest: package=" << packageName << " class=" <<
key.name << endl;
- }
+ QPID_LOG(trace, "RCVD SchemaRequest: package=" << packageName << " class="
<< key.name);
PackageMap::iterator pIter = packages.find(packageName);
if (pIter != packages.end()) {
@@ -406,9 +395,7 @@
outBuffer.reset();
connThreadBody.sendBuffer(outBuffer, outLen, "qpid.management",
"broker");
- if (debugLevel >= DEBUG_PROTO) {
- cout << "SENT SchemaInd: package=" << packageName << " class="
<< key.name << endl;
- }
+ QPID_LOG(trace, "SENT SchemaInd: package=" << packageName << "
class=" << key.name);
}
}
}
@@ -418,9 +405,7 @@
Mutex::ScopedLock lock(agentLock);
clientWasAdded = true;
- if (debugLevel >= DEBUG_PROTO) {
- cout << "RCVD ConsoleAddedInd" << endl;
- }
+ QPID_LOG(trace, "RCVD ConsoleAddedInd");
}
void ManagementAgentImpl::invokeMethodRequest(Buffer& inBuffer, uint32_t
sequence, string replyTo)
@@ -475,9 +460,7 @@
ft.decode(inBuffer);
- if (debugLevel >= DEBUG_PROTO) {
- cout << "RCVD GetQuery: map=" << ft << endl;
- }
+ QPID_LOG(trace, "RCVD GetQuery: map=" << ft);
value = ft.get("_class");
if (value.get() == 0 || !value->convertsTo<string>()) {
@@ -499,9 +482,7 @@
outBuffer.reset ();
connThreadBody.sendBuffer(outBuffer, outLen, "amq.direct",
replyTo);
- if (debugLevel >= DEBUG_PROTO) {
- cout << "SENT ObjectInd" << endl;
- }
+ QPID_LOG(trace, "SENT ObjectInd");
}
sendCommandComplete(replyTo, sequence);
return;
@@ -524,9 +505,7 @@
outBuffer.reset();
connThreadBody.sendBuffer(outBuffer, outLen, "amq.direct",
replyTo);
- if (debugLevel >= DEBUG_PROTO) {
- cout << "SENT ObjectInd" << endl;
- }
+ QPID_LOG(trace, "SENT ObjectInd");
}
}
@@ -546,9 +525,7 @@
invokeMethodRequest(inBuffer, sequence, replyTo);
}
- if (debugLevel >= DEBUG_PROTO) {
- cout << "RCVD MethodRequest" << endl;
- }
+ QPID_LOG(trace, "RCVD MethodRequest");
}
void ManagementAgentImpl::received(Message& msg)
@@ -659,9 +636,7 @@
{
buf.putShortString((*pIter).first);
- if (debugLevel >= DEBUG_PROTO) {
- cout << "SENT PackageInd: package=" << (*pIter).first << endl;
- }
+ QPID_LOG(trace, "SENT PackageInd: package=" << (*pIter).first);
}
void ManagementAgentImpl::encodeClassIndication(Buffer& buf,
@@ -675,9 +650,7 @@
buf.putShortString(key.name);
buf.putBin128(key.hash);
- if (debugLevel >= DEBUG_PROTO) {
- cout << "SENT ClassInd: package=" << (*pIter).first << " class=" <<
key.name << endl;
- }
+ QPID_LOG(trace, "SENT ClassInd: package=" << (*pIter).first << " class="
<< key.name);
}
void ManagementAgentImpl::periodicProcessing()
@@ -693,10 +666,6 @@
moveNewObjectsLH();
- if (debugLevel >= DEBUG_PUBLISH) {
- cout << "Objects managed: " << managementObjects.size() << endl;
- }
-
//
// Clear the been-here flag on all objects in the map.
//
@@ -769,10 +738,6 @@
}
}
- if (debugLevel >= DEBUG_PUBLISH && !deleteList.empty()) {
- cout << "Deleting " << deleteList.size() << " objects" << endl;
- }
-
// Delete flagged objects
for (list<pair<ObjectId, ManagementObject*> >::reverse_iterator iter =
deleteList.rbegin();
iter != deleteList.rend();
@@ -810,8 +775,7 @@
while (true) {
try {
if (agent.initialized) {
- if (agent.debugLevel)
- cout << "QMF Agent attempting to connect to the broker..."
<< endl;
+ QPID_LOG(debug, "QMF Agent attempting to connect to the
broker...");
connection.open(agent.connectionSettings);
session = connection.newSession(queueName.str());
subscriptions = new client::SubscriptionManager(session);
@@ -822,8 +786,7 @@
arg::bindingKey=queueName.str());
subscriptions->subscribe(agent, queueName.str(), dest);
- if (agent.debugLevel)
- cout << " Connection established" << endl;
+ QPID_LOG(info, "Connection established with broker");
{
Mutex::ScopedLock _lock(connLock);
if (shutdown)
@@ -835,8 +798,7 @@
subscriptions->run();
} catch (exception) {}
- if (agent.debugLevel)
- cout << "QMF Agent connection has been lost" << endl;
+ QPID_LOG(warning, "Connection to the broker has been
lost");
operational = false;
agent.connected = false;
@@ -849,8 +811,7 @@
} catch (exception &e) {
if (delay < delayMax)
delay *= delayFactor;
- if (agent.debugLevel)
- cout << " Connection failed: exception=" << e.what() <<
endl;
+ QPID_LOG(debug, "Connection failed: exception=" << e.what());
}
{
@@ -893,7 +854,9 @@
msg.setData(data);
try {
session.messageTransfer(arg::content=msg, arg::destination=exchange);
- } catch(exception&) {}
+ } catch(exception& e) {
+ QPID_LOG(error, "Exception caught in sendBuffer: " << e.what());
+ }
}
void ManagementAgentImpl::ConnectionThread::bindToBank(uint32_t brokerBank,
uint32_t agentBank)
@@ -901,7 +864,7 @@
stringstream key;
key << "agent." << brokerBank << "." << agentBank;
session.exchangeBind(arg::exchange="qpid.management",
arg::queue=queueName.str(),
- arg::bindingKey=key.str());
+ arg::bindingKey=key.str());
}
void ManagementAgentImpl::ConnectionThread::close()
Modified: qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h?rev=727265&r1=727264&r2=727265&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h Tue Dec 16
19:56:41 2008
@@ -146,7 +146,6 @@
uint32_t assignedBrokerBank;
uint32_t assignedAgentBank;
uint16_t bootSequence;
- uint8_t debugLevel;
static const uint8_t DEBUG_OFF = 0;
static const uint8_t DEBUG_CONN = 1;