Author: shuber
Date: Tue Oct 16 15:36:55 2007
New Revision: 18880

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18880&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:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/cache/Ja=
hiaBatchingClusterCacheHibernateProvider.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
he.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
heFactory.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
heImplementation.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/ClusterServiceCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/batch/BatchingClusterServiceCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/batch/BatchingClusterServiceCacheProvider.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ehc=
ache/EhCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/jms=
/JMSCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/osc=
ache/OSCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ref=
erence/ReferenceCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ref=
erence/ReferenceCacheProvider.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/sim=
ple/SimpleCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/tre=
ecache/TreeCacheImpl.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/settings/SettingsB=
ean.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/administration/s=
tatus.jsp

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/ca=
che/JahiaBatchingClusterCacheHibernateProvider.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/hibernate/cache/JahiaBatchingClusterCacheHi=
bernateProvider.java&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/cache/Ja=
hiaBatchingClusterCacheHibernateProvider.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/cache/Ja=
hiaBatchingClusterCacheHibernateProvider.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/Cache.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/Cache.java&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
he.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
he.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/CacheFactory.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/CacheFactory.java&rev=3D1888=
0&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
heFactory.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
heFactory.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/CacheImplementation.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/CacheImplementation.java&rev=
=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
heImplementation.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/Cac=
heImplementation.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/clusterservice/ClusterServiceCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/clusterservice/ClusterServic=
eCacheImpl.java&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/ClusterServiceCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/ClusterServiceCacheImpl.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/clusterservice/batch/BatchingClusterServiceCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/clusterservice/batch/Batchin=
gClusterServiceCacheImpl.java&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/batch/BatchingClusterServiceCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/batch/BatchingClusterServiceCacheImpl.java Tue Oct 16 15:36:55 =
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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/clusterservice/batch/BatchingClusterServiceCacheProvider.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/clusterservice/batch/Batchin=
gClusterServiceCacheProvider.java&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/batch/BatchingClusterServiceCacheProvider.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/clu=
sterservice/batch/BatchingClusterServiceCacheProvider.java Tue Oct 16 15:36=
:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/ehcache/EhCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/ehcache/EhCacheImpl.java&rev=
=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ehc=
ache/EhCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ehc=
ache/EhCacheImpl.java Tue Oct 16 15:36:55 2007
@@ -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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/jms/JMSCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/jms/JMSCacheImpl.java&rev=3D=
18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/jms=
/JMSCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/jms=
/JMSCacheImpl.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/oscache/OSCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/oscache/OSCacheImpl.java&rev=
=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/osc=
ache/OSCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/osc=
ache/OSCacheImpl.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/reference/ReferenceCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/reference/ReferenceCacheImpl=
.java&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ref=
erence/ReferenceCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ref=
erence/ReferenceCacheImpl.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/reference/ReferenceCacheProvider.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/reference/ReferenceCacheProv=
ider.java&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ref=
erence/ReferenceCacheProvider.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/ref=
erence/ReferenceCacheProvider.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/simple/SimpleCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/simple/SimpleCacheImpl.java&=
rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/sim=
ple/SimpleCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/sim=
ple/SimpleCacheImpl.java Tue Oct 16 15:36:55 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cac=
he/treecache/TreeCacheImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/cache/treecache/TreeCacheImpl.java=
&rev=3D18880&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/tre=
ecache/TreeCacheImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cache/tre=
ecache/TreeCacheImpl.java Tue Oct 16 15:36:55 2007
@@ -316,6 +316,19 @@
         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;
         /*
@@ -332,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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/settings/Set=
tingsBean.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/settings/SettingsBean.java&rev=3D18880&repn=
ame=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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/settings/SettingsB=
ean.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/settings/SettingsB=
ean.java Tue Oct 16 15:36:55 2007
@@ -105,8 +105,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;
@@ -676,7 +679,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 ();
@@ -685,13 +688,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);
@@ -1670,8 +1708,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;

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/administra=
tion/status.jsp
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/webapp/jsp/jahia/administration/status.jsp&rev=3D18880&rep=
name=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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/administration/s=
tatus.jsp (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/administration/s=
tatus.jsp Tue Oct 16 15:36:55 2007
@@ -210,6 +210,8 @@
                 <jahia:adminResourceBundle resourceName=3D"org.jahia.admin=
.status.ManageStatus.totalHits.label"/>,
                 <jahia:adminResourceBundle resourceName=3D"org.jahia.admin=
.status.ManageStatus.efficiency.label"/> :
                 <%=3DefficiencyStr%> %
+                <jahia:adminResourceBundle resourceName=3D"org.jahia.admin=
.status.ManageStatus.groupSize.label"/> :
+                <%=3DcurCache.getGroupsSize()%>
             </td>
             <td>
                 <input type=3D"submit" name=3D"flush_<%=3DcurCache.getName=
()%>" value=3D"<jahia:adminResourceBundle resourceName=3D"org.jahia.admin.s=
tatus.ManageStatus.flush.label"/>">

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to