From e0045c53af7d5178a46460fd69f5fbe3531565e3 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 25 Feb 2013 19:43:20 +0000 Subject: NO-JIRA: HA loggging: include status in log messages that refer to a BrokerInfo git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1449831 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/ha/BrokerInfo.cpp | 11 +---------- cpp/src/qpid/ha/BrokerInfo.h | 3 --- cpp/src/qpid/ha/HaBroker.cpp | 4 ++-- cpp/src/qpid/ha/QueueGuard.cpp | 2 +- cpp/src/qpid/ha/RemoteBackup.cpp | 17 ++++++++++++----- cpp/src/qpid/ha/ReplicatingSubscription.cpp | 2 +- 6 files changed, 17 insertions(+), 22 deletions(-) (limited to 'cpp') diff --git a/cpp/src/qpid/ha/BrokerInfo.cpp b/cpp/src/qpid/ha/BrokerInfo.cpp index a0c4af88ca..8efed91b17 100644 --- a/cpp/src/qpid/ha/BrokerInfo.cpp +++ b/cpp/src/qpid/ha/BrokerInfo.cpp @@ -48,15 +48,7 @@ BrokerInfo::BrokerInfo() : port(0), status(JOINING) {} BrokerInfo::BrokerInfo(const types::Uuid& id, BrokerStatus s, const std::string& host, uint16_t port_) : hostName(host), port(port_), systemId(id), status(s) -{ - updateLogId(); -} - -void BrokerInfo::updateLogId() { - std::ostringstream o; - o << hostName << ":" << port; - logId = o.str(); -} +{} FieldTable BrokerInfo::asFieldTable() const { Variant::Map m = asMap(); @@ -94,7 +86,6 @@ void BrokerInfo::assign(const Variant::Map& m) { hostName = get(m, HOST_NAME).asString(); port = get(m, PORT).asUint16(); status = BrokerStatus(get(m, STATUS).asUint8()); - updateLogId(); } std::ostream& operator<<(std::ostream& o, const BrokerInfo& b) { diff --git a/cpp/src/qpid/ha/BrokerInfo.h b/cpp/src/qpid/ha/BrokerInfo.h index 6142e03f98..40358336b0 100644 --- a/cpp/src/qpid/ha/BrokerInfo.h +++ b/cpp/src/qpid/ha/BrokerInfo.h @@ -53,7 +53,6 @@ class BrokerInfo std::string getHostName() const { return hostName; } BrokerStatus getStatus() const { return status; } uint16_t getPort() const { return port; } - std::string getLogId() const { return logId; } void setStatus(BrokerStatus s) { status = s; } @@ -67,8 +66,6 @@ class BrokerInfo bool operator<(const BrokerInfo x) const { return systemId < x.systemId; } private: - void updateLogId(); - std::string logId; std::string hostName; uint16_t port; types::Uuid systemId; diff --git a/cpp/src/qpid/ha/HaBroker.cpp b/cpp/src/qpid/ha/HaBroker.cpp index 661c518fc7..590db7efa5 100644 --- a/cpp/src/qpid/ha/HaBroker.cpp +++ b/cpp/src/qpid/ha/HaBroker.cpp @@ -70,7 +70,7 @@ HaBroker::HaBroker(broker::Broker& b, const Settings& s) // otherwise there's a window for a client to connect before we get to // initialize() if (settings.cluster) { - QPID_LOG(debug, role->getLogPrefix() << "Rejecting client connections."); + QPID_LOG(debug, "Broker startup, rejecting client connections."); shared_ptr excluder(new BackupConnectionExcluder); observer->setObserver(excluder, "Backup: "); broker.getConnectionObservers().add(observer); @@ -93,7 +93,7 @@ void HaBroker::initialize() { broker.getPort(broker::Broker::TCP_TRANSPORT) ) ); - QPID_LOG(notice, role->getLogPrefix() << "Initializing: " << membership.getInfo()); + QPID_LOG(notice, "Initializing: " << membership.getInfo()); // Set up the management object. ManagementAgent* ma = broker.getManagementAgent(); diff --git a/cpp/src/qpid/ha/QueueGuard.cpp b/cpp/src/qpid/ha/QueueGuard.cpp index 863b6779f8..d06d88ca29 100644 --- a/cpp/src/qpid/ha/QueueGuard.cpp +++ b/cpp/src/qpid/ha/QueueGuard.cpp @@ -53,7 +53,7 @@ QueueGuard::QueueGuard(broker::Queue& q, const BrokerInfo& info) : cancelled(false), queue(q), subscription(0) { std::ostringstream os; - os << "Primary guard " << queue.getName() << "@" << info.getLogId() << ": "; + os << "Primary guard " << queue.getName() << "@" << info << ": "; logPrefix = os.str(); observer.reset(new QueueObserver(*this)); queue.addObserver(observer); diff --git a/cpp/src/qpid/ha/RemoteBackup.cpp b/cpp/src/qpid/ha/RemoteBackup.cpp index 149ee3f85e..798ade3f73 100644 --- a/cpp/src/qpid/ha/RemoteBackup.cpp +++ b/cpp/src/qpid/ha/RemoteBackup.cpp @@ -35,9 +35,12 @@ using boost::bind; RemoteBackup::RemoteBackup( const BrokerInfo& info, broker::Connection* c -) : logPrefix("Primary: Remote backup "+info.getLogId()+": "), - brokerInfo(info), replicationTest(NONE), connection(c), reportedReady(false) -{} +) : brokerInfo(info), replicationTest(NONE), connection(c), reportedReady(false) +{ + std::ostringstream oss; + oss << "Primary: Remote backup " << info << ": "; + logPrefix = oss.str(); +} void RemoteBackup::setCatchupQueues(broker::QueueRegistry& queues, bool createGuards) { @@ -100,8 +103,12 @@ std::ostream& operator<<(std::ostream& o, const QueueSetPrinter& qp) { void RemoteBackup::ready(const QueuePtr& q) { catchupQueues.erase(q); - QPID_LOG(debug, logPrefix << "Caught up on queue: " << q->getName() << ", " - << catchupQueues.size() << " remain to catch up"); + if (catchupQueues.size()) { + QPID_LOG(debug, logPrefix << "Caught up on queue: " << q->getName() << ", " + << catchupQueues.size() << " remain to catch up"); + } + else + QPID_LOG(debug, logPrefix << "Caught up on queue: " << q->getName() ); } // Called via ConfigurationObserver::queueCreate and from catchupQueue diff --git a/cpp/src/qpid/ha/ReplicatingSubscription.cpp b/cpp/src/qpid/ha/ReplicatingSubscription.cpp index 72c3a7c7d9..933716e8fa 100644 --- a/cpp/src/qpid/ha/ReplicatingSubscription.cpp +++ b/cpp/src/qpid/ha/ReplicatingSubscription.cpp @@ -138,7 +138,7 @@ ReplicatingSubscription::ReplicatingSubscription( // Set a log prefix message that identifies the remote broker. ostringstream os; - os << "Primary " << queue->getName() << "@" << info.getLogId() << ": "; + os << "Primary " << queue->getName() << "@" << info << ": "; logPrefix = os.str(); // NOTE: Once the guard is attached we can have concurrent -- cgit v1.2.1