我正在寻找一个java示例,该示例演示了当其中一个节点出现故障时如何避免使用Membase的异常。
我有一个由两个节点组成的小集群,其中一个“默认”存储桶。它在两台服务器上都被复制。我为压力加载编写了一些java测试应用程序。我使用spymemcache 2.7。当我运行它时 - 两台服务器都很忙。当我关闭一个membase实例时,我的java应用程序会崩溃。
这是例外日志:
2011-06-15 17:32:33.405 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.1.9:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2011-06-15 17:32:33.407 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.1.10:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2011-06-15 17:32:33.412 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@63238bd2
2011-06-15 17:32:33.413 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@37bd2664
2011-06-15 18:20:21.896 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {QA sa=/192.168.1.9:11211, #Rops=2, #Wops=0, #iq=0, topRop=net.spy.memcached.protocol.binary.StoreOperationImpl@5f4275d4, topWop=null, toWrite=0, interested=1}
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:237)
at sun.nio.ch.IOUtil.read(IOUtil.java:210)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:487)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:427)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:280)
at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:2063)
2011-06-15 18:20:21.897 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=/192.168.1.9:11211, #Rops=2, #Wops=0, #iq=0, topRop=net.spy.memcached.protocol.binary.StoreOperationImpl@5f4275d4, topWop=null, toWrite=0, interested=1}, attempt 0.
2011-06-15 18:20:21.898 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl: Discarding partially completed op: net.spy.memcached.protocol.binary.StoreOperationImpl@5f4275d4
2011-06-15 18:20:21.899 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl: Discarding partially completed op: net.spy.memcached.protocol.binary.GetOperationImpl@802b249
Exception in thread "main" java.lang.RuntimeException: Exception waiting for value
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1146)
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1163)
我让节点192.168.1.9关闭,但是客户端没有理解并崩溃。
任何想法如何正确处理它?</ p>
答案 0 :(得分:0)
- 如果您对服务器进行故障转移,异常会消失吗? - 您指向客户端的服务器的URI是什么?如果你把它指向“其他”和/或两者,它会有所作为吗?
佩里
答案 1 :(得分:0)
我认为这不是因为memcached集群,因为我在本地运行单个memcached服务器并运行测试用例来缓存和检索数据时出现此错误消息。以下环境正在使用mac snow leapord + spymemcached 2.7 + memcached 1.4.6
我在守护进程模式下运行它,并在重新启动本地memcached服务器后得到修复。
对不起,我无法确切地说出原因,但上述方法解决了这个问题。
答案 2 :(得分:0)
所以,我们没有找到问题的答案,我们不再使用这个软件了。现在我们使用Erlang绝对说明了这种内存数据存储的需求。