Author: shuber Date: Tue Oct 16 16:29:53 2007 New Revision: 18882 URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18882&repname= =3Djahia Log: Combined fix for : =
http://www.jahia.net/jira/browse/JAHIA-2531 OOM: OOM after 4 hours load in = live mode - 20 users LDAP - with ESI http://www.jahia.net/jira/browse/JAHIA-2532 OOM: ESI in front-end: moving a= section of 750 sub-pages -> leads to OOM http://www.jahia.net/jira/browse/JAHIA-2533 OOM: moving 30 sub pages in my = topbar with ESI in front-end Changes : = - clusterCacheMaxBatchSize in jahia.properties is now implemented - deactivated cluster batching if cluster is deactivated - cache status page now displays the number of groups for a cache - cache limits (max_cached_) are re-introduced, but need testing. - new group limits (max_cachedgroups_) have been introduced, but have not b= een tested yet. Modified: trunk/core/src/conf/java/JahiaAdministrationResources.properties trunk/core/src/conf/java/JahiaAdministrationResources_en.properties trunk/core/src/conf/java/JahiaAdministrationResources_fr.properties trunk/core/src/java/org/jahia/hibernate/cache/JahiaBatchingClusterCache= HibernateProvider.java trunk/core/src/java/org/jahia/services/cache/Cache.java trunk/core/src/java/org/jahia/services/cache/CacheFactory.java trunk/core/src/java/org/jahia/services/cache/CacheImplementation.java trunk/core/src/java/org/jahia/services/cache/clusterservice/ClusterServ= iceCacheImpl.java trunk/core/src/java/org/jahia/services/cache/clusterservice/batch/Batch= ingClusterServiceCacheImpl.java trunk/core/src/java/org/jahia/services/cache/clusterservice/batch/Batch= ingClusterServiceCacheProvider.java trunk/core/src/java/org/jahia/services/cache/ehcache/EhCacheImpl.java trunk/core/src/java/org/jahia/services/cache/jms/JMSCacheImpl.java trunk/core/src/java/org/jahia/services/cache/oscache/OSCacheImpl.java trunk/core/src/java/org/jahia/services/cache/reference/ReferenceCacheIm= pl.java trunk/core/src/java/org/jahia/services/cache/reference/ReferenceCachePr= ovider.java trunk/core/src/java/org/jahia/services/cache/simple/SimpleCacheImpl.java trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheImpl.ja= va trunk/core/src/java/org/jahia/settings/SettingsBean.java Modified: trunk/core/src/conf/java/JahiaAdministrationResources.properties URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/conf/j= ava/JahiaAdministrationResources.properties&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/conf/java/JahiaAdministrationResources.properties (origi= nal) +++ trunk/core/src/conf/java/JahiaAdministrationResources.properties Tue Oc= t 16 16:29:53 2007 @@ -713,6 +713,7 @@ org.jahia.admin.status.ManageStatus.flushLocks.label =3D Flush content obj= ect locks org.jahia.admin.status.ManageStatus.flush.label =3D Flush org.jahia.admin.status.ManageStatus.freeMemory.label =3D Free Memory +org.jahia.admin.status.ManageStatus.groupSize.label =3D Number of groups org.jahia.admin.status.ManageStatus.htmlCacheSize.label =3D HTML cache si= ze org.jahia.admin.status.ManageStatus.kB.label =3D KB org.jahia.admin.status.ManageStatus.max.label =3D max Modified: trunk/core/src/conf/java/JahiaAdministrationResources_en.properti= es URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/conf/j= ava/JahiaAdministrationResources_en.properties&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/conf/java/JahiaAdministrationResources_en.properties (or= iginal) +++ trunk/core/src/conf/java/JahiaAdministrationResources_en.properties Tue= Oct 16 16:29:53 2007 @@ -713,6 +713,7 @@ org.jahia.admin.status.ManageStatus.flushLocks.label =3D Flush content obj= ect locks org.jahia.admin.status.ManageStatus.flush.label =3D Flush org.jahia.admin.status.ManageStatus.freeMemory.label =3D Free Memory +org.jahia.admin.status.ManageStatus.groupSize.label=3DNumber of groups org.jahia.admin.status.ManageStatus.htmlCacheSize.label =3D HTML cache si= ze org.jahia.admin.status.ManageStatus.kB.label =3D KB org.jahia.admin.status.ManageStatus.max.label =3D max Modified: trunk/core/src/conf/java/JahiaAdministrationResources_fr.properti= es URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/conf/j= ava/JahiaAdministrationResources_fr.properties&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/conf/java/JahiaAdministrationResources_fr.properties (or= iginal) +++ trunk/core/src/conf/java/JahiaAdministrationResources_fr.properties Tue= Oct 16 16:29:53 2007 @@ -828,6 +828,7 @@ org.jahia.admin.status.ManageStatus.flushAllCaches.label =3D Purger tous l= es caches org.jahia.admin.status.ManageStatus.flushLocks.label =3D Purger les verrou= s d'objets de contenu org.jahia.admin.status.ManageStatus.freeMemory.label =3D M=C3=A9moire lib= re +org.jahia.admin.status.ManageStatus.groupSize.label =3D Nombre de groupes org.jahia.admin.status.ManageStatus.htmlCacheSize.label =3D Taille du cach= e HTML org.jahia.admin.status.ManageStatus.kB.label =3D Ko org.jahia.admin.status.ManageStatus.mB.label =3D Mo Modified: trunk/core/src/java/org/jahia/hibernate/cache/JahiaBatchingCluste= rCacheHibernateProvider.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/hibernate/cache/JahiaBatchingClusterCacheHibernateProvider.java&re= v=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/hibernate/cache/JahiaBatchingClusterCache= HibernateProvider.java (original) +++ trunk/core/src/java/org/jahia/hibernate/cache/JahiaBatchingClusterCache= HibernateProvider.java Tue Oct 16 16:29:53 2007 @@ -194,8 +194,18 @@ if (cacheBatch =3D=3D null) { cacheBatch =3D new ClusterMessageCacheBatch(); } + if (!clusterActivated) { + threadClusterBatch.set(cacheBatch); + return; + } cacheBatch.add(clusterCacheMessage); threadClusterBatch.set(cacheBatch); + if (cacheBatch.size() > maxBatchSize) { + if (logger.isDebugEnabled()) { + logger.debug("Maximum batch size reached (" + maxBatchSize= + "), sending cluster messages now..."); + syncClusterNow(); + } + } } = public void sendBatch() { Modified: trunk/core/src/java/org/jahia/services/cache/Cache.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/Cache.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/Cache.java (original) +++ trunk/core/src/java/org/jahia/services/cache/Cache.java Tue Oct 16 16:2= 9:53 2007 @@ -298,6 +298,16 @@ return cacheImplementation.size (); } = + /** + * Get the number of groups for this cache. This is an approximate val= ue + * as it is not synchronized. + * @return a long representing the number of elements in the cache gro= ups + * LRUMap. + */ + final public long getGroupsSize() { + return cacheImplementation.getGroupsSize(); + } + = /** <p>Returns the maximum size allowed for the cache.</p> * @@ -317,6 +327,24 @@ cacheImplementation.setCacheLimit(limit); } = + /** <p>Returns the maximum size allowed for the cache groups.</p> + * + * @return an integer representing the maximum cache groups size. Ret= urns -1 if + * there is no limit set. + */ + final public long getCacheGroupsLimit () { + return cacheImplementation.getCacheGroupsLimit(); + } + + + /** <p>Set the cache groups size limit. -1 will define an unlimited ca= che size.</p> + * + * @param groupsLimit the new size limit + */ + final public void setCacheGroupsLimit (long groupsLimit) { + cacheImplementation.setCacheGroupsLimit(groupsLimit); + } + = /** <p>Retrieves the cache name.</p> * Modified: trunk/core/src/java/org/jahia/services/cache/CacheFactory.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/CacheFactory.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/CacheFactory.java (origina= l) +++ trunk/core/src/java/org/jahia/services/cache/CacheFactory.java Tue Oct = 16 16:29:53 2007 @@ -54,6 +54,7 @@ = // hashmap containing the cache size limits specified in Jahia config. private Map cacheLimits =3D null; + private Map cacheGroupsLimits =3D null; private boolean JMXEnabled =3D false; private long freeMemoryLimit; /** Default constructor, creates a new <code>JahiaCacheFactory</code> = instance. @@ -72,12 +73,25 @@ = cacheProvider.init(settingsBean, this); = - cacheLimits =3D settingsBean.getJahiaMaxCachedValues(); + cacheLimits =3D settingsBean.getMaxCachedValues(); + cacheGroupsLimits =3D settingsBean.getMaxCachedGroupsValues(); freeMemoryLimit =3D new Long(settingsBean.getFreeMemoryLimit().spl= it("MB")[0]).longValue()*(1024*1024); + + // now we set the limits for caches that have already been created= , because this could happen before + // the init of this service. Iterator it =3D caches.values().iterator(); while (it.hasNext()) { Cache cache =3D (Cache) it.next(); - cache.setCacheLimit(freeMemoryLimit); + if (cacheLimits.containsKey(cache.getName())) { + Long cacheLimit =3D (Long) cacheLimits.get(cache.getName()= ); + cache.setCacheLimit(cacheLimit.longValue()); + } else { + cache.setCacheLimit(freeMemoryLimit); + } + if (cacheGroupsLimits.containsKey(cache.getName())) { + Long cacheGroupsLimit =3D (Long) cacheGroupsLimits.get(cac= he.getName()); + cache.setCacheGroupsLimit(cacheGroupsLimit.longValue()); + } } } = @@ -124,10 +138,13 @@ = // instanciate the new cache, can throw an JahiaInitialization exc= eption cache =3D new Cache (name, cacheProvider.newCacheImplementation(na= me)); -// if (cacheLimits.containsKey(name)) { -// String limitStr =3D (String) cacheLimits.get(name); + + if (cacheLimits.containsKey(name)) { + Long cacheLimit =3D (Long) cacheLimits.get(name); + cache.setCacheLimit(cacheLimit.longValue()); + } else { cache.setCacheLimit(freeMemoryLimit); -// } + } logger.debug ("Created cache instance [" + name + "]"); = if (registerCache (cache)) { @@ -169,7 +186,12 @@ = // At this point, the HTML cache does not exist, create it cache =3D new HtmlCache (cacheProvider.newCacheImplementation(Html= Cache.HTML_CACHE)); - cache.setCacheLimit(freeMemoryLimit); + if (cacheLimits.containsKey(cache.getName())) { + Long cacheLimit =3D (Long) cacheLimits.get(cache.getName()); + cache.setCacheLimit(cacheLimit.longValue()); + } else { + cache.setCacheLimit(freeMemoryLimit); + } caches.put (cache.getName(), cache); return cache; } @@ -182,7 +204,12 @@ = // At this point, the HTML cache does not exist, create it cache =3D new ContainerHTMLCache (cacheProvider.newCacheImplementa= tion(ContainerHTMLCache.CONTAINER_HTML_CACHE)); - cache.setCacheLimit(freeMemoryLimit); + if (cacheLimits.containsKey(cache.getName())) { + Long cacheLimit =3D (Long) cacheLimits.get(cache.getName()); + cache.setCacheLimit(cacheLimit.longValue()); + } else { + cache.setCacheLimit(freeMemoryLimit); + } caches.put (cache.getName(), cache); return cache; } Modified: trunk/core/src/java/org/jahia/services/cache/CacheImplementation.= java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/CacheImplementation.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/CacheImplementation.java (= original) +++ trunk/core/src/java/org/jahia/services/cache/CacheImplementation.java T= ue Oct 16 16:29:53 2007 @@ -40,6 +40,14 @@ = int size(); = + /** + * Get the number of groups for this cache. This is an approximate val= ue + * as it is not synchronized. + * @return a long representing the number of elements in the cache gro= ups + * LRUMap. + */ + public long getGroupsSize(); + void flushAll(boolean propagate); = void flushGroup(String groupName); @@ -65,4 +73,18 @@ * @param limit the new size limit */ void setCacheLimit (long limit); + + /** <p>Returns the maximum size allowed for the cache groups.</p> + * + * @return an integer representing the maximum cache groups size. Ret= urns -1 if + * there is no limit set. + */ + long getCacheGroupsLimit (); + + + /** <p>Set the cache groups size limit. -1 will define an unlimited ca= che size.</p> + * + * @param groupsLimit the new size limit + */ + void setCacheGroupsLimit (long groupsLimit); } Modified: trunk/core/src/java/org/jahia/services/cache/clusterservice/Clust= erServiceCacheImpl.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/clusterservice/ClusterServiceCacheImpl.java&rev=3D1= 8882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/clusterservice/ClusterServ= iceCacheImpl.java (original) +++ trunk/core/src/java/org/jahia/services/cache/clusterservice/ClusterServ= iceCacheImpl.java Tue Oct 16 16:29:53 2007 @@ -135,7 +135,15 @@ underlyingCacheImplementation.setCacheLimit(limit); } = - public void setName(String name) { + public long getCacheGroupsLimit() { + return underlyingCacheImplementation.getCacheGroupsLimit(); + } + + public void setCacheGroupsLimit(long groupsLimit) { + underlyingCacheImplementation.setCacheGroupsLimit(groupsLimit); + } + + public void setName(String name) { underlyingCacheImplementation.setName(name); } = @@ -147,4 +155,8 @@ return underlyingCacheImplementation.size(); } = + public long getGroupsSize() { + return underlyingCacheImplementation.getGroupsSize(); + } + } Modified: trunk/core/src/java/org/jahia/services/cache/clusterservice/batch= /BatchingClusterServiceCacheImpl.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/clusterservice/batch/BatchingClusterServiceCacheImp= l.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/clusterservice/batch/Batch= ingClusterServiceCacheImpl.java (original) +++ trunk/core/src/java/org/jahia/services/cache/clusterservice/batch/Batch= ingClusterServiceCacheImpl.java Tue Oct 16 16:29:53 2007 @@ -122,7 +122,15 @@ return underlyingCacheImplementation.getCacheLimit(); } = - public String getName() { + public long getCacheGroupsLimit() { + return underlyingCacheImplementation.getCacheGroupsLimit(); + } + + public void setCacheGroupsLimit(long groupsLimit) { + underlyingCacheImplementation.setCacheGroupsLimit(groupsLimit); + } + = + public String getName() { return underlyingCacheImplementation.getName(); } = @@ -146,4 +154,8 @@ return underlyingCacheImplementation.size(); } = + public long getGroupsSize() { + return underlyingCacheImplementation.getGroupsSize(); + } + = } Modified: trunk/core/src/java/org/jahia/services/cache/clusterservice/batch= /BatchingClusterServiceCacheProvider.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/clusterservice/batch/BatchingClusterServiceCachePro= vider.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/clusterservice/batch/Batch= ingClusterServiceCacheProvider.java (original) +++ trunk/core/src/java/org/jahia/services/cache/clusterservice/batch/Batch= ingClusterServiceCacheProvider.java Tue Oct 16 16:29:53 2007 @@ -156,8 +156,20 @@ cacheBatch =3D new ClusterMessageCacheBatch(); } = + if (!clusterService.isActivated()) { + threadClusterBatch.set(cacheBatch); + return; + } + cacheBatch.add(clusterCacheMessage); threadClusterBatch.set(cacheBatch); + + if (cacheBatch.size() > maxBatchSize) { + if (logger.isDebugEnabled()) { + logger.debug("Maximum batch size reached (" + maxBatchSize= + "), sending cluster messages now..."); + syncClusterNow(); + } + } } = } Modified: trunk/core/src/java/org/jahia/services/cache/ehcache/EhCacheImpl.= java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/ehcache/EhCacheImpl.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/ehcache/EhCacheImpl.java (= original) +++ trunk/core/src/java/org/jahia/services/cache/ehcache/EhCacheImpl.java T= ue Oct 16 16:29:53 2007 @@ -49,7 +49,7 @@ = public Object get(Object key) { Element element =3D ehCache.get(key); - if (element !=3D null) { + if (element !=3D null) { = return element.getValue(); } else { return null; @@ -70,6 +70,10 @@ return ehCache.getSize(); } = + public long getGroupsSize() { + return ehCacheGroups.getSize(); + } + public void flushAll(boolean propagate) { ehCache.removeAll(); ehCacheGroups.removeAll(); @@ -100,6 +104,21 @@ public void setCacheLimit(long limit) { } = + /** + * Not supported. + * @return + */ + public long getCacheGroupsLimit() { + return -1; + } + + /** + * Not supported. + * @param groupsLimit + */ + public void setCacheGroupsLimit(long groupsLimit) { + } + public void flushGroup(String groupName) { Set keysToFlush =3D null; Element element =3D ehCacheGroups.get(groupName); Modified: trunk/core/src/java/org/jahia/services/cache/jms/JMSCacheImpl.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/jms/JMSCacheImpl.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/jms/JMSCacheImpl.java (ori= ginal) +++ trunk/core/src/java/org/jahia/services/cache/jms/JMSCacheImpl.java Tue = Oct 16 16:29:53 2007 @@ -234,6 +234,14 @@ return cache.size (); } = + /** + * Not supported. + * @return + */ + public long getGroupsSize() { + return -1; + } + public void flushAll(boolean propagate) { synchronized (this) { // clears the cache @@ -296,6 +304,21 @@ cacheLimit =3D limit; } = + /** + * Not supported. + * @return + */ + public long getCacheGroupsLimit() { + return -1; + } + + /** + * Not supported. + * @param groupsLimit + */ + public void setCacheGroupsLimit(long groupsLimit) { + } + = /** <p>Retrieves the cache name.</p> * Modified: trunk/core/src/java/org/jahia/services/cache/oscache/OSCacheImpl.= java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/oscache/OSCacheImpl.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/oscache/OSCacheImpl.java (= original) +++ trunk/core/src/java/org/jahia/services/cache/oscache/OSCacheImpl.java T= ue Oct 16 16:29:53 2007 @@ -92,6 +92,14 @@ return -1; // not supported } = + /** + * Not supported. + * @return + */ + public long getGroupsSize() { + return -1; + } + public void flushAll(boolean propagate) { cache.flushGroup(name); } @@ -130,6 +138,21 @@ //To change body of implemented methods use File | Settings | File= Templates. } = + /** + * Not supported. + * @return + */ + public long getCacheGroupsLimit() { + return -1; + } + + /** + * Not supported. + * @param groupsLimit + */ + public void setCacheGroupsLimit(long groupsLimit) { + } + public void setName(String name) { this.name =3D name; } Modified: trunk/core/src/java/org/jahia/services/cache/reference/ReferenceC= acheImpl.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/reference/ReferenceCacheImpl.java&rev=3D18882&repna= me=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/reference/ReferenceCacheIm= pl.java (original) +++ trunk/core/src/java/org/jahia/services/cache/reference/ReferenceCacheIm= pl.java Tue Oct 16 16:29:53 2007 @@ -10,6 +10,7 @@ import org.apache.commons.collections.map.ReferenceMap; import org.apache.commons.collections.map.LRUMap; import org.apache.commons.collections.map.AbstractLinkedMap; +import org.apache.commons.collections.OrderedMapIterator; import org.jahia.services.cache.CacheImplementation; import org.jahia.services.cache.CacheListener; import org.jahia.services.cache.GroupCacheKey; @@ -79,7 +80,7 @@ } = private final Map cache =3D new ReferenceMap(); - private final Map groups; + private GroupLRUMap groups; private ReentrantWriterPreferenceReadWriteLock rwl =3D new ReentrantWr= iterPreferenceReadWriteLock(); private Sync readLock =3D rwl.readLock(); private Sync writeLock =3D rwl.writeLock(); @@ -87,8 +88,9 @@ private String name; private int maxGroups =3D 30000; private long cacheLimit =3D -1; + private long cacheGroupsLimit =3D -1; = - public ReferenceCacheImpl(String name, int maxGroups) { + public ReferenceCacheImpl(String name, int maxGroups) { this.name =3D name; this.maxGroups =3D maxGroups; groups =3D new GroupLRUMap(this, maxGroups); @@ -171,7 +173,11 @@ } } = - public void flushAll(boolean propagate) { + public long getGroupsSize() { + return groups.size(); + } + + public void flushAll(boolean propagate) { try { writeLock.acquire(); try { @@ -330,7 +336,52 @@ cacheLimit =3D limit; } = - public String toString() { + public long getCacheGroupsLimit() { + return cacheGroupsLimit; + } + + /** + * Value 0 is not supported (meaning you cannot really deactivate this= groups). + * @param groupsLimit + */ + public void setCacheGroupsLimit(long groupsLimit) { + try { + writeLock.acquire(); + try { + // if we set to an unlimited value, we simply keep the old= size. + if (groupsLimit !=3D -1) { + // now we must copy values to a new LRUMap with the co= rrect size; + if (groupsLimit !=3D 0) { + if ((groups.size() > groupsLimit)) { + // if the new limit is lower than the current = one, we must reduce the + // size of the groups structure. We do this by= simply copying into + // a smaller LRU map, starting with the LRU en= tries, so they will be + // flushed during the copy. + GroupLRUMap newGroups =3D new GroupLRUMap(this= , (int) groupsLimit); + OrderedMapIterator iterator =3D groups.ordered= MapIterator(); + while (iterator.hasNext()) { + iterator.next(); + newGroups.put(iterator.getKey(), iterator.= getValue()); + } + groups =3D newGroups; + } + } else { + // if we set 0, we create an LRU map with size 1, = as a size 0 is + // not allowed. + // TODO this is not compliant with the specificati= on ! + groups =3D new GroupLRUMap(this, 1); + } + this.cacheGroupsLimit =3D groupsLimit; + } + } finally { + writeLock.release(); + } + } catch (InterruptedException ie) { + logger.error("Error acquiring write lock", ie); + } + } + + public String toString() { return "ReferenceCache(" + getName() + ')'; } = Modified: trunk/core/src/java/org/jahia/services/cache/reference/ReferenceC= acheProvider.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/reference/ReferenceCacheProvider.java&rev=3D18882&r= epname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/reference/ReferenceCachePr= ovider.java (original) +++ trunk/core/src/java/org/jahia/services/cache/reference/ReferenceCachePr= ovider.java Tue Oct 16 16:29:53 2007 @@ -6,9 +6,13 @@ import org.jahia.services.cache.CacheService; import org.jahia.settings.SettingsBean; = +import java.util.HashMap; +import java.util.Map; + public class ReferenceCacheProvider implements CacheProvider { = private int cacheMaxGroups =3D 10000; + private Map cacheMaxGroupsTable =3D new HashMap(); = public void enableClusterSync() throws JahiaInitializationException { } Modified: trunk/core/src/java/org/jahia/services/cache/simple/SimpleCacheIm= pl.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/simple/SimpleCacheImpl.java&rev=3D18882&repname=3Dj= ahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/simple/SimpleCacheImpl.jav= a (original) +++ trunk/core/src/java/org/jahia/services/cache/simple/SimpleCacheImpl.jav= a Tue Oct 16 16:29:53 2007 @@ -43,6 +43,7 @@ = private String name; private long cacheLimit =3D -1; + private long cacheGroupsLimit =3D -1; private int ratio =3D 4; = private static LRUEntries allLRUsEntries =3D new LRUEntries(); @@ -116,6 +117,10 @@ return cache.size(); } = + public long getGroupsSize() { + return groups.size(); + } + public void flushAll(boolean propagate) { Collection c =3D new ArrayList(lruEntries.values()); synchronized(cache) { @@ -249,6 +254,15 @@ } } = + public long getCacheGroupsLimit() { + return cacheGroupsLimit; + } + + public void setCacheGroupsLimit(long groupsLimit) { + this.cacheGroupsLimit =3D groupsLimit; + // TODO : we need to resize the groups if the limit is below the c= urrent value + } + public String toString() { return "SimpleCache(" + getName() + ')'; } Modified: trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheI= mpl.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/services/cache/treecache/TreeCacheImpl.java&rev=3D18882&repname=3D= jahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheImpl.ja= va (original) +++ trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheImpl.ja= va Tue Oct 16 16:29:53 2007 @@ -304,9 +304,31 @@ } = = public int size() { - return getTreeCache().getNumberOfAttributes(getFqn()); + int size =3D 0; + try { + Set treeKeys =3D getTreeCache().getChildrenNames(getFqn()); + if (treeKeys !=3D null) { + size =3D treeKeys.size(); + } + } catch (CacheException e) { + logger.warn(getName(), e); + } + return size; } - = + + public long getGroupsSize() { + int size =3D 0; + try { + Set treeKeys =3D getTreeCache().getChildrenNames(groupsFqn); + if (treeKeys !=3D null) { + size =3D treeKeys.size(); + } + } catch (CacheException e) { + logger.warn(getName(), e); + } + return size; + } + public long getCacheLimit() { int cacheLimit =3D -1; /* @@ -323,6 +345,21 @@ = } = + /** + * Not supported + * @return + */ + public long getCacheGroupsLimit() { + return -1; + } + + /** + * Not supported + * @param groupsLimit + */ + public void setCacheGroupsLimit(long groupsLimit) { + } + private TreeCache initTreeCache(String aName) { boolean isTxCache =3D isTxCache(aName); = Modified: trunk/core/src/java/org/jahia/settings/SettingsBean.java URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o= rg/jahia/settings/SettingsBean.java&rev=3D18882&repname=3Djahia =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/core/src/java/org/jahia/settings/SettingsBean.java (original) +++ trunk/core/src/java/org/jahia/settings/SettingsBean.java Tue Oct 16 16:= 29:53 2007 @@ -104,8 +104,11 @@ // directory to output cache configuration file private String jahiaOutputCacheConfigDiskPath; = - // hashtable containing all max_cached_*... - private Hashtable jahiaMaxCachedValues; + // map containing all max_cached_*... + private Map maxCachedValues; + // map containing all max_cachedgroups_*... + private Map maxCachedGroupsValues; + = // this is the list of jahia.properties autodeployer values... private int jahiaWebAppsAutoDeploy; @@ -700,7 +703,7 @@ defaultSite =3D getString("defautSite"); = // load MaxCached values (max_cached_*) - jahiaMaxCachedValues =3D new Hashtable (); + maxCachedValues =3D new HashMap (); for (Enumeration e =3D properties.propertyNames (); e.hasMoreE= lements ();) { String key =3D (String)e.nextElement (); String lowerKey =3D key.toLowerCase ().trim (); @@ -709,13 +712,48 @@ String cacheKey =3D key.trim().substring (11); String value =3D properties.getProperty (key); if ((cacheKey !=3D null) && (value !=3D null)) { - jahiaMaxCachedValues.put (cacheKey, value); + Long maxSize =3D null; + try { + maxSize =3D Long.valueOf(value); + } catch (NumberFormatException nfe) { + logger.error("Error while parsing value for ca= che size " + cacheKey + ", ignoring..."); + maxSize =3D null; + } + if (maxSize !=3D null) { + maxCachedValues.put (cacheKey, maxSize); + } } else { logger.debug ("Ignoring cache key : " + key + " be= cause value or key is invalid (value=3D" + value + ")"); } } } = + // load MaxGroups values (max_cachedgroups_*) + maxCachedGroupsValues =3D new HashMap (); + for (Enumeration e =3D properties.propertyNames (); e.hasMoreE= lements ();) { + String key =3D (String)e.nextElement (); + String lowerKey =3D key.toLowerCase ().trim (); + // yes this is a max_cached value + if (lowerKey.indexOf ("max_cachedgroups_") =3D=3D 0) { + String cacheKey =3D key.trim().substring (11); + String value =3D properties.getProperty (key); + if ((cacheKey !=3D null) && (value !=3D null)) { + Long maxGroupSize =3D null; + try { + maxGroupSize =3D Long.valueOf(value); + } catch (NumberFormatException nfe) { + logger.error("Error while parsing value for ca= che group size " + cacheKey + ", ignoring..."); + maxGroupSize =3D null; + } + if (maxGroupSize !=3D null) { + maxCachedGroupsValues.put (cacheKey, maxGroupS= ize); + } + } else { + logger.debug ("Ignoring cache groups key : " + key= + " because value or key is invalid (value=3D" + value + ")"); + } + } + } + // webdav settings transformFilenames =3D getBoolean("transformFilenames", false); transformDirnames =3D getBoolean("transformDirnames", true); @@ -1686,8 +1724,11 @@ public String getJahiaJspDiskPath() { return jahiaJspDiskPath; } - public Hashtable getJahiaMaxCachedValues() { - return jahiaMaxCachedValues; + public Map getMaxCachedValues() { + return maxCachedValues; + } + public Map getMaxCachedGroupsValues() { + return maxCachedGroupsValues; } public String getJahiaNewWebAppsDiskPath() { return jahiaNewWebAppsDiskPath; _______________________________________________ cvs_list mailing list [email protected] http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list
