Ehcache jgroups方式同步缓存出现问题总结
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Ehcache jgroups方式同步缓存出现问题总结,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4502字,纯文字阅读大概需要7分钟。
内容图文

ehcache配置文件按官网配置如下:
1 <? xml version="1.0" encoding="UTF-8" ?> 2 < ehcache > 3 4 < diskStore path ="java.io.tmpdir" /> 5 6 < cacheManagerPeerProviderFactory 7 class ="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" 8 properties ="connect=TCP(start_port=7777): 9 TCPPING(initial_hosts=133.96.93.111[7777],133.96.93.105[7777];port_range=10;timeout=3000; 10 num_initial_members=3;up_thread=true;down_thread=true): 11 VERIFY_SUSPECT(timeout=1500;down_thread=false;up_thread=false): 12 pbcast.NAKACK(down_thread=true;up_thread=true;gc_lag=100;retransmit_timeout=3000): 13 pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false; 14 print_local_addr=false;down_thread=true;up_thread=true)" 15 propertySeparator ="::" /> 16 17 < defaultCache maxElementsInMemory ="10000" overflowToDisk ="false" 18 eternal ="false" memoryStoreEvictionPolicy ="LRU" 19 maxElementsOnDisk ="10000000" diskExpiryThreadIntervalSeconds ="600" 20 timeToIdleSeconds ="3600" timeToLiveSeconds ="100000" 21 diskPersistent ="false" /> 22 23 < cache name ="AutoAssignUsers" maxElementsInMemory ="10000" eternal ="true" 24 overflowToDisk ="false" timeToIdleSeconds ="1" timeToLiveSeconds ="600" 25 memoryStoreEvictionPolicy ="LRU" > 26 < cacheEventListenerFactory 27 class ="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory" 28 properties ="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, 29 replicateUpdatesViaCopy=true, replicateRemovals=true " /> 30 </ cache > 31 32 </ ehcache >
按官网配置后启动报错:
[net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProvider] (main) Failed to create JGroups Channel, replication will not function. org.jgroups.ChannelException: unable to setup the protocol stack at org.jgroups.JChannel.init(JChannel.java:1703) at org.jgroups.JChannel. < init > (JChannel.java:246) at org.jgroups.JChannel. < init > (JChannel.java:229) at net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProvider.init(JGroupsCacheManagerPeerProvider.java:127) at net.sf.ehcache.CacheManager.init(CacheManager.java:328) at net.sf.ehcache.CacheManager. < init > (CacheManager.java:226) at net.sf.ehcache.CacheManager.create(CacheManager.java:690)
Caused by: java.lang.IllegalArgumentException: start_port cannot be set to 0, as no dynamic discovery protocol (e.g. MPING or TCPGOSSIP) has been detected.
at org.jgroups.protocols.BasicTCP.init(BasicTCP.java:90)
at org.jgroups.stack.ProtocolStack.initProtocolStack(ProtocolStack.java:705)
at org.jgroups.stack.ProtocolStack.setup(ProtocolStack.java:457)
at org.jgroups.JChannel.init(JChannel.java:1699)
之后google找到解决方法:
①将
start_port=7800 改为 bind_port=7800
即
< cacheManagerPeerProviderFactory class ="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" properties ="connect=TCP(bind_port=7777): TCPPING(initial_hosts=133.96.93.111[7777],133.96.93.105[7777];port_range=10;timeout=3000; num_initial_members=3;up_thread=true;down_thread=true): VERIFY_SUSPECT(timeout=1500;down_thread=false;up_thread=false): pbcast.NAKACK(down_thread=true;up_thread=true;gc_lag=100;retransmit_timeout=3000): pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false; print_local_addr=false;down_thread=true;up_thread=true)" propertySeparator ="::" />
②<EM style=‘line-height: 1.5; font-family: "Courier New"; font-size: 12px;‘ id="__mceDel">cacheManagerPeerProviderFactory 中properties的属性改为文件引用如下:
< cacheManagerPeerProviderFactory class ="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" properties ="jgroups_tcp.xml" />
jgroups_tcp.xml :
<? xml version=‘1.0‘ ?> < config > < TCP start_port ="7777" /> < TCPPING timeout ="3000" initial_hosts ="139.99.93.111[7777],139.99.93.105[7777]" port_range ="10" num_initial_members ="3" /> < VERIFY_SUSPECT timeout ="1500" /> < pbcast.NAKACK use_mcast_xmit ="false" gc_lag ="100" retransmit_timeout ="300,600,1200,2400,4800" discard_delivered_msgs ="true" /> < pbcast.STABLE stability_delay ="1000" desired_avg_gossip ="50000" max_bytes ="400000" /> < pbcast.GMS print_local_addr ="true" join_timeout ="5000" shun ="false" view_bundling ="true" /> </ config >
我试了第一种方法可以缓存同步,第二种没试,但是解决方法中有,可以试试
给出原地址:http://forums.terracotta.org/forums/posts/list/4660.page
原文:http://www.cnblogs.com/luoyanli/p/3717878.html
内容总结
以上是互联网集市为您收集整理的Ehcache jgroups方式同步缓存出现问题总结全部内容,希望文章能够帮你解决Ehcache jgroups方式同步缓存出现问题总结所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。