You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/09/26 13:56:43 UTC
svn commit: r699287 - in /tomcat/trunk: java/org/apache/catalina/core/
java/org/apache/naming/resources/ webapps/docs/config/
Author: markt
Date: Fri Sep 26 04:56:42 2008
New Revision: 699287
URL: http://svn.apache.org/viewvc?rev=699287&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/trunk/java/org/apache/catalina/core/StandardContext.java
tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java
tomcat/trunk/java/org/apache/naming/resources/ProxyDirContext.java
tomcat/trunk/webapps/docs/config/context.xml
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=699287&r1=699286&r2=699287&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Fri Sep 26 04:56:42 2008
@@ -626,6 +626,12 @@
/**
+ * Cache object max size in KB.
+ */
+ protected int cacheObjectMaxSize = 512; // 512K
+
+
+ /**
* Cache TTL in ms.
*/
protected int cacheTTL = 5000;
@@ -789,6 +795,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.
*/
@@ -1830,6 +1852,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/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml?rev=699287&r1=699286&r2=699287&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml (original)
+++ tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml Fri Sep 26 04:56:42 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/trunk/java/org/apache/naming/resources/BaseDirContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java?rev=699287&r1=699286&r2=699287&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java Fri Sep 26 04:56:42 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/trunk/java/org/apache/naming/resources/ProxyDirContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/ProxyDirContext.java?rev=699287&r1=699286&r2=699287&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/ProxyDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/ProxyDirContext.java Fri Sep 26 04:56:42 2008
@@ -78,7 +78,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/trunk/webapps/docs/config/context.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/context.xml?rev=699287&r1=699286&r2=699287&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/context.xml (original)
+++ tomcat/trunk/webapps/docs/config/context.xml Fri Sep 26 04:56:42 2008
@@ -284,6 +284,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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org