Ehcache集群需要很长时间才能在Tomcat上启动

时间:2011-06-21 16:24:17

标签: java tomcat java-ee ehcache

我正在使用部署在Tomcat 7环境中的复制ehcache。这里发生的事情是tomcat需要很长时间才能启动,日志中充满了ehcache心跳消息。

关于如何加速ehcache和Tomcat启动的任何想法?

我的ehcache.xml -

    <?xml version="1.0" encoding="UTF-8"?> 

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

    <diskStore path="java.io.tmpdir"/> 

    <transactionManagerLookup class="net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup"
                              properties="jndiName=java:/TransactionManager" propertySeparator=";"/> 
    <cacheManagerEventListenerFactory class="com.adobe_services.cache.SampleCacheManagerEventListenerFactory" properties="type=counting"/>
  <cacheManagerPeerProviderFactory
            class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
            properties="peerDiscovery=automatic,
                        multicastGroupAddress=230.0.0.1,
                        multicastGroupPort=4446, timeToLive=1"
            propertySeparator=","
            />
    <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
                                     properties="hostName=, port=, socketTimeoutMillis="/> 
     <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskSpoolBufferSizeMB="30"
            maxElementsOnDisk="10000000"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            statistics="false"
            />

    <cache name="replicatedCache"
    maxElementsInMemory="5"
           maxElementsOnDisk="100000"
           eternal="true"
           overflowToDisk="true"
           diskPersistent="true"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="3600"
           timeToLiveSeconds="3600"
           memoryStoreEvictionPolicy="LFU"
           transactionalMode="off">
        <cacheEventListenerFactory
                class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
        <bootstrapCacheLoaderFactory
        class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
        properties="bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"
        propertySeparator="," />
    </cache>   

    <cache name="replicatedCache2"
    maxElementsInMemory="5"
           maxElementsOnDisk="100000"
           eternal="true"
           overflowToDisk="true"
           diskPersistent="true"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="3600"
           timeToLiveSeconds="3600"
           memoryStoreEvictionPolicy="LFU"
           transactionalMode="off">
        <cacheEventListenerFactory
                class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
        <bootstrapCacheLoaderFactory
        class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
        properties="bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"
        propertySeparator="," />
    </cache>   


</ehcache> 

1 个答案:

答案 0 :(得分:3)

您需要将引导程序策略更改为异步(bootstrapAsynchronously=true)以避免启动时出现延迟,即:

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