vaseems / xmemcached

Automatically exported from code.google.com/p/xmemcached
Apache License 2.0
0 stars 0 forks source link

xmemcached1.3.5 on windows7 shutdown error #182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
我有一台windows7系统安装了memcached-win64-1.4.4-14作为缓存服务器
,同时也运行Tomcat7.0作为web 
server,采用了xmemcached1.3.5作为缓存客户端,运行服务器时我��
�现以下3个问题:
1.Tomcat日志中有如下错误信息。我的源代码是这样写的:
public void destory()
    {
        try
        {
            if(!client.isShutdown()) client.shutdown();
        }
        catch(Exception e)
        {               
            EELogger.createInstance().error(e.getMessage(),e);          
        }
    }
日志错误信息-------catalina.2012-03-12.log error info:
2012-3-12 14:56:21 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stopped already. 
 Could not load java.util.concurrent.ExecutorService.  The eventual following 
stack trace is caused by an error thrown for debugging purposes as well as to 
attempt to terminate the thread which caused the illegal access, and has no 
functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1574)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
    at net.rubyeye.xmemcached.impl.MemcachedHandler.stop(MemcachedHandler.java:252)
    at net.rubyeye.xmemcached.XMemcachedClient.shutdown(XMemcachedClient.java:2414)

2.Tomcat日志中有如下错误信息。不知道是什么时候记录的。
2012-3-12 20:00:59 net.rubyeye.xmemcached.impl.MemcachedHandler 
onExceptionCaught
严重: XMemcached network layout exception
java.io.IOException: 远程主机强迫关闭了一个现有的连接。
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(Unknown Source)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
    at sun.nio.ch.IOUtil.read(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
    at com.google.code.yanf4j.nio.impl.NioTCPSession.readFromBuffer(NioTCPSession.java:200)
    at com.google.code.yanf4j.nio.impl.AbstractNioSession.onRead(AbstractNioSession.java:198)
    at com.google.code.yanf4j.nio.impl.AbstractNioSession.onEvent(AbstractNioSession.java:343)
    at com.google.code.yanf4j.nio.impl.SocketChannelController.dispatchReadEvent(SocketChannelController.java:56)
    at com.google.code.yanf4j.nio.impl.NioController.onRead(NioController.java:157)
    at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent(Reactor.java:294)
    at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java:141)

2012-3-12 20:00:59 net.rubyeye.xmemcached.impl.MemcachedConnector 
removeMainSession
警告: Remove a session: 127.0.0.1:11211
2012-3-12 20:01:01 
net.rubyeye.xmemcached.impl.MemcachedConnector$SessionMonitor run
警告: Trying to connect to 127.0.0.1:11211 for 1 times
2012-3-12 20:01:02 
net.rubyeye.xmemcached.impl.MemcachedConnector$SessionMonitor 
rescheduleConnectRequest
严重: Reconnect to 127.0.0.1:11211 fail
2012-3-12 20:01:02 
net.rubyeye.xmemcached.impl.MemcachedConnector$InnerControllerStateListener 
onException
严重: Exception occured in controller
java.io.IOException: Connect to 127.0.0.1:11211 fail,Connection refused: no 
further information
    at net.rubyeye.xmemcached.impl.MemcachedConnector.onConnect(MemcachedConnector.java:402)
    at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent(Reactor.java:302)
    at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java:141)

3.程序中xmemcached代码如下
clientBuilder.setSessionLocator(new 
KetamaMemcachedSessionLocator());//一致性hash算法
            clientBuilder.setCommandFactory(new BinaryCommandFactory());
            clientBuilder.setSocketOption(StandardSocketOption.SO_RCVBUF, 32 * 1024); // 设置接收缓存区为32K,默认16K
            clientBuilder.setSocketOption(StandardSocketOption.SO_SNDBUF, 16 * 1024); // 设置发送缓冲区为16K,默认为8K
            clientBuilder.setSocketOption(StandardSocketOption.TCP_NODELAY, false); // 启用nagle算法,提高吞吐量,默认关闭
            clientBuilder.setConnectionPoolSize(200);
            clientBuilder.getConfiguration().setSessionIdleTimeout(10000);  // 设置为10秒;
            //clientBuilder.getConfiguration().setStatisticsServer(false);
            client = clientBuilder.build();
            client.getTranscoder().setCompressionThreshold(1024*20); //超过20K压缩对象
            client.setSanitizeKeys(true);
            client.setOpTimeout(opTimeout);
            client.setEnableHeartBeat(false);  // 关闭心跳检测
            client.setMergeFactor(50);   //默认是150,缩小到50
            //client.setOptimizeMergeBuffer(false);  //关闭合并buffer的优化

Original issue reported on code.google.com by george.j...@gmail.com on 13 Mar 2012 at 8:06

GoogleCodeExporter commented 9 years ago
你的关闭应该放在统一一个地方,比如ContextListener的destroy,�
��者全部委托给spring管理。从你的错误来看,主要还是关闭顺
序出了问题。

Original comment by killme2...@gmail.com on 19 Mar 2012 at 3:09

GoogleCodeExporter commented 9 years ago
没有问题我关闭了,谢谢。

Original comment by killme2...@gmail.com on 26 Mar 2012 at 10:31