在Tomcat群集中使用ehcache进行缓存复制

Java开发人员

我为3个不同的tomcat实例提供以下ehcache配置。

我的假设是,在每个ehcache中,我们都应将所有其他节点定义为提供者,并将当前节点定义为侦听器。

是否应该在每个ehcache.xml中定义所有缓存?如果是,是否还要将这些名称添加到RMI地址中?我这样定义了ehcache。其中两个缓存的复制工作正常,但其他两个缓存的复制则不起作用(activityCache和classificationCache)。当然,它应该取决于它们的实现,但是在此时,我想确保ehcache配置正确。

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ehcache.xsd">

 <cache name="activityCache"
           maxElementsInMemory="30"
           maxElementsOnDisk="100000"
           eternal="true"
           overflowToDisk="true"
           diskPersistent="true"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="50"
           timeToLiveSeconds="5"
           memoryStoreEvictionPolicy="LFU">

            <bootstrapCacheLoaderFactory class = "net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties = "bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"/>

            <cacheEventListenerFactory class = "net.sf.ehcache.distribution.RMICacheReplicatorFactory" properties="replicateAsynchronously=true, asynchronousReplicationIntervalMillis=100"/>

           </cache>

         <cache name="featureCache"
           maxElementsInMemory="30"
           maxElementsOnDisk="100000"
           eternal="true"
           overflowToDisk="true"
           diskPersistent="true"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="50"
           timeToLiveSeconds="5"
           memoryStoreEvictionPolicy="LFU">            

            <bootstrapCacheLoaderFactory class = "net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties = "bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"/>

            <cacheEventListenerFactory class = "net.sf.ehcache.distribution.RMICacheReplicatorFactory" properties="replicateAsynchronously=true, asynchronousReplicationIntervalMillis=100"/>

           </cache> 

        <cache name="classificationCache"
           maxElementsInMemory="30"
           maxElementsOnDisk="100000"
           eternal="true"
           overflowToDisk="true"
           diskPersistent="true"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="50"
           timeToLiveSeconds="5"
           memoryStoreEvictionPolicy="LFU">    

            <bootstrapCacheLoaderFactory class = "net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties = "bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"/>

            <cacheEventListenerFactory class = "net.sf.ehcache.distribution.RMICacheReplicatorFactory" properties="replicateAsynchronously=true, asynchronousReplicationIntervalMillis=100"/>

           </cache>

    <cache name="userGroupCache"
           maxElementsInMemory="30"
           maxElementsOnDisk="100000"
           eternal="true"
           overflowToDisk="true"
           diskPersistent="true"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="50"
           timeToLiveSeconds="5"
           memoryStoreEvictionPolicy="LFU">

            <bootstrapCacheLoaderFactory class = "net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties = "bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"/>

            <cacheEventListenerFactory class = "net.sf.ehcache.distribution.RMICacheReplicatorFactory" properties="replicateAsynchronously=true, asynchronousReplicationIntervalMillis=100"/>

           </cache>                

 <cacheManagerPeerProviderFactory class = "net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" properties = "peerDiscovery=manual, rmiUrls=//localhost:40002/activityCache|//localhost:40002/userGroupCache|//localhost:40002/featureCache|//localhost:40002/classificationCache//localhost:40003/activityCache|//localhost:40003/userGroupCache|//localhost:40003/featureCache|//localhost:40003/classificationCache"/>

<cacheManagerPeerListenerFactory class = "net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" properties = "hostName=localhost, port=40001, socketTimeoutMillis=2000"/>

</ehcache>

这也是缓存和cahchSevices的定义:

     <bean id="featureCache" parent="abstractOptionalCache">
        <property name="maxElementsInMemory" value="${cache.feature.maxMemoryElements}"/>
        <property name="maxElementsOnDisk" value="${cache.feature.maxDiskElements}"/> 
        <property name="overflowToDisk" value="${cache.feature.useDisk}"/>
      </bean>

      <bean id="featureCacheService" parent="abstractService" class="com.service.business.cache.impl.ehcache.EHcacheFeatureCacheService">
        <property name="cache"  ref="featureCache"/>
        <property name="enabled" value="${cache.feature.enable}"/>
      </bean> 

      <bean id="activityCache" parent="abstractMandatoryCache">
        <property name="cacheManager" ref="cacheManager"/>
        <property name="maxElementsInMemory" value="${cache.activity.maxMemoryElements}"/>
      </bean>

       <bean id="activityCacheService" parent="abstractService" class="com.service.business.cache.impl.ehcache.EHcacheActivityCacheService">
        <property name="cache"  ref="activityCache"/>
      </bean> 

      <bean id="classificationCache" parent="abstractOptionalCache">
        <property name="cacheManager" ref="cacheManager"/>
        <property name="maxElementsInMemory" value="${cache.classification.maxMemoryElements}"/>
        <property name="maxElementsOnDisk" value="${cache.classification.maxDiskElements}"/> 
        <property name="overflowToDisk" value="${cache.classification.useDisk}"/>
      </bean>

      <bean id="classificationCacheService" parent="abstractService" class="com.service.business.cache.impl.ehcache.EHcacheClassificationCacheService">
        <property name="cache"     ref="classificationCache" />
        <property name="enabled" value="${cache.classification.enable}"/>
      </bean>

        <bean id="userGroupCache" parent="abstractOptionalCache">
    <property name="cacheManager" ref="cacheManager"/>
    <property name="maxElementsInMemory" value="${cache.userGroup.maxMemoryElements}"/>
    <property name="maxElementsOnDisk" value="${cache.userGroup.maxDiskElements}"/> 
    <property name="overflowToDisk" value="${cache.userGroup.useDisk}"/>
  </bean>

  <bean id="userGroupCacheService" parent="abstractService" class="com.service.business.cache.impl.ehcache.EHcacheUserGroupCacheService">
    <property name="cache"     ref="userGroupCache" />
    <property name="enabled" value="${cache.userGroup.enable}"/>
  </bean> 

