Follow-up on ALF-765 by upgrading EHCache to 2.0.0

- Fixed CacheTest to avoid disk flushes (configuration issues)
 - Allows Cache statistics to be turned off (done)
 - Added explicit switch to LruMemoryStore (raised https://jira.terracotta.org/jira/browse/EHC-652)
 - Removed EHCache usage within TransactionalCache (replaced with LruMap and Set)
 - Even with 'statistics=false' the EHCache code still messes about too much, but it's much better
 - TODO: Leave ripping out of ehcache-transactional.xml until DAO synch


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19324 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley 2010-03-17 04:53:04 +00:00
parent 4c8f94071c
commit 733cd6e02d
8 changed files with 354 additions and 148 deletions

View File

@ -11,6 +11,7 @@
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
> >
</defaultCache> </defaultCache>
@ -20,6 +21,7 @@
maxElementsInMemory="50" maxElementsInMemory="50"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 0.4MB memory required --> <!-- approx 0.4MB memory required -->
<cache <cache
@ -27,6 +29,7 @@
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 40MB memory required --> <!-- approx 40MB memory required -->
<cache <cache
@ -34,6 +37,7 @@
maxElementsInMemory="50000" maxElementsInMemory="50000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 15MB memory required --> <!-- approx 15MB memory required -->
<cache <cache
@ -41,6 +45,7 @@
maxElementsInMemory="40000" maxElementsInMemory="40000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 10MB memory required --> <!-- approx 10MB memory required -->
<cache <cache
@ -48,6 +53,7 @@
maxElementsInMemory="20000" maxElementsInMemory="20000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 250MB memory required --> <!-- approx 250MB memory required -->
<cache <cache
@ -55,6 +61,7 @@
maxElementsInMemory="200000" maxElementsInMemory="200000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- general use node associations are not common --> <!-- general use node associations are not common -->
<cache <cache
@ -62,6 +69,7 @@
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- low numbers of objects expected --> <!-- low numbers of objects expected -->
<cache <cache
@ -69,6 +77,7 @@
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Permission related caches --> <!-- Permission related caches -->
<!-- approx 1MB memory required --> <!-- approx 1MB memory required -->
@ -77,6 +86,7 @@
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 5MB memory required --> <!-- approx 5MB memory required -->
<cache <cache
@ -84,6 +94,7 @@
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 5MB memory required --> <!-- approx 5MB memory required -->
<cache <cache
@ -91,6 +102,7 @@
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 1MB memory required --> <!-- approx 1MB memory required -->
<cache <cache
@ -98,6 +110,7 @@
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 1MB memory required --> <!-- approx 1MB memory required -->
<cache <cache
@ -105,6 +118,7 @@
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 1MB memory required --> <!-- approx 1MB memory required -->
<cache <cache
@ -112,6 +126,7 @@
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 10MB memory required --> <!-- approx 10MB memory required -->
<cache <cache
@ -119,6 +134,7 @@
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- approx 1MB memory required --> <!-- approx 1MB memory required -->
<cache <cache
@ -126,6 +142,7 @@
maxElementsInMemory="500" maxElementsInMemory="500"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Audit caches --> <!-- Audit caches -->
<cache <cache
@ -133,18 +150,21 @@
maxElementsInMemory="2" maxElementsInMemory="2"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.repo.audit.hibernate.AuditDateImpl" name="org.alfresco.repo.audit.hibernate.AuditDateImpl"
maxElementsInMemory="2" maxElementsInMemory="2"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.repo.audit.hibernate.AuditSourceImpl" name="org.alfresco.repo.audit.hibernate.AuditSourceImpl"
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Attribute Service Caches. --> <!-- Attribute Service Caches. -->
<cache <cache
@ -152,24 +172,28 @@
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.repo.attributes.ListEntryImpl" name="org.alfresco.repo.attributes.ListEntryImpl"
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.repo.attributes.MapEntryImpl" name="org.alfresco.repo.attributes.MapEntryImpl"
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.repo.attributes.GlobalAttributeEntryImpl" name="org.alfresco.repo.attributes.GlobalAttributeEntryImpl"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- AVM caches --> <!-- AVM caches -->
@ -179,6 +203,7 @@
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
@ -186,6 +211,7 @@
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
@ -193,6 +219,7 @@
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
@ -200,6 +227,7 @@
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
@ -207,6 +235,7 @@
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Internally used caches --> <!-- Internally used caches -->
@ -216,102 +245,119 @@
eternal="false" eternal="false"
timeToLiveSeconds="300" timeToLiveSeconds="300"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.qnameEntityCache" name="org.alfresco.cache.qnameEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.namespaceEntityCache" name="org.alfresco.cache.namespaceEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.localeIdCache" name="org.alfresco.cache.localeIdCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.mimetypeEntityCache" name="org.alfresco.cache.mimetypeEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.encodingEntityCache" name="org.alfresco.cache.encodingEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.contentDataCache" name="org.alfresco.cache.contentDataCache"
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.immutableEntityCache" name="org.alfresco.cache.immutableEntityCache"
maxElementsInMemory="50000" maxElementsInMemory="50000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.storeAndNodeIdCache" name="org.alfresco.cache.storeAndNodeIdCache"
maxElementsInMemory="80000" maxElementsInMemory="80000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.parentAssocsCache" name="org.alfresco.cache.parentAssocsCache"
maxElementsInMemory="80000" maxElementsInMemory="80000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.userToAuthorityCache" name="org.alfresco.cache.userToAuthorityCache"
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.authorityCache" name="org.alfresco.cache.authorityCache"
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.permissionsAccessCache" name="org.alfresco.cache.permissionsAccessCache"
maxElementsInMemory="50000" maxElementsInMemory="50000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.nodeOwnerCache" name="org.alfresco.cache.nodeOwnerCache"
maxElementsInMemory="20000" maxElementsInMemory="20000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.personCache" name="org.alfresco.cache.personCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.ticketsCache" name="org.alfresco.cache.ticketsCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="true" overflowToDisk="true"
statistics="false"
/> />
<cache <cache
name="org.alfresco.cache.aclCache" name="org.alfresco.cache.aclCache"
maxElementsInMemory="50000" maxElementsInMemory="50000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Web Client Config (tenant-based) --> <!-- Web Client Config (tenant-based) -->
@ -321,6 +367,7 @@
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Messages I18N (tenant-based) --> <!-- Messages I18N (tenant-based) -->
@ -330,6 +377,7 @@
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
@ -337,6 +385,7 @@
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<cache <cache
@ -344,6 +393,7 @@
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Dictionary / Namespace (tenant-based) --> <!-- Dictionary / Namespace (tenant-based) -->
@ -354,6 +404,7 @@
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- dictionary namespaces --> <!-- dictionary namespaces -->
@ -362,6 +413,7 @@
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Tenants Cache --> <!-- Tenants Cache -->
@ -371,6 +423,7 @@
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Tenant-based Routing File Content Store --> <!-- Tenant-based Routing File Content Store -->
@ -380,6 +433,7 @@
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Web Scripts Registry --> <!-- Web Scripts Registry -->
@ -389,6 +443,7 @@
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
<!-- Routing Content Store --> <!-- Routing Content Store -->
@ -398,6 +453,7 @@
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
statistics="false"
/> />
</ehcache> </ehcache>

View File

@ -22,7 +22,9 @@
eternal="true" eternal="true"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -38,7 +40,9 @@
maxElementsInMemory="50" maxElementsInMemory="50"
eternal="true" eternal="true"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -53,7 +57,9 @@
name="org.hibernate.cache.UpdateTimestampsCache" name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -70,7 +76,9 @@
eternal="true" eternal="true"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -87,7 +95,9 @@
eternal="true" eternal="true"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -104,7 +114,9 @@
eternal="true" eternal="true"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -121,7 +133,9 @@
eternal="true" eternal="true"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -138,7 +152,9 @@
eternal="true" eternal="true"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -155,7 +171,9 @@
eternal="true" eternal="true"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -170,7 +188,9 @@
name="org.alfresco.repo.domain.hibernate.DbAccessControlEntryContextImpl" name="org.alfresco.repo.domain.hibernate.DbAccessControlEntryContextImpl"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -185,7 +205,9 @@
name="org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl" name="org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl"
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -200,7 +222,9 @@
name="org.alfresco.repo.domain.hibernate.DbAccessControlListChangeSetImpl" name="org.alfresco.repo.domain.hibernate.DbAccessControlListChangeSetImpl"
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -215,7 +239,9 @@
name="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl" name="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -230,7 +256,9 @@
name="org.alfresco.repo.domain.hibernate.DbAccessControlListMemberImpl" name="org.alfresco.repo.domain.hibernate.DbAccessControlListMemberImpl"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -245,7 +273,9 @@
name="org.alfresco.repo.domain.hibernate.DbAuthorityAliasImpl" name="org.alfresco.repo.domain.hibernate.DbAuthorityAliasImpl"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -260,7 +290,9 @@
name="org.alfresco.repo.domain.hibernate.DbAuthorityImpl" name="org.alfresco.repo.domain.hibernate.DbAuthorityImpl"
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -275,7 +307,9 @@
name="org.alfresco.repo.domain.hibernate.DbPermissionImpl" name="org.alfresco.repo.domain.hibernate.DbPermissionImpl"
maxElementsInMemory="500" maxElementsInMemory="500"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -290,7 +324,9 @@
name="org.alfresco.repo.audit.hibernate.AuditConfigImpl" name="org.alfresco.repo.audit.hibernate.AuditConfigImpl"
maxElementsInMemory="2" maxElementsInMemory="2"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -305,7 +341,9 @@
name="org.alfresco.repo.audit.hibernate.AuditDateImpl" name="org.alfresco.repo.audit.hibernate.AuditDateImpl"
maxElementsInMemory="2" maxElementsInMemory="2"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -320,7 +358,9 @@
name="org.alfresco.repo.audit.hibernate.AuditSourceImpl" name="org.alfresco.repo.audit.hibernate.AuditSourceImpl"
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -335,7 +375,9 @@
name="org.alfresco.repo.attributes.AttributeImpl" name="org.alfresco.repo.attributes.AttributeImpl"
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -350,7 +392,9 @@
name="org.alfresco.repo.attributes.ListEntryImpl" name="org.alfresco.repo.attributes.ListEntryImpl"
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -365,7 +409,9 @@
name="org.alfresco.repo.attributes.MapEntryImpl" name="org.alfresco.repo.attributes.MapEntryImpl"
maxElementsInMemory="2000" maxElementsInMemory="2000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -380,7 +426,9 @@
name="org.alfresco.repo.attributes.GlobalAttributeEntryImpl" name="org.alfresco.repo.attributes.GlobalAttributeEntryImpl"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -397,7 +445,9 @@
name="org.alfresco.cache.avm.avmEntityCache" name="org.alfresco.cache.avm.avmEntityCache"
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -412,7 +462,9 @@
name="org.alfresco.cache.avm.versionRootEntityCache" name="org.alfresco.cache.avm.versionRootEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -427,7 +479,9 @@
name="org.alfresco.cache.avm.avmNodeCache" name="org.alfresco.cache.avm.avmNodeCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -442,7 +496,9 @@
name="org.alfresco.cache.avm.avmStoreCache" name="org.alfresco.cache.avm.avmStoreCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -457,7 +513,9 @@
name="org.alfresco.cache.avm.avmNodeAspectsCache" name="org.alfresco.cache.avm.avmNodeAspectsCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -473,7 +531,9 @@
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="false" eternal="false"
timeToLiveSeconds="300" timeToLiveSeconds="300"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -488,7 +548,9 @@
name="org.alfresco.cache.storeAndNodeIdCache" name="org.alfresco.cache.storeAndNodeIdCache"
maxElementsInMemory="80000" maxElementsInMemory="80000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -503,7 +565,9 @@
name="org.alfresco.cache.qnameEntityCache" name="org.alfresco.cache.qnameEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -518,7 +582,9 @@
name="org.alfresco.cache.namespaceEntityCache" name="org.alfresco.cache.namespaceEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -533,7 +599,9 @@
name="org.alfresco.cache.localeIdCache" name="org.alfresco.cache.localeIdCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -548,7 +616,9 @@
name="org.alfresco.cache.mimetypeEntityCache" name="org.alfresco.cache.mimetypeEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -563,7 +633,9 @@
name="org.alfresco.cache.encodingEntityCache" name="org.alfresco.cache.encodingEntityCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -578,7 +650,9 @@
name="org.alfresco.cache.contentDataCache" name="org.alfresco.cache.contentDataCache"
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -593,7 +667,9 @@
name="org.alfresco.cache.immutableEntityCache" name="org.alfresco.cache.immutableEntityCache"
maxElementsInMemory="50000" maxElementsInMemory="50000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -608,7 +684,9 @@
name="org.alfresco.cache.parentAssocsCache" name="org.alfresco.cache.parentAssocsCache"
maxElementsInMemory="80000" maxElementsInMemory="80000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -623,7 +701,9 @@
name="org.alfresco.cache.userToAuthorityCache" name="org.alfresco.cache.userToAuthorityCache"
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -638,7 +718,9 @@
name="org.alfresco.cache.authorityCache" name="org.alfresco.cache.authorityCache"
maxElementsInMemory="5000" maxElementsInMemory="5000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -653,7 +735,9 @@
name="org.alfresco.cache.permissionsAccessCache" name="org.alfresco.cache.permissionsAccessCache"
maxElementsInMemory="50000" maxElementsInMemory="50000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -668,7 +752,9 @@
name="org.alfresco.cache.nodeOwnerCache" name="org.alfresco.cache.nodeOwnerCache"
maxElementsInMemory="20000" maxElementsInMemory="20000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -683,7 +769,9 @@
name="org.alfresco.cache.personCache" name="org.alfresco.cache.personCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -698,7 +786,9 @@
name="org.alfresco.cache.ticketsCache" name="org.alfresco.cache.ticketsCache"
maxElementsInMemory="1000" maxElementsInMemory="1000"
eternal="true" eternal="true"
overflowToDisk="true"> overflowToDisk="true"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -714,7 +804,9 @@
name="org.alfresco.cache.sysAdminCache" name="org.alfresco.cache.sysAdminCache"
maxElementsInMemory="10" maxElementsInMemory="10"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -729,7 +821,9 @@
name="org.alfresco.cache.aclCache" name="org.alfresco.cache.aclCache"
maxElementsInMemory="50000" maxElementsInMemory="50000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -746,7 +840,9 @@
name="org.alfresco.cache.globalConfigCache" name="org.alfresco.cache.globalConfigCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -764,7 +860,9 @@
name="org.alfresco.cache.resourceBundleBaseNamesCache" name="org.alfresco.cache.resourceBundleBaseNamesCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -780,7 +878,9 @@
name="org.alfresco.cache.loadedResourceBundlesCache" name="org.alfresco.cache.loadedResourceBundlesCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -796,7 +896,9 @@
name="org.alfresco.cache.messagesCache" name="org.alfresco.cache.messagesCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -814,7 +916,9 @@
name="org.alfresco.cache.compiledModelsCache" name="org.alfresco.cache.compiledModelsCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -830,7 +934,9 @@
name="org.alfresco.cache.prefixesCache" name="org.alfresco.cache.prefixesCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -849,7 +955,9 @@
name="org.alfresco.cache.tenantsCache" name="org.alfresco.cache.tenantsCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -867,7 +975,9 @@
name="org.alfresco.cache.tenantFileStoresCache" name="org.alfresco.cache.tenantFileStoresCache"
maxElementsInMemory="10000" maxElementsInMemory="10000"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
@ -885,7 +995,9 @@
name="org.alfresco.cache.webScriptsRegistryCache" name="org.alfresco.cache.webScriptsRegistryCache"
maxElementsInMemory="100" maxElementsInMemory="100"
eternal="true" eternal="true"
overflowToDisk="false"> overflowToDisk="false"
statistics="false"
>
<cacheEventListenerFactory <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"

View File

@ -36,7 +36,6 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* @see org.alfresco.repo.cache.EhCacheAdapter * @see org.alfresco.repo.cache.EhCacheAdapter
@ -45,9 +44,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/ */
public class CacheTest extends TestCase public class CacheTest extends TestCase
{ {
private static ApplicationContext ctx =new ClassPathXmlApplicationContext( private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(
new String[] {"classpath:cache-test-context.xml", ApplicationContextHelper.CONFIG_LOCATIONS[0]} new String[] {
); "classpath:cache-test/cache-test-context.xml",
ApplicationContextHelper.CONFIG_LOCATIONS[0]});
private ServiceRegistry serviceRegistry; private ServiceRegistry serviceRegistry;
private SimpleCache<String, Object> standaloneCache; private SimpleCache<String, Object> standaloneCache;
@ -77,9 +77,9 @@ public class CacheTest extends TestCase
public void testSetUp() throws Exception public void testSetUp() throws Exception
{ {
CacheManager cacheManager = (CacheManager) ctx.getBean("ehCacheManager"); CacheManager cacheManager = (CacheManager) ctx.getBean("testEHCacheManager");
assertNotNull(cacheManager); assertNotNull(cacheManager);
CacheManager cacheManagerCheck = (CacheManager) ctx.getBean("ehCacheManager"); CacheManager cacheManagerCheck = (CacheManager) ctx.getBean("testEHCacheManager");
assertTrue(cacheManager == cacheManagerCheck); assertTrue(cacheManager == cacheManagerCheck);
assertNotNull(serviceRegistry); assertNotNull(serviceRegistry);
@ -344,7 +344,7 @@ public class CacheTest extends TestCase
*/ */
public void testPerformance() throws Exception public void testPerformance() throws Exception
{ {
for (int i = 0; i < 5; i++) for (int i = 0; i < 6; i++)
{ {
int count = (int) Math.pow(10D, (double)i); int count = (int) Math.pow(10D, (double)i);
@ -371,6 +371,32 @@ public class CacheTest extends TestCase
} }
} }
/**
* @see #testPerformance()
*/
public static void main(String ... args)
{
try
{
CacheTest test = new CacheTest();
test.setUp();
System.out.println("Press any key to run test ...");
System.in.read();
test.testPerformance();
System.out.println("Press any key to shutdown ...");
System.in.read();
test.tearDown();
}
catch (Throwable e)
{
e.printStackTrace();
}
finally
{
ApplicationContextHelper.closeApplicationContext();
}
}
/** /**
* Starts off with a <tt>null</tt> in the backing cache and adds a value to the * Starts off with a <tt>null</tt> in the backing cache and adds a value to the
* transactional cache. There should be no problem with this. * transactional cache. There should be no problem with this.
@ -412,7 +438,7 @@ public class CacheTest extends TestCase
assertEquals("The start value isn't correct", startValue, transactionalCache.get(startKey)); assertEquals("The start value isn't correct", startValue, transactionalCache.get(startKey));
for (int i = 0; i < 50000; i++) for (int i = 0; i < 205000; i++)
{ {
Object value = Integer.valueOf(i); Object value = Integer.valueOf(i);
String key = value.toString(); String key = value.toString();

View File

@ -43,6 +43,13 @@ import org.springframework.core.io.Resource;
*/ */
public class EhCacheManagerFactoryBean implements FactoryBean, InitializingBean, DisposableBean public class EhCacheManagerFactoryBean implements FactoryBean, InitializingBean, DisposableBean
{ {
static
{
// https://jira.terracotta.org/jira/browse/EHC-652
// Force old-style LruMemoryStore
System.setProperty("net.sf.ehcache.use.classic.lru", "true");
}
protected final Log logger = LogFactory.getLog(EhCacheManagerFactoryBean.class); protected final Log logger = LogFactory.getLog(EhCacheManagerFactoryBean.class);
private Resource configLocation; private Resource configLocation;

View File

@ -63,6 +63,13 @@ import org.springframework.util.ResourceUtils;
*/ */
public class InternalEhCacheManagerFactoryBean implements FactoryBean<CacheManager>, CacheProvider public class InternalEhCacheManagerFactoryBean implements FactoryBean<CacheManager>, CacheProvider
{ {
static
{
// https://jira.terracotta.org/jira/browse/EHC-652
// Force old-style LruMemoryStore
System.setProperty("net.sf.ehcache.use.classic.lru", "true");
}
public static final String CUSTOM_CONFIGURATION_FILE = "classpath:alfresco/extension/ehcache-custom.xml"; public static final String CUSTOM_CONFIGURATION_FILE = "classpath:alfresco/extension/ehcache-custom.xml";
public static final String DEFAULT_CONFIGURATION_FILE = "classpath:alfresco/ehcache-default.xml"; public static final String DEFAULT_CONFIGURATION_FILE = "classpath:alfresco/ehcache-default.xml";

View File

@ -21,17 +21,17 @@ package org.alfresco.repo.cache;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.Map;
import java.util.Set;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheException;
import net.sf.ehcache.CacheManager; import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionListener; import org.alfresco.repo.transaction.TransactionListener;
import org.alfresco.util.EqualsHelper; import org.alfresco.util.EqualsHelper;
import org.apache.commons.collections.map.LRUMap;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
@ -83,9 +83,6 @@ public class TransactionalCache<K extends Serializable, V extends Object>
/** the shared cache that will get updated after commits */ /** the shared cache that will get updated after commits */
private SimpleCache<Serializable, Object> sharedCache; private SimpleCache<Serializable, Object> sharedCache;
/** the manager to control Ehcache caches */
private CacheManager cacheManager;
/** the maximum number of elements to be contained in the cache */ /** the maximum number of elements to be contained in the cache */
private int maxCacheSize = 500; private int maxCacheSize = 500;
@ -145,13 +142,10 @@ public class TransactionalCache<K extends Serializable, V extends Object>
} }
/** /**
* Set the manager to activate and control the cache instances * No-op
*
* @param cacheManager
*/ */
public void setCacheManager(CacheManager cacheManager) public void setCacheManager(CacheManager cacheManager)
{ {
this.cacheManager = cacheManager;
} }
/** /**
@ -185,7 +179,6 @@ public class TransactionalCache<K extends Serializable, V extends Object>
public void afterPropertiesSet() throws Exception public void afterPropertiesSet() throws Exception
{ {
Assert.notNull(name, "name property not set"); Assert.notNull(name, "name property not set");
Assert.notNull(cacheManager, "cacheManager property not set");
// generate the resource binding key // generate the resource binding key
resourceKeyTxnData = RESOURCE_KEY_TXN_DATA + "." + name; resourceKeyTxnData = RESOURCE_KEY_TXN_DATA + "." + name;
// Refine the log category // Refine the log category
@ -201,30 +194,14 @@ public class TransactionalCache<K extends Serializable, V extends Object>
TransactionData data = (TransactionData) AlfrescoTransactionSupport.getResource(resourceKeyTxnData); TransactionData data = (TransactionData) AlfrescoTransactionSupport.getResource(resourceKeyTxnData);
if (data == null) if (data == null)
{ {
String txnId = AlfrescoTransactionSupport.getTransactionId();
data = new TransactionData(); data = new TransactionData();
// create and initialize caches // create and initialize caches
data.updatedItemsCache = new Cache( data.updatedItemsCache = new LRUMap(maxCacheSize);
name + "_"+ txnId + "_updates", data.removedItemsCache = new HashSet<K>(maxCacheSize * 2);
maxCacheSize, false, true, 0, 0);
data.removedItemsCache = new Cache( // ensure that we get the transaction callbacks as we have bound the unique
name + "_" + txnId + "_removes", // transactional caches to a common manager
maxCacheSize, false, true, 0, 0); AlfrescoTransactionSupport.bindListener(this);
try
{
cacheManager.addCache(data.updatedItemsCache);
cacheManager.addCache(data.removedItemsCache);
}
catch (CacheException e)
{
throw new AlfrescoRuntimeException("Failed to add txn caches to manager", e);
}
finally
{
// ensure that we get the transaction callbacks as we have bound the unique
// transactional caches to a common manager
AlfrescoTransactionSupport.bindListener(this);
}
AlfrescoTransactionSupport.bindResource(resourceKeyTxnData, data); AlfrescoTransactionSupport.bindResource(resourceKeyTxnData, data);
} }
return data; return data;
@ -266,9 +243,9 @@ public class TransactionalCache<K extends Serializable, V extends Object>
keys.addAll(backingKeys); keys.addAll(backingKeys);
} }
// add keys // add keys
keys.addAll((Collection<K>) txnData.updatedItemsCache.getKeys()); keys.addAll(txnData.updatedItemsCache.keySet());
// remove keys // remove keys
keys.removeAll((Collection<K>) txnData.removedItemsCache.getKeys()); keys.removeAll(txnData.removedItemsCache);
} }
else else
{ {
@ -324,7 +301,7 @@ public class TransactionalCache<K extends Serializable, V extends Object>
if (!txnData.isClearOn) // deletions cache only useful before a clear if (!txnData.isClearOn) // deletions cache only useful before a clear
{ {
// check to see if the key is present in the transaction's removed items // check to see if the key is present in the transaction's removed items
if (txnData.removedItemsCache.get(key) != null) if (txnData.removedItemsCache.contains(key))
{ {
// it has been removed in this transaction // it has been removed in this transaction
if (isDebugEnabled) if (isDebugEnabled)
@ -338,10 +315,9 @@ public class TransactionalCache<K extends Serializable, V extends Object>
} }
// check for the item in the transaction's new/updated items // check for the item in the transaction's new/updated items
Element element = txnData.updatedItemsCache.get(key); CacheBucket<V> bucket = (CacheBucket<V>) txnData.updatedItemsCache.get(key);
if (element != null) if (bucket != null)
{ {
CacheBucket<V> bucket = (CacheBucket<V>) element.getValue();
V value = bucket.getValue(); V value = bucket.getValue();
// element was found in transaction-specific updates/additions // element was found in transaction-specific updates/additions
if (isDebugEnabled) if (isDebugEnabled)
@ -429,7 +405,7 @@ public class TransactionalCache<K extends Serializable, V extends Object>
{ {
// we have an active transaction - add the item into the updated cache for this transaction // we have an active transaction - add the item into the updated cache for this transaction
// are we in an overflow condition? // are we in an overflow condition?
if (txnData.updatedItemsCache.getMemoryStoreSize() >= maxCacheSize) if (txnData.updatedItemsCache.isFull())
{ {
// overflow about to occur or has occured - we can only guarantee non-stale // overflow about to occur or has occured - we can only guarantee non-stale
// data by clearing the shared cache after the transaction. Also, the // data by clearing the shared cache after the transaction. Also, the
@ -456,8 +432,7 @@ public class TransactionalCache<K extends Serializable, V extends Object>
// The value didn't exist before // The value didn't exist before
bucket = new NewCacheBucket<V>(nullMarker, value); bucket = new NewCacheBucket<V>(nullMarker, value);
} }
Element element = new Element(key, bucket); txnData.updatedItemsCache.put(key, bucket);
txnData.updatedItemsCache.put(element);
// remove the item from the removed cache, if present // remove the item from the removed cache, if present
txnData.removedItemsCache.remove(key); txnData.removedItemsCache.remove(key);
// done // done
@ -517,7 +492,7 @@ public class TransactionalCache<K extends Serializable, V extends Object>
else else
{ {
// are we in an overflow condition? // are we in an overflow condition?
if (txnData.removedItemsCache.getMemoryStoreSize() >= maxCacheSize) if (txnData.removedItemsCache.size() >= maxCacheSize)
{ {
// overflow about to occur or has occured - we can only guarantee non-stale // overflow about to occur or has occured - we can only guarantee non-stale
// data by clearing the shared cache after the transaction. Also, the // data by clearing the shared cache after the transaction. Also, the
@ -539,9 +514,7 @@ public class TransactionalCache<K extends Serializable, V extends Object>
else else
{ {
// Create a bucket to remove the value from the shared cache // Create a bucket to remove the value from the shared cache
CacheBucket<V> removeBucket = new RemoveCacheBucket<V>(existingValue); txnData.removedItemsCache.add(key);
Element element = new Element(key, removeBucket);
txnData.removedItemsCache.put(element);
} }
} }
} }
@ -590,8 +563,8 @@ public class TransactionalCache<K extends Serializable, V extends Object>
// and also serves to ensure that the shared cache will be ignored // and also serves to ensure that the shared cache will be ignored
// for the remainder of the transaction // for the remainder of the transaction
txnData.isClearOn = true; txnData.isClearOn = true;
txnData.updatedItemsCache.removeAll(); txnData.updatedItemsCache.clear();
txnData.removedItemsCache.removeAll(); txnData.removedItemsCache.clear();
} }
} }
else // no transaction else // no transaction
@ -654,23 +627,22 @@ public class TransactionalCache<K extends Serializable, V extends Object>
// transfer any removed items // transfer any removed items
// any removed items will have also been removed from the in-transaction updates // any removed items will have also been removed from the in-transaction updates
// propogate the deletes to the shared cache // propogate the deletes to the shared cache
List<Serializable> keys = txnData.removedItemsCache.getKeys(); for (Serializable key : txnData.removedItemsCache)
for (Serializable key : keys)
{ {
sharedCache.remove(key); sharedCache.remove(key);
} }
if (isDebugEnabled) if (isDebugEnabled)
{ {
logger.debug("Removed " + keys.size() + " values from shared cache"); logger.debug("Removed " + txnData.removedItemsCache.size() + " values from shared cache");
} }
} }
// transfer updates // transfer updates
List<Serializable> keys = txnData.updatedItemsCache.getKeys(); Set<K> keys = (Set<K>) txnData.updatedItemsCache.keySet();
for (Serializable key : keys) for (Map.Entry<K, CacheBucket<V>> entry : (Set<Map.Entry<K, CacheBucket<V>>>) txnData.updatedItemsCache.entrySet())
{ {
Element element = txnData.updatedItemsCache.get(key); K key = entry.getKey();
CacheBucket<V> bucket = (CacheBucket<V>) element.getObjectValue(); CacheBucket<V> bucket = entry.getValue();
bucket.doPostCommit(sharedCache, key); bucket.doPostCommit(sharedCache, key);
} }
if (isDebugEnabled) if (isDebugEnabled)
@ -705,8 +677,6 @@ public class TransactionalCache<K extends Serializable, V extends Object>
*/ */
private void removeCaches(TransactionData txnData) private void removeCaches(TransactionData txnData)
{ {
cacheManager.removeCache(txnData.updatedItemsCache.getName());
cacheManager.removeCache(txnData.removedItemsCache.getName());
txnData.isClosed = true; txnData.isClosed = true;
} }
@ -830,30 +800,11 @@ public class TransactionalCache<K extends Serializable, V extends Object>
} }
} }
/**
* Data holder to keep track of cache removals. This bucket assumes the previous existence
* of an entry in the shared cache.
*/
private static class RemoveCacheBucket<BV> extends UpdateCacheBucket<BV>
{
private static final long serialVersionUID = -7736719065158540252L;
public RemoveCacheBucket(BV originalValue)
{
super(originalValue, null);
}
public void doPostCommit(SimpleCache<Serializable, Object> sharedCache, Serializable key)
{
// We remove the shared entry whether it has moved on or not
sharedCache.remove(key);
}
}
/** Data holder to bind data to the transaction */ /** Data holder to bind data to the transaction */
private class TransactionData private class TransactionData
{ {
private Cache updatedItemsCache; private LRUMap updatedItemsCache;
private Cache removedItemsCache; private Set<K> removedItemsCache;
private boolean haveIssuedFullWarning; private boolean haveIssuedFullWarning;
private boolean isClearOn; private boolean isClearOn;
private boolean isClosed; private boolean isClosed;

View File

@ -0,0 +1,41 @@
<?xml version='1.0' encoding='UTF-8'?>
<ehcache>
<!-- defaults -->
<diskStore
path="java.io.tmpdir"
/>
<defaultCache
maxElementsInMemory="5000"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="false"
>
</defaultCache>
<cache
name="cache1"
maxElementsInMemory="200000"
eternal="true"
overflowToDisk="false"
statistics="false"
/>
<cache
name="backingCache"
maxElementsInMemory="200000"
eternal="true"
overflowToDisk="false"
statistics="false"
/>
<cache
name="objectCache"
maxElementsInMemory="200000"
eternal="true"
overflowToDisk="false"
statistics="false"
/>
</ehcache>

View File

@ -4,15 +4,18 @@
<!-- sample bean configuration to test cache configurations --> <!-- sample bean configuration to test cache configurations -->
<beans> <beans>
<bean name="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" > <bean name="testEHCacheManager" class="org.alfresco.repo.cache.EhCacheManagerFactoryBean" >
<property name="configLocation"> <property name="configLocation">
<value>classpath:alfresco/ehcache-default.xml</value> <value>classpath:cache-test/cache-test-config.xml</value>
</property> </property>
</bean> </bean>
<bean name="ehCache1" class="org.alfresco.repo.cache.EhCacheAdapter"> <bean name="ehCache1" class="org.alfresco.repo.cache.EhCacheAdapter">
<property name="cache"> <property name="cache">
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" > <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" >
<property name="cacheManager">
<ref bean="testEHCacheManager" />
</property>
<property name="cacheName"> <property name="cacheName">
<value>cache1</value> <value>cache1</value>
</property> </property>
@ -23,6 +26,9 @@
<bean name="backingCache" class="org.alfresco.repo.cache.EhCacheAdapter"> <bean name="backingCache" class="org.alfresco.repo.cache.EhCacheAdapter">
<property name="cache"> <property name="cache">
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" > <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" >
<property name="cacheManager">
<ref bean="testEHCacheManager" />
</property>
<property name="cacheName"> <property name="cacheName">
<value>backingCache</value> <value>backingCache</value>
</property> </property>
@ -34,20 +40,20 @@
<property name="sharedCache"> <property name="sharedCache">
<ref bean="backingCache" /> <ref bean="backingCache" />
</property> </property>
<property name="cacheManager" >
<ref bean="ehCacheManager" />
</property>
<property name="name"> <property name="name">
<value>transactionalCache</value> <value>transactionalCache</value>
</property> </property>
<property name="maxCacheSize"> <property name="maxCacheSize">
<value>20000</value> <value>200000</value>
</property> </property>
</bean> </bean>
<bean name="objectCache" class="org.alfresco.repo.cache.EhCacheAdapter"> <bean name="objectCache" class="org.alfresco.repo.cache.EhCacheAdapter">
<property name="cache"> <property name="cache">
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" > <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" >
<property name="cacheManager">
<ref bean="testEHCacheManager" />
</property>
<property name="cacheName"> <property name="cacheName">
<value>objectCache</value> <value>objectCache</value>
</property> </property>