Ehcache集群
2015-08-03 16:14
148 查看
Ehcache集群的两种方式:组播方式和点对点方式
一、 组播方式
1) 配置cacheManagerPeerProviderFactory<cacheManagerPeerProviderFactoryclass="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"properties="peerDiscovery=automatic,multicastGroupAddress=230.0.0.2,multicast groupPort=4447,timeToLive=1”propertySeparator="," /> 作用:当缓存发生变化,进行广播 属性: peerDiscovery:atutomatic为自动;multicastGroupAddress:广播组地址,指定D类IP地址空间,范围从 224.0.1.0 到 238.255.255.255 中的任何一个地址 mulicastGroupPort广播组端口 timeToLive:搜索范围0是同一台服务器1是同一个子网32是指同一站点64是指同一块地域128是同一块大陆256是任何 2) 配置cacheManagerPeerListenerFactory<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" /> 作用:监听本服务器所有端口二、 点对点方式1) 配置cacheManagerPeerProviderFactory<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"properties="peerDiscovery=manual,rmiUrls=//192.168.4.50:40002/com.pccw.kernel.dic.vo.ArchDicKindVOImpl|//192.168.4.50:40002/com.pccw.kernel.dic.vo.ArchDicItemVOImpl"/>作用:当缓存发生变化,通知集群中其他节点。属性: peerDiscovery:manual为手动 rmiUrls:通知需要同步的缓存3) 配置cacheManagerPeerListenerFactory<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"properties="hostName=192.168.4.24,port=40001,socketTimeoutMillis=2000" /> 作用:监听本服务器指定端口 缓存的配置(共同部分)cacheEventListenerFactory:注册相应的的缓存监听类,用于处理缓存事件,如put,remove,update,和expire bootstrapCacheLoaderFactory:指定相应的BootstrapCacheLoader,用于 在初始化缓存(从硬盘读取,overflowToDisk为false时,此配置失效),以及自动设置。
p2p方式
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd"><!--Caches in this file can be clustered and are configured to be clustered.--><diskStore path="java.io.tmpdir/arch" /><cacheManagerEventListenerFactory class="" properties="" /><cacheManagerPeerProviderFactoryclass="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"properties="peerDiscovery=manual,rmiUrls=//192.168.4.24:40001/com.pccw.kernel.dic.vo.ArchDicKindVOImpl|//192.168.4.24:40001/com.pccw.kernel.dic.vo.ArchDicItemVOImpl"/><cacheManagerPeerListenerFactoryclass="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"properties="hostName=192.168.0.50,port=40002,socketTimeoutMillis=2000"//><defaultCachemaxElementsInMemory="10000"eternal="false" timeToIdleSeconds="600"overflowToDisk="false"> <cacheEventListenerFactoryclass="net.sf.ehcache.distribution.RMICacheReplicatorFactory"properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true"propertySeparator=","/><bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" /></defaultCache><cachename="sessionCache"maxElementsInMemory="10000"eternal="true" timeToIdleSeconds="600"overflowToDisk="false"> <cacheEventListenerFactoryclass="net.sf.ehcache.distribution.RMICacheReplicatorFactory"properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true"propertySeparator=","/><bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" /></cache><cachename="customCache"maxElementsInMemory="10000"eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="1800"overflowToDisk="false"> <cacheEventListenerFactoryclass="net.sf.ehcache.distribution.RMICacheReplicatorFactory"properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true"propertySeparator=","/><bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" /></cache><cache name="com.pccw.kernel.dic.vo.ArchDicItemVOImpl"maxElementsInMemory="100000" eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="1200" overflowToDisk="false"> <cacheEventListenerFactoryclass="net.sf.ehcache.distribution.RMICacheReplicatorFactory"properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true"propertySeparator=","/><bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" /></cache><cache name="com.pccw.kernel.dic.vo.ArchDicKindVOImpl"maxElementsInMemory="100000" eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="1200" overflowToDisk="false" > <cacheEventListenerFactoryclass="net.sf.ehcache.distribution.RMICacheReplicatorFactory"properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true"propertySeparator=","/><bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" /></cache></ehcache>
相关文章推荐
- 脏读、不可重复读 共享锁、悲观锁 和 事务五种隔离级别
- 文件及文件处理小结
- JAVA内存管理
- Use of undectared identifier '_xxxx'
- C语言:将结构体数组的成绩按照从小到大进行排序。
- php页面静态化方法小结
- BitmapFactory.decodeStream()获取bitmap返回null
- LeetCode -- 帕斯卡三角形
- IP获取城市位置信息 API
- 真机调试成功和打包安装后闪退
- iOS 将文本转换为语音
- 重学java23种设计模式(9)装饰者模式
- linux 信号集操作
- 深入了解ThreadPoolExecutor类的工作原理
- 认识Backbone (二)
- 堆的构建及实例化
- EF 4.0 更新数据时候的一个错误及其处理
- IOS UIWebView与Javascript之间的交互
- 用Fabric自动推送nagios client脚本
- 用Fabric自动推送nagios client脚本 推荐