Memcached ++++ exception thrown while trying to get object from cache for key
2017-08-15 09:05
1021 查看
Memcached ++++ exception thrown while trying to get object from cache for key
2016-10-20 14:57:13| 分类:默认分类 | 标签:memcached xmemcached memcached客户端
|举报
|字号大中小 订阅
++++ exception thrown while writing bytes to server on set
您的主机中的软件中止了一个已建立的连接
java.io.IOException: 您的主机中的软件中止了一个已建立的连接。
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
at sun.nio.ch.IOUtil.read(IOUtil.java:206)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
at sun.nio.ch.SocketAdaptor$SocketInputStream.read(SocketAdaptor.java:184)
at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:86)
隔一段时间不访问,一开始访问就报错。
使用的客户端是com.danga.memcached
怀疑是客户端问题
最后换成客户端:
com.whalin.Memcached-Java-Client
问题解决,会不会再出现,等后面再观察。
进过观察,换了memcached服务器版本,客户端版本,已经尝试的客户端的各个参数,参数设置会延迟刷新的时候,但是久了后还是会出现断掉的情况,猜想原因:客户端在维护socket池的时候出现了bug,在检查的时候,没把有问题的连接给关掉。导致第一次访问那个缓存还是之前的问题连接,然后就报错。
解决办法:换成xmemcached 客户端,xmemcached 是采用nio的方式,理论上是可以不用维持数据池的,尝试效果,目前没出现这种情况。一下是跟spring整合的配置。
pom
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
<version>2.0.0</version>
</dependency>
properties
memcache.server=xx
memcache.port=xx
memcache.connectionPoolSize=10
spring
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="memcachedClientBuilder" class="net.rubyeye.xmemcached.XMemcachedClientBuilder">
<constructor-arg>
<list>
<bean class="java.net.InetSocketAddress">
<constructor-arg value="${memcache.server}" />
<constructor-arg value="${memcache.port}" />
</bean>
</list>
</constructor-arg>
<property name="connectionPoolSize" value="${memcache.connectionPoolSize}" />
<property name="commandFactory">
<bean class="net.rubyeye.xmemcached.command.BinaryCommandFactory" />
</property>
<property name="transcoder">
<bean class="net.rubyeye.xmemcached.transcoders.SerializingTranscoder" />
</property>
</bean>
<bean id="xmemcachedClient" factory-bean="memcachedClientBuilder"
factory-method="build" destroy-method="shutdown" />
</beans>
使用:
@Resource
MemcachedClient xmemcachedClient;
@Override
public List<Configuration> getList() {
List<Configuration> result = null;
try {
result = (List<Configuration>) xmemcachedClient.get("configurationgetList");
if (result == null) {
result = session.select(0, 0);
xmemcachedClient.set("configurationgetList", DateUtil.oneDayCache, result);
}
} catch (TimeoutException e1) {
e1.printStackTrace();
} catch (InterruptedException e1) {
e1.printStackTrace();
} catch (MemcachedException e1) {
e1.printStackTrace();
}
return result;
}
回复
上一页
1
... -1
-1 -1
-1 -1
-1 -1
... -1
下一页
相关文章推荐
- JsonException: Max allowed object depth reached while trying to export from type System.Single
- JsonException: Max allowed object depth reached while trying to export from type System.Single
- (Entlib 5.0)Activation error occured while trying to get instance of type ICacheManager, key ""求解决办法
- The method queryForMap(String, Object...) from the type JdbcTemplate refers to the missing type DataAccessException
- Activation error occured while trying to get instance of type IcacheManager,key
- ShellBasedUnixGroupsMapping: got exception trying to get groups for user webuser
- 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to i
- NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: WebKitLocalStorageDatabasePathPreferenc
- Notice: Trying to get property of non-object problem(PHP)解决办法
- Oracle 9i 升级中的bug-- Sys.Cdc_alter_ctable_before ORA-04020 deadlock detected while trying to lock object
- 工作总结26 Error while trying to retrieve text for error ORA-12154 解决方案
- Target failed to run: Remote exception encountered: 'Failed to get task for pid #
- [笔记]--解决 Error while trying to retrieve text for error ORA-12154 的问题
- *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value ‘<Student: 0x8399f70>’
- *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from o
- Solve For a SqlCE Error When Select:ExceptionCode: 0xc0000005;NativeMethods.GetKeyInfo
- Oracle 9i 升级中的bug-- Sys.Cdc_alter_ctable_before ORA-04020 deadlock detected while trying to lock object
- sql异常:nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
- -[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object' 解决方法:
- Android An unexpected exception occurred while creating a change object. see the error log for more details