我将根据您的要求提供更多信息。

先感谢您。

体育vu

你做对了,但是在做错了

rmiUrls=//localhost:40002/activityCache|//localhost:40002/userGroupCache|//localhost:40002/featureCache|//localhost:40002/classificationCache//localhost:40003/activityCache|//localhost:40003/userGroupCache|//localhost:40003/featureCache|//localhost:40003/classificationCache

|在分类和活动缓存之间错过了

//localhost:40002/classificationCache//localhost:40003/activityCache

这就是这两个缓存都不起作用的原因!

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

WebLogic群集中的EhCache rmi复制问题

来自分类Dev

在安全群集中使用Nifi

来自分类Dev

Spring Boot,使用EhCache进行缓存

来自分类Dev

如何在Galera群集中使用MySQL临时表?

来自分类Dev

如何在ARM程序集中使用位移位在寄存器之间进行复制?

来自分类Dev

Tomcat的群集/会话复制无法正确复制

来自分类Dev

EHCache 3.1中的RMI缓存复制

来自分类Dev

在Laravel中使用缓存进行分页

来自分类Dev

如何在 C# 中使用 WMI 从 Hyper-v 故障转移群集中删除资源

来自分类Dev

在程序集中使用fget进行分段错误

来自分类Dev

在群集中运行的应用程序中使用多个主题时,如何均匀分配多个主题的分区?

来自分类Dev

在群集中使用http.createServer时,为什么多次调用提供给http.createServer的回调?

来自分类Dev

要添加到Windows Server中的什么角色,以便我可以在群集中使用共享磁盘?

来自分类Dev

使用Spring / EHCache加载时刷新缓存

来自分类Dev

使用Spring / EHCache加载时刷新缓存

来自分类Dev

在Android中使用clearApplicationUserData()方法进行缓存清除

来自分类Dev

Liferay / EHCache群集

来自分类Dev

如何在ASP.NET MVC中进行群集缓存?

来自分类Dev

有没有办法在graphviz中使用fdp布局在同一群集中的节点之间以及不同群集中的节点之间具有不同的边缘样条曲线?

来自分类Dev

在使用SPSS进行病例对照研究中,如何在病例集中复制数据?

来自分类Dev

在无状态集群应用程序中使用 Ehcache 和 Teracotta 进行休眠

来自分类Dev

在 kubernetes 上使用 jgroups 复制设置 ehcache

来自分类Dev

在Python中使用Paramiko进行递归目录复制

来自分类Dev

在CSS中使用渐变背景进行不必要的复制

来自分类Dev

在C / C ++中使用ProtoBuf进行深度复制

来自分类Dev

在Python中使用Paramiko进行递归目录复制

来自分类Dev

在CSS中使用渐变背景进行不必要的复制

来自分类Dev

在特定的Spring配置中进行缓存复制

来自分类Dev

使用ConcurrentHashMap进行缓存

Related 相关文章

  1. 1

    WebLogic群集中的EhCache rmi复制问题

  2. 2

    在安全群集中使用Nifi

  3. 3

    Spring Boot,使用EhCache进行缓存

  4. 4

    如何在Galera群集中使用MySQL临时表?

  5. 5

    如何在ARM程序集中使用位移位在寄存器之间进行复制?

  6. 6

    Tomcat的群集/会话复制无法正确复制

  7. 7

    EHCache 3.1中的RMI缓存复制

  8. 8

    在Laravel中使用缓存进行分页

  9. 9

    如何在 C# 中使用 WMI 从 Hyper-v 故障转移群集中删除资源

  10. 10

    在程序集中使用fget进行分段错误

  11. 11

    在群集中运行的应用程序中使用多个主题时,如何均匀分配多个主题的分区?

  12. 12

    在群集中使用http.createServer时,为什么多次调用提供给http.createServer的回调?

  13. 13

    要添加到Windows Server中的什么角色,以便我可以在群集中使用共享磁盘?

  14. 14

    使用Spring / EHCache加载时刷新缓存

  15. 15

    使用Spring / EHCache加载时刷新缓存

  16. 16

    在Android中使用clearApplicationUserData()方法进行缓存清除

  17. 17

    Liferay / EHCache群集

  18. 18

    如何在ASP.NET MVC中进行群集缓存?

  19. 19

    有没有办法在graphviz中使用fdp布局在同一群集中的节点之间以及不同群集中的节点之间具有不同的边缘样条曲线?

  20. 20

    在使用SPSS进行病例对照研究中,如何在病例集中复制数据?

  21. 21

    在无状态集群应用程序中使用 Ehcache 和 Teracotta 进行休眠

  22. 22

    在 kubernetes 上使用 jgroups 复制设置 ehcache

  23. 23

    在Python中使用Paramiko进行递归目录复制

  24. 24

    在CSS中使用渐变背景进行不必要的复制

  25. 25

    在C / C ++中使用ProtoBuf进行深度复制

  26. 26

    在Python中使用Paramiko进行递归目录复制

  27. 27

    在CSS中使用渐变背景进行不必要的复制

  28. 28

    在特定的Spring配置中进行缓存复制

  29. 29

    使用ConcurrentHashMap进行缓存

热门标签

归档