java中memcached中set操作的IOException
当我尝试在memcache中设置密钥时,我的java代码给出了ioexception,memcache服务器重新连接。我使用的是windows xp而不是linux 代码:java中memcached中set操作的IOException,java,windows-xp,memcached,spymemcached,Java,Windows Xp,Memcached,Spymemcached,当我尝试在memcache中设置密钥时,我的java代码给出了ioexception,memcache服务器重新连接。我使用的是windows xp而不是linux 代码: public class Memcache implements Serializable { MemcachedClient client; public static final int EXP_TIME = 10; public static final String KEY = "spo
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);
}
}
我调试了代码,但当它达到set操作时,它给出了ion disconnected异常
假人代码为:
import java.io.Serializable;
public class Dummy implements Serializable {
String one;
public Dummy(String one){
this.one=one;
}
}
stacktrace是:
2012-06-15 14:30:19.259 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/10.2.200.104:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2012-06-15 14:30:19.274 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@7cbde6
[/10.2.200.104:11211]
[]
2012-06-15 14:30:22.852 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {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, interested=1}
java.io.IOException: Disconnected unexpected, will reconnect.
at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:452)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:380)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:242)
at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:833)
2012-06-15 14:30:22.852 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {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, interested=1}, attempt 0.
2012-06-15 14:30:22.852 WARN net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl: Discarding partially completed op: Cmd: set Key: spoon Flags: 1 Exp: 10 Data Length: 76
2012-06-15 14:30:24.868 INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=/10.2.200.104:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
2012-06-15 14:30:24.868 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@113beb5
2012-06-15 14:30:31.665 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {QA sa=/10.2.200.104:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: get Keys: spoon Exp: 0, topWop=null, toWrite=0, interested=1}
java.io.IOException: Disconnected unexpected, will reconnect.
at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:452)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:380)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:242)
at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:833)
2012-06-15 14:30:31.665 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=/10.2.200.104:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: get Keys: spoon Exp: 0, topWop=null, toWrite=0, interested=1}, attempt 0.
2012-06-15 14:30:31.665 WARN net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl: Discarding partially completed op: Cmd: get Keys: spoon Exp: 0
2012-06-15 14:30:33.680 INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=/10.2.200.104:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
2012-06-15 14:30:33.680 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@edf389
Exception in thread "main" java.lang.RuntimeException: Exception waiting for value
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1001)
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1018)
at ballydev.Memcache.main(Memcache.java:39)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Cancelled
at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:103)
at net.spy.memcached.internal.GetFuture.get(GetFuture.java:62)
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:997)
... 2 more
Caused by: java.lang.RuntimeException: Cancelled
... 5 more
2012-06-15 14:30:19.259 INFO net.spy.memcached.memcached连接:添加了{QA sa=/10.2.200.104:11211,#Rops=0,#Wops=0,#iq=0,topRop=null,topWop=null,toWrite=0,INTERGED=0}来连接队列
2012-06-15 14:30:19.274 INFO net.spy.memcached.memcached连接:sun.nio.ch的连接状态已更改。SelectionKeyImpl@7cbde6
[/10.2.200.104:11211]
[]
2012-06-15 14:30:22.852 INFO net.spy.memcached.memcached连接:由于{QA sa=/10.2.200.104:11211,#Rops=1,#Wops=0,#iq=0,topRop=Cmd:set Key:spoon标志:1 Exp:10数据长度: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 WARN net.spy.memcached.memcached连接:关闭并重新打开{QA sa=/10.2.200.104:11211,#Rops=1,#Wops=0,#iq=0,topRop=Cmd:set Key:spoon标志:1 Exp:10数据长度:76,topWop=null,toWrite=0,interest=1},尝试0。
2012-06-15 14:30:22.852警告net.spy.memcached.protocol.ascii.ascimemcachednodeimpl:丢弃部分完成的op:Cmd:set Key:spoon标志:1 Exp:10数据长度:76
2012-06-15 14:30:24.868 INFO net.spy.memcached.memcached连接:重新连接{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:24.868 INFO net.spy.memcached.memcached连接:sun.nio.ch的连接状态已更改。SelectionKeyImpl@113beb5
2012-06-15 14:30:31.665 INFO net.spy.memcached.memcached连接:由于{QA sa=/10.2.200.104:11211,#Rops=1,#Wops=0,#iq=0,topRop=Cmd:get键:spoon Exp:0,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:31.665警告net.spy.memcached.memcached连接:关闭并重新打开{QA sa=/10.2.200.104:11211,#Rops=1,#Wops=0,#iq=0,topRop=Cmd:get键:spoon Exp:0,topWop=null,toWrite=0,interest=1},尝试0。
2012-06-15 14:30:31.665警告net.spy.memcached.protocol.ascii.ascimemcachednodeimpl:丢弃部分完成的op:Cmd:get key:spoon Exp:0
2012-06-15 14:30:33.680 INFO net.spy.memcached.memcached连接:重新连接{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:33.680 INFO net.spy.memcached.memcached连接:sun.nio.ch的连接状态已更改。SelectionKeyImpl@edf389
线程“main”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)
... 还有两个
原因:java.lang.RuntimeException:已取消
... 还有5个
要调试此问题,请尝试从发起请求的服务器远程登录到memcached。如果memcached启动时明确提及ip地址,则它可以拒绝与其他主机的连接。若要调试此问题,请尝试从发起请求的服务器远程登录memcached。如果memcached启动时明确提及ip地址,则它可以拒绝与其他主机的连接。您有备用stacktrace吗?在我看来,这似乎是防火墙/防病毒问题。试着禁用它。我做不到。。组策略…可能是我应该尝试关闭11211端口上的防火墙…您在Windows上使用什么memcached服务器?你如何运行它?你有备用的stacktrace吗?在我看来这是防火墙/防病毒问题。试着禁用它。我做不到。。组策略…可能是我应该尝试关闭11211端口上的防火墙…您在Windows上使用什么memcached服务器?如何运行它?我尝试了telnet localhost 11211命令,但命令提示符显示空白屏幕。。。即使我在cmd上键入了一些字符,光标也会空白移动…当我在cmd上键入任何字符时,都不会出现任何结果。。。当我按enter键时,它会恢复正常…我尝试了telnet localhost 11211命令,但命令提示符显示空白屏幕。。。即使我在cmd上键入了一些字符,光标也会空白移动…当我在cmd上键入任何字符时,都不会出现任何结果。。。当我按enter键时,它会恢复正常。。。