You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by br...@apache.org on 2010/11/16 19:25:50 UTC
svn commit: r1035727 - in /hadoop/zookeeper/trunk: ./
src/contrib/hedwig/client/src/main/cpp/
src/contrib/hedwig/client/src/main/cpp/lib/
src/contrib/hedwig/client/src/main/cpp/scripts/
src/contrib/hedwig/client/src/main/cpp/test/
Author: breed
Date: Tue Nov 16 18:25:49 2010
New Revision: 1035727
URL: http://svn.apache.org/viewvc?rev=1035727&view=rev
Log:
ZOOKEEPER-930. Hedwig c++ client uses a non thread safe logging library
Added:
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/scripts/log4cxx.conf
Removed:
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/scripts/log4cpp.conf
Modified:
hadoop/zookeeper/trunk/CHANGES.txt
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/configure.ac
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/channel.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/client.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/clientimpl.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/data.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/eventdispatcher.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/publisherimpl.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/subscriberimpl.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/util.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/main.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/publishtest.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/pubsubtest.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/servercontrol.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/subscribetest.cpp
hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/util.h
Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Nov 16 18:25:49 2010
@@ -151,6 +151,8 @@ BUGFIXES:
ZOOKEEPER-916. Problem receiving messages from subscribed channels in c++ client (ivan via breed)
+ ZOOKEEPER-930. Hedwig c++ client uses a non thread safe logging library (ivan via breed)
+
IMPROVEMENTS:
ZOOKEEPER-724. Improve junit test integration - log harness information
(phunt via mahadev)
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/configure.ac
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/configure.ac?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/configure.ac (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/configure.ac Tue Nov 16 18:25:49 2010
@@ -26,7 +26,7 @@ AC_LANG([C++])
AC_CONFIG_FILES([Makefile lib/Makefile test/Makefile hedwig-0.1.pc])
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
-PKG_CHECK_MODULES([DEPS], [log4cpp protobuf cppunit])
+PKG_CHECK_MODULES([DEPS], [liblog4cxx protobuf cppunit])
AX_BOOST_BASE
AX_BOOST_ASIO
AX_BOOST_THREAD
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/channel.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/channel.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/channel.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/channel.cpp Tue Nov 16 18:25:49 2010
@@ -35,10 +35,10 @@
#include "util.h"
#include "clientimpl.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
@@ -48,17 +48,13 @@ DuplexChannel::DuplexChannel(EventDispat
socket(dispatcher.getService()), instream(&in_buf), copy_buf(NULL), copy_buf_length(0),
state(UNINITIALISED), receiving(false), sending(false)
{
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Creating DuplexChannel(" << this << ")";
- }
+ LOG4CXX_DEBUG(logger, "Creating DuplexChannel(" << this << ")");
}
/*static*/ void DuplexChannel::connectCallbackHandler(DuplexChannelPtr channel,
const boost::system::error_code& error) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::connectCallbackHandler error(" << error
- << ") channel(" << channel.get() << ")";
- }
+ LOG4CXX_DEBUG(logger,"DuplexChannel::connectCallbackHandler error(" << error
+ << ") channel(" << channel.get() << ")");
if (error) {
channel->channelDisconnected(ChannelConnectException());
@@ -97,14 +93,12 @@ void DuplexChannel::connect() {
std::size_t message_size,
const boost::system::error_code& error,
std::size_t bytes_transferred) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::messageReadCallbackHandler " << error << ", "
- << bytes_transferred << " channel(" << channel.get() << ")";
- }
-
+ LOG4CXX_DEBUG(logger, "DuplexChannel::messageReadCallbackHandler " << error << ", "
+ << bytes_transferred << " channel(" << channel.get() << ")");
+
if (error) {
- LOG.errorStream() << "Invalid read error (" << error << ") bytes_transferred ("
- << bytes_transferred << ") channel(" << channel.get() << ")";
+ LOG4CXX_ERROR(logger, "Invalid read error (" << error << ") bytes_transferred ("
+ << bytes_transferred << ") channel(" << channel.get() << ")");
channel->channelDisconnected(ChannelReadException());
return;
}
@@ -113,7 +107,7 @@ void DuplexChannel::connect() {
channel->copy_buf_length = message_size;
channel->copy_buf = (char*)realloc(channel->copy_buf, channel->copy_buf_length);
if (channel->copy_buf == NULL) {
- LOG.errorStream() << "Error allocating buffer. channel(" << channel.get() << ")";
+ LOG4CXX_ERROR(logger, "Error allocating buffer. channel(" << channel.get() << ")");
return;
}
}
@@ -124,13 +118,13 @@ void DuplexChannel::connect() {
if (!err) {
- LOG.errorStream() << "Error parsing message. channel(" << channel.get() << ")";
+ LOG4CXX_ERROR(logger, "Error parsing message. channel(" << channel.get() << ")");
channel->channelDisconnected(ChannelReadException());
return;
- } else if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "channel(" << channel.get() << ") : " << channel->in_buf.size()
- << " bytes left in buffer";
+ } else {
+ LOG4CXX_DEBUG(logger, "channel(" << channel.get() << ") : " << channel->in_buf.size()
+ << " bytes left in buffer");
}
ChannelHandlerPtr h;
@@ -150,21 +144,19 @@ void DuplexChannel::connect() {
/*static*/ void DuplexChannel::sizeReadCallbackHandler(DuplexChannelPtr channel,
const boost::system::error_code& error,
std::size_t bytes_transferred) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::sizeReadCallbackHandler " << error << ", "
- << bytes_transferred << " channel(" << channel.get() << ")";
- }
+ LOG4CXX_DEBUG(logger, "DuplexChannel::sizeReadCallbackHandler " << error << ", "
+ << bytes_transferred << " channel(" << channel.get() << ")");
if (error) {
- LOG.errorStream() << "Invalid read error (" << error << ") bytes_transferred ("
- << bytes_transferred << ") channel(" << channel.get() << ")";
+ LOG4CXX_ERROR(logger, "Invalid read error (" << error << ") bytes_transferred ("
+ << bytes_transferred << ") channel(" << channel.get() << ")");
channel->channelDisconnected(ChannelReadException());
return;
}
if (channel->in_buf.size() < sizeof(uint32_t)) {
- LOG.errorStream() << "Not enough data in stream. Must have been an error reading. "
- << " Closing channel(" << channel.get() << ")";
+ LOG4CXX_ERROR(logger, "Not enough data in stream. Must have been an error reading. "
+ << " Closing channel(" << channel.get() << ")");
channel->channelDisconnected(ChannelReadException());
return;
}
@@ -175,10 +167,8 @@ void DuplexChannel::connect() {
size = ntohl(size);
int toread = size - channel->in_buf.size();
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << " size of incoming message " << size << ", currently in buffer "
- << channel->in_buf.size() << " channel(" << channel.get() << ")";
- }
+ LOG4CXX_DEBUG(logger, " size of incoming message " << size << ", currently in buffer "
+ << channel->in_buf.size() << " channel(" << channel.get() << ")");
if (toread <= 0) {
DuplexChannel::messageReadCallbackHandler(channel, size, error, 0);
} else {
@@ -197,11 +187,9 @@ void DuplexChannel::connect() {
}
int toread = sizeof(uint32_t) - channel->in_buf.size();
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << " size of incoming message " << sizeof(uint32_t)
- << ", currently in buffer " << channel->in_buf.size()
- << " channel(" << channel.get() << ")";
- }
+ LOG4CXX_DEBUG(logger, " size of incoming message " << sizeof(uint32_t)
+ << ", currently in buffer " << channel->in_buf.size()
+ << " channel(" << channel.get() << ")");
if (toread < 0) {
DuplexChannel::sizeReadCallbackHandler(channel, boost::system::error_code(), 0);
@@ -217,10 +205,8 @@ void DuplexChannel::connect() {
}
void DuplexChannel::startReceiving() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::startReceiving channel(" << this << ") currently receiving = " << receiving;
- }
-
+ LOG4CXX_DEBUG(logger, "DuplexChannel::startReceiving channel(" << this << ") currently receiving = " << receiving);
+
boost::lock_guard<boost::mutex> lock(receiving_lock);
if (receiving) {
return;
@@ -235,10 +221,8 @@ bool DuplexChannel::isReceiving() {
}
void DuplexChannel::stopReceiving() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::stopReceiving channel(" << this << ")";
- }
-
+ LOG4CXX_DEBUG(logger, "DuplexChannel::stopReceiving channel(" << this << ")");
+
boost::lock_guard<boost::mutex> lock(receiving_lock);
receiving = false;
}
@@ -255,10 +239,8 @@ void DuplexChannel::startSending() {
if (sending) {
return;
}
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::startSending channel(" << this << ")";
- }
-
+ LOG4CXX_DEBUG(logger, "DuplexChannel::startSending channel(" << this << ")");
+
WriteRequest w;
{
boost::lock_guard<boost::mutex> lock(write_lock);
@@ -320,10 +302,8 @@ void DuplexChannel::channelDisconnected(
}
void DuplexChannel::kill() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Killing duplex channel (" << this << ")";
- }
-
+ LOG4CXX_DEBUG(logger, "Killing duplex channel (" << this << ")");
+
bool connected = false;
{
boost::shared_lock<boost::shared_mutex> statelock(state_lock);
@@ -349,18 +329,14 @@ DuplexChannel::~DuplexChannel() {
copy_buf = NULL;
copy_buf_length = 0;
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Destroying DuplexChannel(" << this << ")";
- }
+ LOG4CXX_DEBUG(logger, "Destroying DuplexChannel(" << this << ")");
}
/*static*/ void DuplexChannel::writeCallbackHandler(DuplexChannelPtr channel, OperationCallbackPtr callback,
const boost::system::error_code& error,
std::size_t bytes_transferred) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::writeCallbackHandler " << error << ", "
- << bytes_transferred << " channel(" << channel.get() << ")";
- }
+ LOG4CXX_DEBUG(logger, "DuplexChannel::writeCallbackHandler " << error << ", "
+ << bytes_transferred << " channel(" << channel.get() << ")");
if (error) {
callback->operationFailed(ChannelWriteException());
@@ -381,17 +357,15 @@ DuplexChannel::~DuplexChannel() {
}
void DuplexChannel::writeRequest(const PubSubRequestPtr& m, const OperationCallbackPtr& callback) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "DuplexChannel::writeRequest channel(" << this << ") txnid("
- << m->txnid() << ") shouldClaim("<< m->has_shouldclaim() << ", "
- << m->shouldclaim() << ")";
- }
+ LOG4CXX_DEBUG(logger, "DuplexChannel::writeRequest channel(" << this << ") txnid("
+ << m->txnid() << ") shouldClaim("<< m->has_shouldclaim() << ", "
+ << m->shouldclaim() << ")");
{
boost::shared_lock<boost::shared_mutex> lock(state_lock);
if (state != CONNECTED && state != CONNECTING) {
- LOG.errorStream() << "Tried to write transaction [" << m->txnid() << "] to a channel ["
- << this << "] which is " << (state == DEAD ? "DEAD" : "UNINITIALISED");
+ LOG4CXX_ERROR(logger,"Tried to write transaction [" << m->txnid() << "] to a channel ["
+ << this << "] which is " << (state == DEAD ? "DEAD" : "UNINITIALISED"));
callback->operationFailed(UninitialisedChannelException());
}
}
@@ -409,9 +383,8 @@ void DuplexChannel::writeRequest(const P
Store the transaction data for a request.
*/
void DuplexChannel::storeTransaction(const PubSubDataPtr& data) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Storing txnid(" << data->getTxnId() << ") for channel(" << this << ")";
- }
+ LOG4CXX_DEBUG(logger, "Storing txnid(" << data->getTxnId() << ") for channel(" << this << ")");
+
boost::lock_guard<boost::mutex> lock(txnid2data_lock);
txnid2data[data->getTxnId()] = data;
}
@@ -425,8 +398,8 @@ PubSubDataPtr DuplexChannel::retrieveTra
PubSubDataPtr data = txnid2data[txnid];
txnid2data.erase(txnid);
if (data == NULL) {
- LOG.errorStream() << "Transaction txnid(" << txnid
- << ") doesn't exist in channel (" << this << ")";
+ LOG4CXX_ERROR(logger, "Transaction txnid(" << txnid
+ << ") doesn't exist in channel (" << this << ")");
}
return data;
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/client.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/client.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/client.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/client.cpp Tue Nov 16 18:25:49 2010
@@ -20,9 +20,9 @@
#include <memory>
#include "clientimpl.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
@@ -34,9 +34,8 @@ const std::string Configuration::RECONNE
const std::string Configuration::SYNC_REQUEST_TIMEOUT = "hedwig.cpp.sync_request_timeout";
Client::Client(const Configuration& conf) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Client::Client (" << this << ")";
- }
+ LOG4CXX_DEBUG(logger, "Client::Client (" << this << ")");
+
clientimpl = ClientImpl::Create( conf );
}
@@ -49,9 +48,7 @@ Publisher& Client::getPublisher() {
}
Client::~Client() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Client::~Client (" << this << ")";
- }
+ LOG4CXX_DEBUG(logger, "Client::~Client (" << this << ")");
clientimpl->Destroy();
}
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/clientimpl.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/clientimpl.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/clientimpl.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/clientimpl.cpp Tue Nov 16 18:25:49 2010
@@ -19,9 +19,9 @@
#include "channel.h"
#include "publisherimpl.h"
#include "subscriberimpl.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
@@ -31,7 +31,7 @@ void SyncOperationCallback::wait() {
boost::unique_lock<boost::mutex> lock(mut);
while(response==PENDING) {
if (cond.timed_wait(lock, boost::posix_time::milliseconds(timeout)) == false) {
- LOG.errorStream() << "Timeout waiting for operation to complete " << this;
+ LOG4CXX_ERROR(logger, "Timeout waiting for operation to complete " << this);
response = TIMEOUT;
}
@@ -40,7 +40,7 @@ void SyncOperationCallback::wait() {
void SyncOperationCallback::operationComplete() {
if (response == TIMEOUT) {
- LOG.errorStream() << "operationCompleted successfully after timeout " << this;
+ LOG4CXX_ERROR(logger, "operationCompleted successfully after timeout " << this);
return;
}
@@ -53,7 +53,7 @@ void SyncOperationCallback::operationCom
void SyncOperationCallback::operationFailed(const std::exception& exception) {
if (response == TIMEOUT) {
- LOG.errorStream() << "operationCompleted unsuccessfully after timeout " << this;
+ LOG4CXX_ERROR(logger, "operationCompleted unsuccessfully after timeout " << this);
return;
}
@@ -105,10 +105,10 @@ HedwigClientChannelHandler::HedwigClient
}
void HedwigClientChannelHandler::messageReceived(const DuplexChannelPtr& channel, const PubSubResponsePtr& m) {
- LOG.debugStream() << "Message received txnid(" << m->txnid() << ") status("
- << m->statuscode() << ")";
+ LOG4CXX_DEBUG(logger, "Message received txnid(" << m->txnid() << ") status("
+ << m->statuscode() << ")");
if (m->has_message()) {
- LOG.errorStream() << "Subscription response, ignore for now";
+ LOG4CXX_ERROR(logger, "Subscription response, ignore for now");
return;
}
@@ -134,7 +134,7 @@ void HedwigClientChannelHandler::message
client->getSubscriberImpl().messageHandler(m, data);
break;
default:
- LOG.errorStream() << "Unimplemented request type " << data->getType();
+ LOG4CXX_ERROR(logger, "Unimplemented request type " << data->getType());
break;
}
}
@@ -145,13 +145,13 @@ void HedwigClientChannelHandler::channel
}
void HedwigClientChannelHandler::channelDisconnected(const DuplexChannelPtr& channel, const std::exception& e) {
- LOG.errorStream() << "Channel disconnected";
+ LOG4CXX_ERROR(logger, "Channel disconnected");
client->channelDied(channel);
}
void HedwigClientChannelHandler::exceptionOccurred(const DuplexChannelPtr& channel, const std::exception& e) {
- LOG.errorStream() << "Exception occurred" << e.what();
+ LOG4CXX_ERROR(logger, "Exception occurred" << e.what());
}
ClientTxnCounter::ClientTxnCounter() : counter(0)
@@ -176,18 +176,15 @@ long ClientTxnCounter::next() { // woul
ClientImplPtr ClientImpl::Create(const Configuration& conf) {
ClientImplPtr impl(new ClientImpl(conf));
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Creating Clientimpl " << impl;
- }
+ LOG4CXX_DEBUG(logger, "Creating Clientimpl " << impl);
+
impl->dispatcher.start();
return impl;
}
void ClientImpl::Destroy() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "destroying Clientimpl " << this;
- }
+ LOG4CXX_DEBUG(logger, "destroying Clientimpl " << this);
dispatcher.stop();
{
@@ -255,16 +252,14 @@ void ClientImpl::redirectRequest(const D
HostAddress h = HostAddress::fromString(response->statusmsg());
if (data->hasTriedServer(h)) {
- LOG.errorStream() << "We've been told to try request [" << data->getTxnId() << "] with ["
- << h.getAddressString()<< "] by " << oldhost.getAddressString()
- << " but we've already tried that. Failing operation";
+ LOG4CXX_ERROR(logger, "We've been told to try request [" << data->getTxnId() << "] with ["
+ << h.getAddressString()<< "] by " << oldhost.getAddressString()
+ << " but we've already tried that. Failing operation");
data->getCallback()->operationFailed(InvalidRedirectException());
return;
}
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "We've been told [" << data->getTopic() << "] is on [" << h.getAddressString()
- << "] by [" << oldhost.getAddressString() << "]. Redirecting request " << data->getTxnId();
- }
+ LOG4CXX_DEBUG(logger, "We've been told [" << data->getTopic() << "] is on [" << h.getAddressString()
+ << "] by [" << oldhost.getAddressString() << "]. Redirecting request " << data->getTxnId());
data->setShouldClaim(true);
setHostForTopic(data->getTopic(), h);
@@ -289,9 +284,7 @@ void ClientImpl::redirectRequest(const D
}
ClientImpl::~ClientImpl() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "deleting Clientimpl " << this;
- }
+ LOG4CXX_DEBUG(logger, "deleting Clientimpl " << this);
}
DuplexChannelPtr ClientImpl::createChannel(const std::string& topic, const ChannelHandlerPtr& handler) {
@@ -313,9 +306,7 @@ DuplexChannelPtr ClientImpl::createChann
channel->connect();
allchannels.insert(channel);
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "(create) All channels size: " << allchannels.size();
- }
+ LOG4CXX_DEBUG(logger, "(create) All channels size: " << allchannels.size());
return channel;
}
@@ -329,9 +320,7 @@ DuplexChannelPtr ClientImpl::getChannel(
DuplexChannelPtr channel = host2channel[addr];
if (channel.get() == 0) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << " No channel for topic, creating new channel.get() " << channel.get() << " addr " << addr.getAddressString();
- }
+ LOG4CXX_DEBUG(logger, " No channel for topic, creating new channel.get() " << channel.get() << " addr " << addr.getAddressString());
ChannelHandlerPtr handler(new HedwigClientChannelHandler(shared_from_this()));
channel = createChannel(topic, handler);
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/data.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/data.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/data.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/data.cpp Tue Nov 16 18:25:49 2010
@@ -19,9 +19,9 @@
#include <hedwig/protocol.h>
#include "data.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
@@ -103,37 +103,30 @@ const PubSubRequestPtr PubSubData::getRe
request->set_topic(topic);
if (type == PUBLISH) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Creating publish request";
- }
+ LOG4CXX_DEBUG(logger, "Creating publish request");
+
Hedwig::PublishRequest* pubreq = request->mutable_publishrequest();
Hedwig::Message* msg = pubreq->mutable_msg();
msg->set_body(body);
} else if (type == SUBSCRIBE) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Creating subscribe request";
- }
+ LOG4CXX_DEBUG(logger, "Creating subscribe request");
Hedwig::SubscribeRequest* subreq = request->mutable_subscriberequest();
subreq->set_subscriberid(subscriberid);
subreq->set_createorattach(mode);
} else if (type == CONSUME) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Creating consume request";
- }
+ LOG4CXX_DEBUG(logger, "Creating consume request");
Hedwig::ConsumeRequest* conreq = request->mutable_consumerequest();
conreq->set_subscriberid(subscriberid);
conreq->mutable_msgid()->CopyFrom(msgid);
} else if (type == UNSUBSCRIBE) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Creating unsubscribe request";
- }
+ LOG4CXX_DEBUG(logger, "Creating unsubscribe request");
Hedwig::UnsubscribeRequest* unsubreq = request->mutable_unsubscriberequest();
unsubreq->set_subscriberid(subscriberid);
} else {
- LOG.errorStream() << "Tried to create a request message for the wrong type [" << type << "]";
+ LOG4CXX_ERROR(logger, "Tried to create a request message for the wrong type [" << type << "]");
throw UnknownRequestException();
}
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/eventdispatcher.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/eventdispatcher.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/eventdispatcher.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/eventdispatcher.cpp Tue Nov 16 18:25:49 2010
@@ -18,9 +18,9 @@
#include "eventdispatcher.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
@@ -28,21 +28,17 @@ EventDispatcher::EventDispatcher() : ser
}
void EventDispatcher::run_forever() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Starting event dispatcher";
- }
+ LOG4CXX_DEBUG(logger, "Starting event dispatcher");
while (true) {
try {
service.run();
break;
} catch (std::exception &e) {
- LOG.errorStream() << "Exception in dispatch handler. " << e.what();
+ LOG4CXX_ERROR(logger, "Exception in dispatch handler. " << e.what());
}
}
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Event dispatcher done";
- }
+ LOG4CXX_DEBUG(logger, "Event dispatcher done");
}
void EventDispatcher::start() {
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/publisherimpl.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/publisherimpl.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/publisherimpl.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/publisherimpl.cpp Tue Nov 16 18:25:49 2010
@@ -19,22 +19,20 @@
#include "publisherimpl.h"
#include "channel.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
PublishWriteCallback::PublishWriteCallback(const ClientImplPtr& client, const PubSubDataPtr& data) : client(client), data(data) {}
void PublishWriteCallback::operationComplete() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Successfully wrote transaction: " << data->getTxnId();
- }
+ LOG4CXX_DEBUG(logger, "Successfully wrote transaction: " << data->getTxnId());
}
void PublishWriteCallback::operationFailed(const std::exception& exception) {
- LOG.errorStream() << "Error writing to publisher " << exception.what();
+ LOG4CXX_ERROR(logger, "Error writing to publisher " << exception.what());
data->getCallback()->operationFailed(exception);
}
@@ -74,11 +72,11 @@ void PublisherImpl::messageHandler(const
txn->getCallback()->operationComplete();
break;
case SERVICE_DOWN:
- LOG.errorStream() << "Server responsed with SERVICE_DOWN for " << txn->getTxnId();
+ LOG4CXX_ERROR(logger, "Server responsed with SERVICE_DOWN for " << txn->getTxnId());
txn->getCallback()->operationFailed(ServiceDownException());
break;
default:
- LOG.errorStream() << "Unexpected response " << m->statuscode() << " for " << txn->getTxnId();
+ LOG4CXX_ERROR(logger, "Unexpected response " << m->statuscode() << " for " << txn->getTxnId());
txn->getCallback()->operationFailed(UnexpectedResponseException());
break;
}
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/subscriberimpl.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/subscriberimpl.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/subscriberimpl.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/subscriberimpl.cpp Tue Nov 16 18:25:49 2010
@@ -23,9 +23,9 @@
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
const int DEFAULT_MESSAGE_CONSUME_RETRY_WAIT_TIME = 5000;
@@ -36,13 +36,11 @@ const int DEFAULT_RECONNECT_SUBSCRIBE_RE
SubscriberWriteCallback::SubscriberWriteCallback(const ClientImplPtr& client, const PubSubDataPtr& data) : client(client), data(data) {}
void SubscriberWriteCallback::operationComplete() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Successfully wrote subscribe transaction: " << data->getTxnId();
- }
+ LOG4CXX_DEBUG(logger, "Successfully wrote subscribe transaction: " << data->getTxnId());
}
void SubscriberWriteCallback::operationFailed(const std::exception& exception) {
- LOG.errorStream() << "Error writing to subscriber " << exception.what();
+ LOG4CXX_ERROR(logger, "Error writing to subscriber " << exception.what());
//remove txn from channel pending list
data->getCallback()->operationFailed(exception);
@@ -52,9 +50,7 @@ void SubscriberWriteCallback::operationF
UnsubscribeWriteCallback::UnsubscribeWriteCallback(const ClientImplPtr& client, const PubSubDataPtr& data) : client(client), data(data) {}
void UnsubscribeWriteCallback::operationComplete() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Successfully wrote unsubscribe transaction: " << data->getTxnId();
- }
+ LOG4CXX_DEBUG(logger, "Successfully wrote unsubscribe transaction: " << data->getTxnId());
}
void UnsubscribeWriteCallback::operationFailed(const std::exception& exception) {
@@ -80,16 +76,14 @@ ConsumeWriteCallback::~ConsumeWriteCallb
void ConsumeWriteCallback::operationComplete() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Successfully wrote consume transaction: " << data->getTxnId();
- }
+ LOG4CXX_DEBUG(logger, "Successfully wrote consume transaction: " << data->getTxnId());
}
void ConsumeWriteCallback::operationFailed(const std::exception& exception) {
int retrywait = client->getConfiguration().getInt(Configuration::MESSAGE_CONSUME_RETRY_WAIT_TIME,
DEFAULT_MESSAGE_CONSUME_RETRY_WAIT_TIME);
- LOG.errorStream() << "Error writing consume transaction: " << data->getTxnId() << " error: " << exception.what()
- << " retrying in " << retrywait << " Microseconds";
+ LOG4CXX_ERROR(logger, "Error writing consume transaction: " << data->getTxnId() << " error: " << exception.what()
+ << " retrying in " << retrywait << " Microseconds");
boost::asio::deadline_timer t(client->getService(), boost::posix_time::milliseconds(retrywait));
@@ -104,9 +98,8 @@ SubscriberConsumeCallback::SubscriberCon
}
void SubscriberConsumeCallback::operationComplete() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "ConsumeCallback::operationComplete " << data->getTopic() << " - " << data->getSubscriberId();
- };
+ LOG4CXX_DEBUG(logger, "ConsumeCallback::operationComplete " << data->getTopic() << " - " << data->getSubscriberId());
+
client->getSubscriber().consume(data->getTopic(), data->getSubscriberId(), m->message().msgid());
}
@@ -120,13 +113,13 @@ void SubscriberConsumeCallback::operatio
}
void SubscriberConsumeCallback::operationFailed(const std::exception& exception) {
- LOG.errorStream() << "ConsumeCallback::operationFailed " << data->getTopic() << " - " << data->getSubscriberId();
+ LOG4CXX_ERROR(logger, "ConsumeCallback::operationFailed " << data->getTopic() << " - " << data->getSubscriberId());
int retrywait = client->getConfiguration().getInt(Configuration::SUBSCRIBER_CONSUME_RETRY_WAIT_TIME,
DEFAULT_SUBSCRIBER_CONSUME_RETRY_WAIT_TIME);
- LOG.errorStream() << "Error passing message to client transaction: " << data->getTxnId() << " error: " << exception.what()
- << " retrying in " << retrywait << " Microseconds";
+ LOG4CXX_ERROR(logger, "Error passing message to client transaction: " << data->getTxnId() << " error: " << exception.what()
+ << " retrying in " << retrywait << " Microseconds");
boost::asio::deadline_timer t(client->getService(), boost::posix_time::milliseconds(retrywait));
@@ -141,29 +134,22 @@ void SubscriberReconnectCallback::operat
}
void SubscriberReconnectCallback::operationFailed(const std::exception& exception) {
- LOG.errorStream() << "Error writing to new subscriber. Channel should pick this up disconnect the channel and try to connect again " << exception.what();
-
+ LOG4CXX_ERROR(logger, "Error writing to new subscriber. Channel should pick this up disconnect the channel and try to connect again " << exception.what());
}
SubscriberClientChannelHandler::SubscriberClientChannelHandler(const ClientImplPtr& client, SubscriberImpl& subscriber, const PubSubDataPtr& data)
: HedwigClientChannelHandler(client), subscriber(subscriber), origData(data), closed(false), should_wait(true) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Creating SubscriberClientChannelHandler " << this;
- }
+ LOG4CXX_DEBUG(logger, "Creating SubscriberClientChannelHandler " << this);
}
SubscriberClientChannelHandler::~SubscriberClientChannelHandler() {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Cleaning up SubscriberClientChannelHandler " << this;
- }
+ LOG4CXX_DEBUG(logger, "Cleaning up SubscriberClientChannelHandler " << this);
}
void SubscriberClientChannelHandler::messageReceived(const DuplexChannelPtr& channel, const PubSubResponsePtr& m) {
if (m->has_message()) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Message received (topic:" << origData->getTopic() << ", subscriberId:" << origData->getSubscriberId() << ")";
- }
+ LOG4CXX_DEBUG(logger, "Message received (topic:" << origData->getTopic() << ", subscriberId:" << origData->getSubscriberId() << ")");
if (this->handler.get()) {
OperationCallbackPtr callback(new SubscriberConsumeCallback(client, shared_from_this(), origData, m));
@@ -263,7 +249,7 @@ void SubscriberClientChannelHandler::sto
void SubscriberClientChannelHandler::handoverDelivery(const SubscriberClientChannelHandlerPtr& newHandler) {
- LOG.debugStream() << "Messages in queue " << queue.size();
+ LOG4CXX_DEBUG(logger, "Messages in queue " << queue.size());
MessageHandlerCallbackPtr handler = this->handler;
stopDelivery(); // resets old handler
newHandler->startDelivery(handler);
@@ -284,7 +270,7 @@ SubscriberImpl::SubscriberImpl(const Cli
SubscriberImpl::~SubscriberImpl()
{
- LOG.debugStream() << "deleting subscriber" << this;
+ LOG4CXX_DEBUG(logger, "deleting subscriber" << this);
}
@@ -322,9 +308,8 @@ void SubscriberImpl::doSubscribe(const D
oldhandler->handoverDelivery(handler);
}
topicsubscriber2handler[t] = handler;
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "Set topic subscriber for topic(" << data->getTopic() << ") subscriberId(" << data->getSubscriberId() << ") to " << handler.get() << " topicsubscriber2topic(" << &topicsubscriber2handler << ")";
- }
+
+ LOG4CXX_DEBUG(logger, "Set topic subscriber for topic(" << data->getTopic() << ") subscriberId(" << data->getSubscriberId() << ") to " << handler.get() << " topicsubscriber2topic(" << &topicsubscriber2handler << ")");
}
void SubscriberImpl::unsubscribe(const std::string& topic, const std::string& subscriberId) {
@@ -359,13 +344,13 @@ void SubscriberImpl::consume(const std::
SubscriberClientChannelHandlerPtr handler = topicsubscriber2handler[t];
if (handler.get() == 0) {
- LOG.errorStream() << "Cannot consume. Bad handler for topic(" << topic << ") subscriberId(" << subscriberId << ") topicsubscriber2topic(" << &topicsubscriber2handler << ")";
+ LOG4CXX_ERROR(logger, "Cannot consume. Bad handler for topic(" << topic << ") subscriberId(" << subscriberId << ") topicsubscriber2topic(" << &topicsubscriber2handler << ")");
return;
}
DuplexChannelPtr channel = handler->getChannel();
if (channel.get() == 0) {
- LOG.errorStream() << "Trying to consume a message on a topic/subscriber pair that don't have a channel. Something fishy going on. Topic: " << topic << " SubscriberId: " << subscriberId << " MessageSeqId: " << messageSeqId.localcomponent();
+ LOG4CXX_ERROR(logger, "Trying to consume a message on a topic/subscriber pair that don't have a channel. Something fishy going on. Topic: " << topic << " SubscriberId: " << subscriberId << " MessageSeqId: " << messageSeqId.localcomponent());
}
PubSubDataPtr data = PubSubData::forConsumeRequest(client->counter().next(), subscriberId, topic, messageSeqId);
@@ -380,7 +365,7 @@ void SubscriberImpl::startDelivery(const
SubscriberClientChannelHandlerPtr handler = topicsubscriber2handler[t];
if (handler.get() == 0) {
- LOG.errorStream() << "Trying to start deliver on a non existant handler topic = " << topic << ", subscriber = " << subscriberId;
+ LOG4CXX_ERROR(logger, "Trying to start deliver on a non existant handler topic = " << topic << ", subscriber = " << subscriberId);
}
handler->startDelivery(callback);
}
@@ -392,15 +377,14 @@ void SubscriberImpl::stopDelivery(const
SubscriberClientChannelHandlerPtr handler = topicsubscriber2handler[t];
if (handler.get() == 0) {
- LOG.errorStream() << "Trying to start deliver on a non existant handler topic = " << topic << ", subscriber = " << subscriberId;
+ LOG4CXX_ERROR(logger, "Trying to start deliver on a non existant handler topic = " << topic << ", subscriber = " << subscriberId);
}
handler->stopDelivery();
}
void SubscriberImpl::closeSubscription(const std::string& topic, const std::string& subscriberId) {
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "closeSubscription (" << topic << ", " << subscriberId << ")";
- }
+ LOG4CXX_DEBUG(logger, "closeSubscription (" << topic << ", " << subscriberId << ")");
+
TopicSubscriber t(topic, subscriberId);
SubscriberClientChannelHandlerPtr handler;
@@ -420,13 +404,12 @@ void SubscriberImpl::closeSubscription(c
*/
void SubscriberImpl::messageHandler(const PubSubResponsePtr& m, const PubSubDataPtr& txn) {
if (!txn.get()) {
- LOG.errorStream() << "Invalid transaction";
+ LOG4CXX_ERROR(logger, "Invalid transaction");
return;
}
- if (LOG.isDebugEnabled()) {
- LOG.debugStream() << "message received with status " << m->statuscode();
- }
+ LOG4CXX_DEBUG(logger, "message received with status " << m->statuscode());
+
switch (m->statuscode()) {
case SUCCESS:
txn->getCallback()->operationComplete();
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/util.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/util.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/util.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/lib/util.cpp Tue Nov 16 18:25:49 2010
@@ -21,11 +21,11 @@
#include <errno.h>
#include "util.h"
#include "channel.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
#include <sys/types.h>
#include <sys/socket.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwig."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace Hedwig;
@@ -75,7 +75,7 @@ void HostAddress::parse_string() {
char* url = strdup(address_str.c_str());
if (url == NULL) {
- LOG.errorStream() << "You seems to be out of memory";
+ LOG4CXX_ERROR(logger, "You seems to be out of memory");
throw OomException();
}
int port = DEFAULT_PORT;
@@ -93,7 +93,7 @@ void HostAddress::parse_string() {
sslport = strtol(sslcolon, NULL, 10);
if (sslport == 0) {
- LOG.errorStream() << "Invalid SSL port given: [" << sslcolon << "]";
+ LOG4CXX_ERROR(logger, "Invalid SSL port given: [" << sslcolon << "]");
free((void*)url);
throw InvalidPortException();
}
@@ -101,7 +101,7 @@ void HostAddress::parse_string() {
port = strtol(colon, NULL, 10);
if (port == 0) {
- LOG.errorStream() << "Invalid port given: [" << colon << "]";
+ LOG4CXX_ERROR(logger, "Invalid port given: [" << colon << "]");
free((void*)url);
throw InvalidPortException();
}
@@ -117,7 +117,7 @@ void HostAddress::parse_string() {
err = getaddrinfo(url, NULL, &hints, &addr);
if (err != 0) {
- LOG.errorStream() << "Couldn't resolve host [" << url << "]:" << hstrerror(err);
+ LOG4CXX_ERROR(logger, "Couldn't resolve host [" << url << "]:" << hstrerror(err));
free((void*)url);
throw HostResolutionException();
}
Added: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/scripts/log4cxx.conf
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/scripts/log4cxx.conf?rev=1035727&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/scripts/log4cxx.conf (added)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/scripts/log4cxx.conf Tue Nov 16 18:25:49 2010
@@ -0,0 +1,49 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# 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
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+log4j.appender.rootAppender=org.apache.log4j.ConsoleAppender
+log4j.appender.rootAppender.layout=org.apache.log4j.BasicLayout
+
+#log4j.appender.hedwig=org.apache.log4j.RollingFileAppender
+log4j.appender.hedwig=org.apache.log4j.ConsoleAppender
+#log4j.appender.hedwig.fileName=./testLog.log
+log4j.appender.hedwig.layout=org.apache.log4j.PatternLayout
+log4j.appender.hedwig.layout.ConversionPattern=[%d{%H:%M:%S.%l}] %t %c %p - %m%n
+log4j.appender.hedwig.layout=org.apache.log4j.PatternLayout
+log4j.appender.hedwig.layout.ConversionPattern=%.5m%n
+
+log4j.appender.hedwigtest=org.apache.log4j.ConsoleAppender
+#log4j.appender.hedwig.fileName=./testLog.log
+log4j.appender.hedwigtest.layout=org.apache.log4j.PatternLayout
+log4j.appender.hedwigtest.layout.ConversionPattern=[%d{%H:%M:%S.%l}] %c %p - %m%n
+log4j.appender.hedwigtest.layout=org.apache.log4j.PatternLayout
+log4j.appender.hedwigtest.layout.ConversionPattern=%.5m%n
+
+# category
+log4j.category.hedwig=DEBUG, hedwig
+log4j.rootCategory=DEBUG
+
+#log4j.category.hedwig.channel=ERROR
+log4j.category.hedwig.util=ERROR
+log4j.category.hedwigtest.servercontrol=ERROR
+
+log4j.category.hedwigtest=DEBUG, hedwigtest
+log4j.rootCategory=DEBUG
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/main.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/main.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/main.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/main.cpp Tue Nov 16 18:25:49 2010
@@ -20,8 +20,12 @@
#include <hedwig/protocol.h>
#include <hedwig/callback.h>
#include <iostream>
-#include <log4cpp/PropertyConfigurator.hh>
-#include <log4cpp/Category.hh>
+
+#include <log4cxx/logger.h>
+#include <log4cxx/basicconfigurator.h>
+#include <log4cxx/propertyconfigurator.h>
+#include <log4cxx/helpers/exception.h>
+
#include "servercontrol.h"
#include "util.h"
@@ -36,13 +40,12 @@ HedwigCppTextTestProgressListener gprogr
int main( int argc, char **argv)
{
try {
- if (getenv("LOG4CPP_CONF") == NULL) {
- std::cerr << "Set LOG4CPP_CONF in your environment to get logging." << std::endl;
+ if (getenv("LOG4CXX_CONF") == NULL) {
+ std::cerr << "Set LOG4CXX_CONF in your environment to get logging." << std::endl;
+ log4cxx::BasicConfigurator::configure();
} else {
- log4cpp::PropertyConfigurator::configure(getenv("LOG4CPP_CONF"));
+ log4cxx::PropertyConfigurator::configure(getenv("LOG4CXX_CONF"));
}
- } catch (log4cpp::ConfigureFailure &e) {
- std::cerr << "log4cpp configuration failure while loading : " << e.what() << std::endl;
} catch (std::exception &e) {
std::cerr << "exception caught while configuring log4cpp via : " << e.what() << std::endl;
} catch (...) {
@@ -71,7 +74,5 @@ int main( int argc, char **argv)
bool ret = runner.run(testPath);
google::protobuf::ShutdownProtobufLibrary();
- log4cpp::Category::shutdown();
-
return (ret == true) ? 0 : 1;
}
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/publishtest.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/publishtest.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/publishtest.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/publishtest.cpp Tue Nov 16 18:25:49 2010
@@ -25,12 +25,12 @@
#include <stdexcept>
#include <pthread.h>
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
#include "servercontrol.h"
#include "util.h"
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwigtest."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
using namespace CppUnit;
@@ -160,7 +160,7 @@ public:
delete conf;
}
/* void simplePublish() {
- LOG.debugStream() << ">>> simplePublish";
+ LOG4CXX_DEBUG(logger, ">>> simplePublish");
SimpleWaitCondition* cond = new SimpleWaitCondition();
Hedwig::Configuration* conf = new Configuration1();
@@ -170,15 +170,15 @@ public:
Hedwig::OperationCallbackPtr testcb(new TestCallback(cond));
pub.asyncPublish("foobar", "barfoo", testcb);
- LOG.debugStream() << "wait for response";
+ LOG4CXX_DEBUG(logger, "wait for response");
cond->wait();
delete cond;
- LOG.debugStream() << "got response";
+ LOG4CXX_DEBUG(logger, "got response");
delete client;
delete conf;
- LOG.debugStream() << "<<< simplePublish";
+ LOG4CXX_DEBUG(logger, "<<< simplePublish");
}
class MyMessageHandler : public Hedwig::MessageHandlerCallback {
@@ -186,8 +186,8 @@ public:
MyMessageHandler(SimpleWaitCondition* cond) : cond(cond) {}
void consume(const std::string& topic, const std::string& subscriberId, const Hedwig::Message& msg, Hedwig::OperationCallbackPtr& callback) {
- LOG.debugStream() << "Topic: " << topic << " subscriberId: " << subscriberId;
- LOG.debugStream() << " Message: " << msg.body();
+ LOG4CXX_DEBUG(logger, "Topic: " << topic << " subscriberId: " << subscriberId);
+ LOG4CXX_DEBUG(logger, " Message: " << msg.body());
callback->operationComplete();
cond->setTrue();
@@ -243,21 +243,21 @@ public:
Hedwig::Client* subscribeclient = new Hedwig::Client(*subscribeconf);
Hedwig::Subscriber& sub = subscribeclient->getSubscriber();
- LOG.debugStream() << "publishing";
+ LOG4CXX_DEBUG(logger, "publishing");
Hedwig::OperationCallbackPtr testcb2(new TestCallback(cond3));
pub.asyncPublish("foobar", "barfoo", testcb2);
cond3->wait();
- LOG.debugStream() << "Subscribing";
+ LOG4CXX_DEBUG(logger, "Subscribing");
std::string topic("foobar");
std::string sid("mysubscriber");
Hedwig::OperationCallbackPtr testcb1(new TestCallback(cond1));
sub.asyncSubscribe(topic, sid, Hedwig::SubscribeRequest::CREATE_OR_ATTACH, testcb1);
- LOG.debugStream() << "Starting delivery";
+ LOG4CXX_DEBUG(logger, "Starting delivery");
Hedwig::MessageHandlerCallbackPtr messagecb(new MyMessageHandler(cond2));
sub.startDelivery(topic, sid, messagecb);
- LOG.debugStream() << "Subscribe wait";
+ LOG4CXX_DEBUG(logger, "Subscribe wait");
cond1->wait();
Hedwig::OperationCallbackPtr testcb3(new TestCallback(cond4));
@@ -265,7 +265,7 @@ public:
cond4->wait();
- LOG.debugStream() << "Delivery wait";
+ LOG4CXX_DEBUG(logger, "Delivery wait");
cond2->wait();
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/pubsubtest.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/pubsubtest.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/pubsubtest.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/pubsubtest.cpp Tue Nov 16 18:25:49 2010
@@ -26,12 +26,12 @@
#include <stdexcept>
#include <pthread.h>
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
#include "servercontrol.h"
#include "util.h"
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwigtest."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
class PubSubTestSuite : public CppUnit::TestFixture {
private:
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/servercontrol.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/servercontrol.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/servercontrol.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/servercontrol.cpp Tue Nov 16 18:25:49 2010
@@ -28,14 +28,14 @@
#include "servercontrol.h"
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
#include "util.h"
#include <sstream>
#include <time.h>
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwigtest."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
extern HedwigCppTextTestProgressListener gprogress;
@@ -66,7 +66,7 @@ void TestServerImpl::kill() {
sstr << "KILL " << address << std::endl;
ServerControl::ServerResponse resp = sc.requestResponse(sstr.str());
if (resp.status != "OK") {
- LOG.errorStream() << "Error killing Server " << resp.message;
+ LOG4CXX_ERROR(logger, "Error killing Server " << resp.message);
throw ErrorKillingServerException();
}
}
@@ -79,7 +79,7 @@ ServerControl::ServerControl(int port) {
socketfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (-1 == socketfd) {
- LOG.errorStream() << "Couldn't create socket";
+ LOG4CXX_ERROR(logger, "Couldn't create socket");
throw CantConnectToServerControlDaemonException();
}
@@ -89,7 +89,7 @@ ServerControl::ServerControl(int port) {
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
if (-1 == ::connect(socketfd, (const sockaddr *)&addr, sizeof(struct sockaddr))) {
- LOG.errorStream() << "Couldn't connect socket";
+ LOG4CXX_ERROR(logger, "Couldn't connect socket");
close(socketfd);
throw CantConnectToServerControlDaemonException();
}
@@ -106,12 +106,12 @@ ServerControl::ServerResponse ServerCont
socketlock.lock();
char response[MAX_COMMAND_LN];
- LOG.debugStream() << "REQ: " << request.c_str() << " " << request.length();
+ LOG4CXX_DEBUG(logger, "REQ: " << request.c_str() << " " << request.length());
send(socketfd, request.c_str(), request.length(), 0);
memset(response, 0, MAX_COMMAND_LN);
recv(socketfd, response, MAX_COMMAND_LN, 0);
- LOG.debugStream() << "RESP: " << response;
+ LOG4CXX_DEBUG(logger, "RESP: " << response);
socketlock.unlock();
@@ -130,7 +130,7 @@ ServerControl::ServerResponse ServerCont
if (strlen(message) < 1) {
throw InvalidServerControlDaemonResponseException();
}
- LOG.debugStream() << "$" << message << "$";
+ LOG4CXX_DEBUG(logger, "$" << message << "$");
ServerControl::ServerResponse resp = { std::string(status), std::string(message) };
return resp;
}
@@ -140,13 +140,13 @@ TestServerPtr ServerControl::startZookee
sstr << "START ZOOKEEPER " << port << std::endl;
std::string req(sstr.str());
- LOG.debugStream() << req;
+ LOG4CXX_DEBUG(logger, req);
ServerControl::ServerResponse resp = requestResponse(req);
if (resp.status == "OK") {
return TestServerPtr(new TestServerImpl(resp.message, *this));
} else {
- LOG.errorStream() << "Error creating zookeeper on port " << port << " " << resp.message;
+ LOG4CXX_ERROR(logger, "Error creating zookeeper on port " << port << " " << resp.message);
throw ErrorCreatingServerException();
}
}
@@ -156,13 +156,13 @@ TestServerPtr ServerControl::startBookie
sstr << "START BOOKKEEPER " << port << " " << zookeeperServer->getAddress() << std::endl;
std::string req(sstr.str());
- LOG.debugStream() << req;
+ LOG4CXX_DEBUG(logger, req);
ServerControl::ServerResponse resp = requestResponse(req);
if (resp.status == "OK") {
return TestServerPtr(new TestServerImpl(resp.message, *this));
} else {
- LOG.errorStream() << "Error creating bookkeeper on port " << port << " " << resp.message;
+ LOG4CXX_ERROR(logger, "Error creating bookkeeper on port " << port << " " << resp.message);
throw ErrorCreatingServerException();
}
}
@@ -172,13 +172,13 @@ TestServerPtr ServerControl::startPubSub
sstr << "START HEDWIG " << port << " " << region << " " << zookeeperServer->getAddress() << std::endl;
std::string req(sstr.str());
- LOG.debugStream() << req;
+ LOG4CXX_DEBUG(logger, req);
ServerControl::ServerResponse resp = requestResponse(req);
if (resp.status == "OK") {
return TestServerPtr(new TestServerImpl(resp.message, *this));
} else {
- LOG.errorStream() << "Error creating hedwig on port " << port << " " << resp.message;
+ LOG4CXX_ERROR(logger, "Error creating hedwig on port " << port << " " << resp.message);
throw ErrorCreatingServerException();
}
}
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/subscribetest.cpp
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/subscribetest.cpp?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/subscribetest.cpp (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/subscribetest.cpp Tue Nov 16 18:25:49 2010
@@ -25,12 +25,12 @@
#include <stdexcept>
#include <pthread.h>
-#include <log4cpp/Category.hh>
+#include <log4cxx/logger.h>
#include "servercontrol.h"
#include "util.h"
-static log4cpp::Category &LOG = log4cpp::Category::getInstance("hedwigtest."__FILE__);
+static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("hedwig."__FILE__));
class SubscribeTestSuite : public CppUnit::TestFixture {
private:
Modified: hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/util.h
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/util.h?rev=1035727&r1=1035726&r2=1035727&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/util.h (original)
+++ hadoop/zookeeper/trunk/src/contrib/hedwig/client/src/main/cpp/test/util.h Tue Nov 16 18:25:49 2010
@@ -28,7 +28,9 @@
#include <cppunit/TestResult.h>
#include <cppunit/Test.h>
-static log4cpp::Category &UTILLOG = log4cpp::Category::getInstance("hedwigtest."__FILE__);
+#include <log4cxx/logger.h>
+
+static log4cxx::LoggerPtr utillogger(log4cxx::Logger::getLogger("hedwig."__FILE__));
class SimpleWaitCondition {
public:
@@ -73,14 +75,14 @@ public:
}
virtual void operationComplete() {
- UTILLOG.debugStream() << "operationComplete";
+ LOG4CXX_DEBUG(utillogger, "operationComplete");
cond->setSuccess(true);
cond->notify();
}
virtual void operationFailed(const std::exception& exception) {
- UTILLOG.debugStream() << "operationFailed: " << exception.what();
+ LOG4CXX_DEBUG(utillogger, "operationFailed: " << exception.what());
cond->setSuccess(false);
cond->notify();
}