Running version 2.0.1 on OS X 10.5.7 with JDK 1.5, I observed the following
exception when to a
host that had been accidentally taken out of service:
java.net.SocketException: Host is down
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:464)
at net.spy.memcached.MemcachedConnection.<init>(MemcachedConnection.java:80)
at
net.spy.memcached.DefaultConnectionFactory.createConnection(DefaultConnectionFac
tory.java:8
4)
at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:146)
It looks like the 2.4.1 client resolves this by catching ConnectException and
queuing a reconnect,
in this code:
// Initially I had attempted to skirt this by queueing every
// connect, but it considerably slowed down start time.
try {
if(ch.connect(sa)) {
getLogger().info("Connected to %s immediately", qa);
connected(qa);
} else {
getLogger().info("Added %s to connect queue", qa);
ops=SelectionKey.OP_CONNECT;
}
qa.setSk(ch.register(selector, ops, qa));
assert ch.isConnected()
|| qa.getSk().interestOps() == SelectionKey.OP_CONNECT
: "Not connected, and not wanting to connect";
} catch(ConnectException e) {
queueReconnect(qa);
}
connections.add(qa);
Given the stack trace I observed, the catch of ConnectException should cast a
slightly larger net
and catch SocketException.
Original issue reported on code.google.com by kevin.la...@gmail.com on 18 Oct 2009 at 9:01
Original issue reported on code.google.com by
kevin.la...@gmail.com
on 18 Oct 2009 at 9:01