标签:des style blog class code java
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="::" />
②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
Ehcache jgroups方式同步缓存出现问题总结,布布扣,bubuko.com
标签:des style blog class code java
原文地址:http://www.cnblogs.com/luoyanli/p/3717878.html