java java中实现Memcache的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11045600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 03:34:19  来源:igfitidea点击:

Errors in implementing Memcache in java

javamemcached

提问by Anil Kumar

I'm trying to write a simple code in Java to connect to a memcache server . I using the spymemcached 2.8 jar but I am getting a "server reconnecting" error which I'm unable to understand.

我正在尝试用 Java 编写一个简单的代码来连接到 memcache 服务器。我使用的是 spymemcached 2.8 jar,但出现“服务器重新连接”错误,我无法理解。

Code is:

代码是:

    **client =  new MemcachedClient(new    BinaryConnectionFactory(),AddrUtil.getAddresses("127.0.0.1:11211"));
    } catch (IOException e) {
       e.printStackTrace();
       System.err.println("connection problem");
    }
     client.set("someKey", 3600, new Integer(10));
    Object myObject=temp.client.get("someKey");
    System.out.println(myObject);
    client.delete("someKey");**

    

But I'm getting errors which are:

但我收到以下错误:

**2012-06-14 17:58:31.412 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2012-06-14 17:58:31.428 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@1621e42
2012-06-14 17:58:31.428 INFO net.spy.memcached.MemcachedConnection:  Reconnecting due to exception on {QA sa=/127.0.0.1:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: 1 Opaque: 1 Key: someKey Cas: 0 Exp: 3600 Flags: 512 Data Length: 1, 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-14 17:58:31.428 WARN net.spy.memcached.MemcachedConnection:  Closing, and reopening {QA sa=/127.0.0.1:11211, #Rops=1, #Wops=0, #iq=1, topRop=Cmd: 1 Opaque: 1 Key: someKey Cas: 0 Exp: 3600 Flags: 512 Data Length: 1, topWop=null, toWrite=0, interested=1}, attempt 0.
2012-06-14 17:58:31.428 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl:  Discarding partially completed op: Cmd: 1 Opaque: 1 Key: someKey Cas: 0 Exp: 3600 Flags: 512 Data Length: 1
2012-06-14 17:58:31.444 WARN net.spy.memcached.MemcachedConnection:  Could not redistribute to another node, retrying primary node for someKey.
2012-06-14 17:58:33.444 INFO net.spy.memcached.MemcachedConnection:  Reconnecting {QA sa=/127.0.0.1:11211, #Rops=0, #Wops=1, #iq=0, topRop=null, topWop=Cmd: 0 Opaque: 3 Key: someKey, toWrite=0, interested=0}
2012-06-14 17:58:33.444 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@1813fac
Exception in thread "main" net.spy.memcached.OperationTimeoutException: Timeout waiting for value
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1003)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1018)
    at ballydev.Memcache.main(Memcache.java:29)
Caused by: net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: /127.0.0.1:11211
    at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:93)
    at net.spy.memcached.internal.GetFuture.get(GetFuture.java:62)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:997)
    ... 2 more**

 

Anyone having any idea or suggestion? .. please reply...

任何人有任何想法或建议?.. 请回复...

回答by Dmitry Zagorulkin

Timed out waiting for operation - failing node: /127.0.0.1:11211this means your memcached binded on other adress or it's not started.

Timed out waiting for operation - failing node: /127.0.0.1:11211这意味着您的 memcached 已绑定到其他地址或尚未启动。

回答by Anil Kumar

Sorry guys, there was some problem with my machine, that's why I was having so many troubles running a simple code. But when I tried on a different box and used it's IP den it worked fine... :)

抱歉各位,我的机器出了点问题,这就是为什么我在运行一个简单的代码时遇到了很多麻烦。但是当我尝试使用不同的盒子并使用它的 IP den 时,它运行良好...... :)

Thanks everybody for bearing this one with me...

谢谢大家陪我度过这个...