ehcache rmi 动态节点,代码创建,分布式配置

简介: ehcache rmi 动态节点,代码创建,分布式配置

通常配置ehcache分布式,都是在xml中配置的。例如:

 <cacheManagerPeerListenerFactory
            class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
            properties="port=40001,socketTimeoutMillis=2000"/>
    <!--缓存成员发现工厂,管理cacheManager对象 -->
    <cacheManagerPeerProviderFactory
            class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
            properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
            multicastGroupPort=4446, timeToLive=32"/>
<cache name="allWindowsParticulars"
           maxElementsInMemory="3000"
           eternal="false"
           timeToIdleSeconds="7200"
           timeToLiveSeconds="7200"
           overflowToDisk="false"
           overflowToOffHeap="false"
           diskPersistent="false"
           memoryStoreEvictionPolicy="LRU">
        <cacheEventListenerFactory
                class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                properties="replicateAsynchronously=false"
        />
        <!-- 服务器(Tomcat)启动就同步其他服务器(Tomcat)中的缓存-->
        <bootstrapCacheLoaderFactory
                class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
    </cache>

如果cache节点是通过代码创建的,该怎么配置呐?解决办法如下:

CacheConfiguration config = cacheManager.getConfiguration().getDefaultCacheConfiguration();
 CacheConfiguration.CacheEventListenerFactoryConfiguration cacheEventListenerFactoryConfiguration=new CacheConfiguration.CacheEventListenerFactoryConfiguration();
        cacheEventListenerFactoryConfiguration.setClass("net.sf.ehcache.distribution.RMICacheReplicatorFactory");
        cacheEventListenerFactoryConfiguration.setProperties("replicateAsynchronously=true,replicatePuts=true,replicateUpdates=true," +
                "replicateUpdatesViaCopy=false,replicateRemovals=true");
        config.addCacheEventListenerFactory(cacheEventListenerFactoryConfiguration);
        CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration bootstrapCacheLoaderFactoryConfiguration = new CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration();
        bootstrapCacheLoaderFactoryConfiguration.setClass("net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory");
        config.addBootstrapCacheLoaderFactory(bootstrapCacheLoaderFactoryConfiguration);
        new Cache(config);
相关文章
|
3月前
|
Cloud Native Java 开发工具
云原生 阿里云分布式文件系统 对象存储OSS 服务配置
【1月更文挑战第8天】云原生 阿里云分布式文件系统 对象存储OSS 服务配置
|
3月前
|
缓存 网络协议 算法
Golang简单实现 分布式缓存+一致性哈希+节点再平衡(gossip + consistent + rebalance)
Golang简单实现 分布式缓存+一致性哈希+节点再平衡(gossip + consistent + rebalance)
62 0
|
1月前
|
消息中间件 SpringCloudAlibaba Java
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(八)Config服务配置+bus消息总线+stream消息驱动+Sleuth链路追踪
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(八)Config服务配置+bus消息总线+stream消息驱动+Sleuth链路追踪
783 0
|
5月前
|
消息中间件 负载均衡 监控
分布式系列教程(08) -分布式协调工具Zookeeper(介绍&安装&配置详解)
分布式系列教程(08) -分布式协调工具Zookeeper(介绍&安装&配置详解)
374 0
|
2月前
|
负载均衡 定位技术 Nacos
Nacos 高级玩法:深入探讨分布式配置和服务发现
Nacos 高级玩法:深入探讨分布式配置和服务发现
359 0
|
4月前
|
监控 前端开发 应用服务中间件
Zabbix【部署 01】Zabbix企业级分布式监控系统部署配置使用实例(在线安装及问题处理)程序安装+数据库初始+前端配置+服务启动+Web登录
Zabbix【部署 01】Zabbix企业级分布式监控系统部署配置使用实例(在线安装及问题处理)程序安装+数据库初始+前端配置+服务启动+Web登录
413 0
|
4月前
|
Linux
Linux下Zookeeper分布式安装与配置
Linux下Zookeeper分布式安装与配置
269 0
|
4月前
|
Shell 网络安全 开发工具
[分布式] Git详细安装与配置
[分布式] Git详细安装与配置
289 0
|
5月前
|
存储 数据可视化 Linux
分布式系列教程(42) -ELK配置与使用
分布式系列教程(42) -ELK配置与使用
287 0
|
6月前
|
NoSQL Redis
114分布式电商项目 - Redis集群(节点增加删除)
114分布式电商项目 - Redis集群(节点增加删除)
25 1

热门文章

最新文章