So I have two simple programs, one that writes to memached, the other
that reads (skipping imports)
public class PutInCache {
public static void main(String[] args) throws Exception {
XMemcachedClientBuilder builder = new XMemcachedClientBuilder
(AddrUtil.getAddresses("localhost:1624"));
MemcachedClient client = builder.build();
for (int i=0; i<1000; i++) {
try {
client.set("foo", 0, "Bar" + i);
System.out.println("Updated cache" + i);
}
catch (Exception e) {
System.out.println("Skipping update" + i);
}
Thread.sleep(500);
}
client.shutdown();
}
}
And the other that reads
public class ReadFromCache {
public static void main(String[] args) throws Exception {
XMemcachedClientBuilder builder = new XMemcachedClientBuilder
(AddrUtil.getAddresses("localhost:1624"));
MemcachedClient client = builder.build();
for (int i=0; i<1000; i++) {
try {
Object value = client.get("foo");
System.out.println(value);
}
catch (Exception e) {
System.out.println("no value");
}
Thread.sleep(500);
}
client.shutdown();
}
}
So I start these two programs and you can see memcached getting
updated and the values getting read. Then I kill memcached, as
expected the output switches to the 'catch' block codepath. Then I
restart memcached and the output stays 'stuck' on the catch block code
path. I only see logging at the moment I kill memecached. After that
flurry of logging I no longer see any output suggesting any retries.
The logging output I get when memcached is first killed is as
follows...
ul 21, 2009 10:53:15 AM
com.google.code.yanf4j.nio.impl.AbstractController start
WARNING: The Controller started at port 0 ...
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:
574)
at net.rubyeye.xmemcached.impl.MemcachedConnector.onConnect
(MemcachedConnector.java)
at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent
(Reactor.java)
at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java)
Jul 21, 2009 10:53:15 AM com.google.code.yanf4j.nio.impl.Reactor
dispatchEvent
SEVERE: java.io.IOException: Connect to localhost:1624 fail
java.io.IOException: Connect to localhost:1624 fail
at net.rubyeye.xmemcached.impl.MemcachedConnector.onConnect
(MemcachedConnector.java)
at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent
(Reactor.java)
at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java)
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:
574)
... 3 more
Jul 21, 2009 10:53:15 AM net.rubyeye.xmemcached.XMemcachedClient
connect
SEVERE: connect to localhost:1624 error
java.util.concurrent.ExecutionException: java.net.ConnectException:
Connection refused
at net.rubyeye.xmemcached.impl.MemcachedConnector$ConnectFuture.get
(MemcachedConnector.java)
at net.rubyeye.xmemcached.impl.MemcachedConnector$ConnectFuture.get
(MemcachedConnector.java)
at net.rubyeye.xmemcached.XMemcachedClient.connect
(XMemcachedClient.java)
at net.rubyeye.xmemcached.XMemcachedClient.<init>
(XMemcachedClient.java)
at net.rubyeye.xmemcached.XMemcachedClientBuilder.build
(XMemcachedClientBuilder.java)
at memcached.example.PutInCache.main(PutInCache.java:14)
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:
574)
at net.rubyeye.xmemcached.impl.MemcachedConnector.onConnect
(MemcachedConnector.java)
at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent
(Reactor.java)
at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java)
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:
574)
at net.rubyeye.xmemcached.impl.MemcachedConnector.onConnect
(MemcachedConnector.java)
at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent
(Reactor.java)
at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java)
Jul 21, 2009 10:53:15 AM net.rubyeye.xmemcached.XMemcachedClient
connect
SEVERE: Connect to localhost:1624 fail
java.util.concurrent.ExecutionException: java.net.ConnectException:
Connection refused
at net.rubyeye.xmemcached.impl.MemcachedConnector$ConnectFuture.get
(MemcachedConnector.java)
at net.rubyeye.xmemcached.impl.MemcachedConnector$ConnectFuture.get
(MemcachedConnector.java)
at net.rubyeye.xmemcached.XMemcachedClient.connect
(XMemcachedClient.java)
at net.rubyeye.xmemcached.XMemcachedClient.<init>
(XMemcachedClient.java)
at net.rubyeye.xmemcached.XMemcachedClientBuilder.build
(XMemcachedClientBuilder.java)
at memcached.example.PutInCache.main(PutInCache.java:14)
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:
574)
at net.rubyeye.xmemcached.impl.MemcachedConnector.onConnect
(MemcachedConnector.java)
at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent
(Reactor.java)
at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java)
Jul 21, 2009 10:53:15 AM com.google.code.yanf4j.nio.impl.Reactor
dispatchEvent
SEVERE: java.io.IOException: Connect to localhost:1624 fail
java.io.IOException: Connect to localhost:1624 fail
at net.rubyeye.xmemcached.impl.MemcachedConnector.onConnect
(MemcachedConnector.java)
at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent
(Reactor.java)
at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java)
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:
574)
... 3 more
Jul 21, 2009 10:53:15 AM net.rubyeye.xmemcached.impl.MemcachedConnector
$SessionMonitor run
WARNING: Try to reconnect to localhost:1624 for 1 times
these programs run for over 5 minutes each, so there's a fair amount
of time for the connection to reconnect...
Do you see anything in my configuration?
Thanks, for providing such great turn around support!
Bryant
On Jul 21, 8:36 am, dennis zhuang <
killme2...@gmail.com> wrote:
> In my test,xmemcached can heal the connection if you have restart
> memcached.You can find it in the log output when you have configured
> log4j.properties.I don't know what's the problem with your test
> program,maybe your test program have finished invoking functions before
> xmemcached heal connection?You should configure log for more information.
>
> 2009/7/21 Bryant <
publish...@myrete.com>