INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=0.0.0.0/0.0.0.0:11211,}

2

I kept getting this annoying message every 30 seconds (dont intend to offend anyone here :))

2012-02-09 13:55:59.322 INFO net.spy.memcached.MemcachedConnection:  Reconnecting {QA sa=0.0.0.0/0.0.0.0:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
2012-02-09 13:55:59.323 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@15f0688
2012-02-09 13:55:59.323 INFO net.spy.memcached.MemcachedConnection:  Reconnecting due to failure to connect to {QA sa=0.0.0.0/0.0.0.0:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connection refused
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:592)
	at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:313)
	at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:199)
	at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:1622)
2012-02-09 13:55:59.324 WARN net.spy.memcached.MemcachedConnection:  Closing, and reopening {QA sa=0.0.0.0/0.0.0.0:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}, attempt 26.

This is what I had running on my setup. All on the localhost
Server

prompt$ /usr/bin/memcached -m 64 -U 11211 -p 11211 -l 127.0.0.1
ps -ef | grep memcached shows
username  12029  2961  0 13:32 pts/2    00:00:00 /usr/bin/memcached -m 64 -U 11211 -p 11211 -l 127.0.0.1
sudo netstat -anp | grep 11211 shows
prompt$ sudo netstat -anp | grep 11211
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      12029/memcached 
tcp        0      0 127.0.0.1:11211         127.0.0.1:36642         ESTABLISHED 12029/memcached 
tcp6       0      0 127.0.0.1:36642         127.0.0.1:11211         ESTABLISHED 13941/java      
udp        0      0 127.0.0.1:11211         0.0.0.0:*                           12029/memcached 
unix  2      [ ACC ]     STREAM     LISTENING     11211    1821/dbus-daemon    @/tmp/dbus-TelpJZAoJl

Client

private MyClass() throws UnknownHostException, IOException {
	super(new InetSocketAddress("127.0.0.1", 11211));
	}

Results
I am able to set/get with no issues at all. My cache populates and work perfectly well. Just that warning/info message on log4j.

To fix this, I loaded the memcaced without “-l 127.0.0.1”

prompt>$ /usr/bin/memcached -m 64 -U 11211 -p 11211

My memcached still works well, without that message.

Include Log4j to my java project in eclipse

0

Well, like any programmer, I started with System.out.println’s for my logging and debugging needs. But only after I wrote myself a set of test cases. As you assumed right I ran out of thought process to organize my log’s very soon. As I was debugging stuff, I realized that my logs not only need to be categorized they need to be “intended”. When I “intended” I meant that sometime in future I want to be able to say something like “show me logs of all threading happening on my server”. So I know who is using my threads, when and is some client eating up my threadpool ? I also want to be able to drive down to the client level to figure out who exactly is eating it up.

The that is “important” for me, not urgent as yet. As any good time management advice will tell you, to focus on your urgent and important. So currently I need to be able to just organize my logs into the regular 4 levels, fatal, error, info and debug. So here goes. I choose Log4j for many reasons
– Tried and tested
– A lot of help on the net for log4j
– Best Practices are already identified, documented and followed (http://juliusdavies.ca/logging.html)
/**
* Logger Design
* Should be greppable
* Separate files for separate areas of interest
* Device/Connection/StreamManager threads
* Stream Management
* Request Issues
* Database Issues
* Memcached Issues
* TimeStamps with timezones from server and client and down to nanoseconds (yyyy-MM-dd/HH:mm:ss.SSS/zzz) Java does not support nanoseconds
* Identity (who tried to do what)
* Single Line (no multiple line’s. Except, exceptions
* When did user last login ?
* Error reported to user “must” be logged (exact Error)
* Every Class to have
* public static final Logger log = Logger.getLogger(MyClass.class) ;
*/

I did encounter some trouble starting up. So this blog will help those who want to startup too. The the above advice, I also did the following
– In my main method I did
PropertyConfigurator.configure(“log4j.properties”);
– Added log.properties under the same level as src directory on my eclipse project
Project
src
….
log4j.properties
– My log4j.properties contents are
log4j.rootLogger=DEBUG, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x – %m%n

#log4j.appender.A1.all=\u001B[1;37m
#log4j.appender.A1.fatal=\u001B[1;31m
#log4j.appender.A1.error=\u001B[0;31m
#log4j.appender.A1.warn=\u001B[1;33m
#log4j.appender.A1.info=\u001B[0;37m
#log4j.appender.A1.debug=\u001B[0;36m
#log4j.appender.A1.stacktrace=\u001B[0;31m
#log4j.appender.A1.defaultcolor=\u001B[1;37m

#AnsiColorLogger.ERROR_COLOR=2;31
#AnsiColorLogger.WARNING_COLOR=2;35
#AnsiColorLogger.INFO_COLOR=2;36
#AnsiColorLogger.VERBOSE_COLOR=2;32
#AnsiColorLogger.DEBUG_COLOR=2;34
#
#AnsiColorLogger.*=Attribute;Foreground;Background
#
#Attribute is one of the following:
#0 -> Reset All Attributes (return to normal mode)
#1 -> Bright (Usually turns on BOLD)
#2 -> Dim
#3 -> Underline
#5 -> link
#7 -> Reverse
#8 -> Hidden
#
#Foreground is one of the following:
#30 -> Black
#31 -> Red
#32 -> Green
#33 -> Yellow
#34 -> Blue
#35 -> Magenta
#36 -> Cyan
#37 -> White
#
#Background is one of the following:
#40 -> Black
#41 -> Red
#42 -> Green
#43 -> Yellow
#44 -> Blue
#45 -> Magenta
#46 -> Cyan
#47 -> White
#org.apache.tools.ant.listener.AnsiColorLogger=.ERROR_COLOR=2;31
#org.apache.tools.ant.listener.AnsiColorLogger=.WARNING_COLOR=2;35
#org.apache.tools.ant.listener.AnsiColorLogger=.INFO_COLOR=2;36
#org.apache.tools.ant.listener.AnsiColorLogger=.VERBOSE_COLOR=2;32
#org.apache.tools.ant.listener.AnsiColorLogger=.DEBUG_COLOR=2;34

I am still trying to get colors in my log, but that does not work. When I get it up and running, I’ll edit this post with more. If you have a solution on this, please comment.