From c99d4d45ead8020517838b99e2106887701b17d7 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 12 Nov 2008 17:15:20 +0000 Subject: Cluster replicates queues/exchanges with same encode/decode functions as the store. Removed un-necessary heap allocation in QPID_LOG statements. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@713425 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/DumpClient.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'cpp/src/qpid/cluster/DumpClient.cpp') diff --git a/cpp/src/qpid/cluster/DumpClient.cpp b/cpp/src/qpid/cluster/DumpClient.cpp index 18db83ba87..3a4f217721 100644 --- a/cpp/src/qpid/cluster/DumpClient.cpp +++ b/cpp/src/qpid/cluster/DumpClient.cpp @@ -133,14 +133,20 @@ void DumpClient::run() { delete this; } +namespace { +template std::string encode(const T& t) { + std::string encoded; + encoded.resize(t.encodedSize()); + framing::Buffer buf(const_cast(encoded.data()), encoded.size()); + t.encode(buf); + return encoded; +} +} // namespace + void DumpClient::dumpExchange(const boost::shared_ptr& ex) { - session.exchangeDeclare( - ex->getName(), ex->getType(), - ex->getAlternate() ? ex->getAlternate()->getName() : std::string(), - arg::passive=false, - arg::durable=ex->isDurable(), - arg::autoDelete=false, - arg::arguments=ex->getArgs()); + QPID_LOG(debug, dumperId << " dumping exchange " << ex->getName()); + ClusterConnectionProxy proxy(session); + proxy.exchange(encode(*ex)); } /** Bind a queue to the dump exchange and dump messges to it @@ -181,14 +187,9 @@ class MessageDumper { void DumpClient::dumpQueue(const boost::shared_ptr& q) { - session.queueDeclare( - q->getName(), - q->getAlternateExchange() ? q->getAlternateExchange()->getName() : std::string(), - arg::passive=false, - arg::durable=q->isDurable(), - arg::exclusive=q->hasExclusiveConsumer(), - arg::autoDelete=q->isAutoDelete(), - arg::arguments=q->getSettings()); + QPID_LOG(debug, dumperId << " dumping queue " << q->getName()); + ClusterConnectionProxy proxy(session); + proxy.queue(encode(*q)); MessageDumper dumper(q->getName(), session); q->eachMessage(boost::bind(&MessageDumper::dumpQueuedMessage, &dumper, _1)); q->eachBinding(boost::bind(&DumpClient::dumpBinding, this, q->getName(), _1)); -- cgit v1.2.1