当我尝试使用 windows xp 而不是 linux 在 memcache.im 中设置密钥时,我的 java 代码给出了 ioexception 和 memcache 服务器重新连接。
代码 :
public class Memcache implements Serializable  {
    MemcachedClient client;
    public static final int EXP_TIME = 10;
    public static final String KEY = "spoon";
    public static void main(String[] args)throws IOException{
        Memcache temp=new Memcache();
        Dummy dummy= new Dummy("Hello World");
        try {
           temp.client = new MemcachedClient(new InetSocketAddress("localhost", 11211));
        } catch (IOException e) {
           e.printStackTrace();
           System.err.println("connection problem");
        }
        temp.obj=temp.client.getAvailableServers();
        System.out.println(temp.obj);
        temp.obj1=temp.client.getUnavailableServers();
        System.out.println(temp.obj1);
        temp.client.add(KEY, EXP_TIME, dummy);
        Object myObject=temp.client.get(KEY);
        System.out.println(myObject);
        temp.client.delete(KEY);
    }
}
我调试了代码,但是当它到达设置操作时,它使 IOException n 断开连接。
假人的代码是:
import java.io.Serializable;
public class Dummy implements Serializable {
    String one;
    public Dummy(String one){
        this.one=one;
    }
}
堆栈跟踪是:
2012-06-15 14:30:19.259 信息 net.spy.memcached.MemcachedConnection:添加 {QA sa=/10.2.200.104:11211,#Rops=0,#Wops=0,#iq=0,topRop=null, topWop=null, toWrite=0, Interest=0} 连接队列
2012-06-15 14:30:19.274 信息 net.spy.memcached.MemcachedConnection:sun.nio.ch.SelectionKeyImpl@7cbde6 的连接状态已更改
[/10.2.200.104:11211]
[]
2012-06-15 14:30:22.852 信息 net.spy.memcached.MemcachedConnection:由于 {QA sa=/10.2.200.104:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: set Key:spoon Flags: 1 Exp: 10 Data Length: 76, topWop=null, toWrite=0, Interest=1}
java.io.IOException:意外断开连接,将重新连接。
    在 net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:452)
    在 net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:380)
    在 net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:242)
    在 net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:833)
2012-06-15 14:30:22.852 警告 net.spy.memcached.MemcachedConnection:关闭并重新打开 {QA sa=/10.2.200.104:11211,#Rops=1,#Wops=0,#iq=0,topRop =Cmd:设置键:勺子标志:1 Exp:10 数据长度:76,topWop=null,toWrite=0,interested=1},尝试 0。
2012-06-15 14:30:22.852 警告 net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl:丢弃部分完成的操作:Cmd:设置键:勺子标志:1 Exp:10 数据长度:76
2012-06-15 14:30:24.868 信息 net.spy.memcached.MemcachedConnection:重新连接 {QA sa=/10.2.200.104:11211,#Rops=0,#Wops=0,#iq=0,topRop=null, topWop=null,toWrite=0,有兴趣=0}
2012-06-15 14:30:24.868 INFO net.spy.memcached.MemcachedConnection:sun.nio.ch.SelectionKeyImpl@113beb5 的连接状态已更改
2012-06-15 14:30:31.665 信息 net.spy.memcached.MemcachedConnection:由于 {QA sa=/10.2.200.104:11211、#Rops=1、#Wops=0、#iq=0、 topRop=Cmd:获取键:spoon Exp:0,topWop=null,toWrite=0,interested=1}
java.io.IOException:意外断开连接,将重新连接。
    在 net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:452)
    在 net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:380)
    在 net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:242)
    在 net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:833)
2012-06-15 14:30:31.665 警告 net.spy.memcached.MemcachedConnection:关闭并重新打开 {QA sa=/10.2.200.104:11211,#Rops=1,#Wops=0,#iq=0,topRop =Cmd: get Keys:spoon Exp: 0, topWop=null, toWrite=0, Interest=1},尝试0。
2012-06-15 14:30:31.665 警告 net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl:丢弃部分完成的操作:Cmd:获取密钥:勺子 Exp:0
2012-06-15 14:30:33.680 信息 net.spy.memcached.MemcachedConnection:重新连接 {QA sa=/10.2.200.104:11211,#Rops=0,#Wops=0,#iq=0,topRop=null, topWop=null,toWrite=0,有兴趣=0}
2012-06-15 14:30:33.680 信息 net.spy.memcached.MemcachedConnection:sun.nio.ch.SelectionKeyImpl@edf389 的连接状态已更改
线程“主”java.lang.RuntimeException 中的异常:等待值的异常
    在 net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1001)
    在 net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1018)
    在 ballydev.Memcache.main(Memcache.java:39)
引起:java.util.concurrent.ExecutionException:java.lang.RuntimeException:已取消
    在 net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:103)
    在 net.spy.memcached.internal.GetFuture.get(GetFuture.java:62)
    在 net.spy.memcached.MemcachedClient.get(MemcachedClient.java:997)
    ... 2 更多
引起:java.lang.RuntimeException:已取消
    ... 5 更多