Author: markt
Date: Mon Oct 27 03:03:19 2008
New Revision: 708123

URL: http://svn.apache.org/viewvc?rev=708123&view=rev
Log:
Allow the maximum allowed size of a resource that is cached to be configured. 
The default of cacheMaxSize/20 gave too high a value for large caches.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
    tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java
    tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/ProxyDirContext.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc6.0.x/trunk/webapps/docs/config/context.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=708123&r1=708122&r2=708123&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Mon Oct 27 03:03:19 2008
@@ -133,13 +133,8 @@
   +1: markt, fhanik
   -1: 
 
-* Make the size limit on objects placed in the static resource cache 
configurable
-  http://svn.apache.org/viewvc?rev=699287&view=rev
-  +1: markt, remm, fhanik
-  -1: 
-
 * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45851
-  Fix NPE and outof order message processing issues
+  Fix NPE and out of order message processing issues
   http://svn.apache.org/viewvc?rev=699427&view=rev
   +1: markt
    0: 

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?rev=708123&r1=708122&r2=708123&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Mon 
Oct 27 03:03:19 2008
@@ -618,6 +618,12 @@
 
 
     /**
+     * Cache object max size in KB.
+     */
+    protected int cacheObjectMaxSize = 512; // 512K
+
+
+    /**
      * Cache TTL in ms.
      */
     protected int cacheTTL = 5000;
@@ -781,6 +787,22 @@
 
 
     /**
+     * Return the maximum size of objects to be cached in KB.
+     */
+    public int getCacheObjectMaxSize() {
+        return cacheObjectMaxSize;
+    }
+
+
+    /**
+     * Set the maximum size of objects to be placed the cache in KB.
+     */
+    public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
+        this.cacheObjectMaxSize = cacheObjectMaxSize;
+    }
+
+
+    /**
      * Return the "follow standard delegation model" flag used to configure
      * our ClassLoader.
      */
@@ -1823,6 +1845,8 @@
             ((BaseDirContext) resources).setCached(isCachingAllowed());
             ((BaseDirContext) resources).setCacheTTL(getCacheTTL());
             ((BaseDirContext) resources).setCacheMaxSize(getCacheMaxSize());
+            ((BaseDirContext) resources).setCacheObjectMaxSize(
+                    getCacheObjectMaxSize());
         }
         if (resources instanceof FileDirContext) {
             filesystemBased = true;

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml?rev=708123&r1=708122&r2=708123&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml 
Mon Oct 27 03:03:19 2008
@@ -57,6 +57,10 @@
                description="Maximum cache size in KB"
                type="int"/>
       
+    <attribute name="cacheObjectMaxSize"
+               description="Maximum cached object size in KB"
+               type="int"/>
+      
     <attribute name="cacheTTL"
                description="Time interval in ms between cache refeshes"
                type="int"/>

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java?rev=708123&r1=708122&r2=708123&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java 
Mon Oct 27 03:03:19 2008
@@ -105,11 +105,17 @@
 
 
     /**
-     * Max size of resources which will have their content cached.
+     * Max size of cache for resources.
      */
     protected int cacheMaxSize = 10240; // 10 MB
 
 
+    /**
+     * Max size of resources that will be content cached.
+     */
+    protected int cacheObjectMaxSize = 512; // 512 K
+
+
     // ------------------------------------------------------------- Properties
 
 
@@ -192,6 +198,22 @@
     }
 
 
+    /**
+     * Return the maximum size of objects to be cached in KB.
+     */
+    public int getCacheObjectMaxSize() {
+        return cacheObjectMaxSize;
+    }
+
+
+    /**
+     * Set the maximum size of objects to be placed the cache in KB.
+     */
+    public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
+        this.cacheObjectMaxSize = cacheObjectMaxSize;
+    }
+
+
     // --------------------------------------------------------- Public Methods
 
 

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/ProxyDirContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/ProxyDirContext.java?rev=708123&r1=708122&r2=708123&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/ProxyDirContext.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/ProxyDirContext.java 
Mon Oct 27 03:03:19 2008
@@ -76,7 +76,12 @@
                 }
                 cache.setCacheMaxSize(baseDirContext.getCacheMaxSize());
                 cacheTTL = baseDirContext.getCacheTTL();
-                cacheObjectMaxSize = baseDirContext.getCacheMaxSize() / 20;
+                cacheObjectMaxSize = baseDirContext.getCacheObjectMaxSize();
+                // cacheObjectMaxSize must be less than cacheMaxSize
+                // Set a sensible limit
+                if (cacheObjectMaxSize > baseDirContext.getCacheMaxSize()/20) {
+                    cacheObjectMaxSize = baseDirContext.getCacheMaxSize()/20;
+                }
             }
         }
         hostName = (String) env.get(HOST);

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=708123&r1=708122&r2=708123&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Mon Oct 27 03:03:19 2008
@@ -102,6 +102,11 @@
         the functionality to lock out a user after too many failed logins.
         (markt)
       </add>
+      <add>
+        Make the upper size limit of the static resource cache configurable
+        since the default of <code>cacheMaxSize/20</code> gave too high a value
+        for large caches. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Coyote">

Modified: tomcat/tc6.0.x/trunk/webapps/docs/config/context.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/config/context.xml?rev=708123&r1=708122&r2=708123&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/config/context.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/config/context.xml Mon Oct 27 03:03:19 
2008
@@ -292,6 +292,14 @@
         (10 megabytes).</p>
       </attribute>
 
+      <attribute name="cacheObjectMaxSize" required="false">
+        <p>Maximum size of the static resource that will be placed in the 
cache.
+        If not specified, the default value is <code>512</code>
+        (512 kilobytes). If this value is greater than
+        <code>cacheMaxSize/20</code> it will be reduced to
+        <code>cacheMaxSize/20</code>.</p>
+      </attribute>
+
       <attribute name="cacheTTL" required="false">
         <p>Amount of time in milliseconds between cache entries revalidation.
         If not specified, the default value is <code>5000</code> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to