You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by sg...@apache.org on 2015/06/26 14:21:40 UTC

svn commit: r1687766 - in /jspwiki/trunk: jspwiki-portable/src/overlay/launchers/tomcat/ jspwiki-portable/src/overlay/woas/webapps/private/WEB-INF/classes/ jspwiki-portable/src/overlay/woas/webapps/public/WEB-INF/classes/ jspwiki-war/src/main/java/org/...

Author: sgoeschl
Date: Fri Jun 26 12:21:39 2015
New Revision: 1687766

URL: http://svn.apache.org/r1687766
Log:
[JSPWIKI-888] Enable cache timeouts for Portable JSPWiki. Provide a "ehcache.xml" for the two default installations and enforce a timout of 24 hours for cache entries.

Added:
    jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/private/WEB-INF/classes/ehcache.xml   (with props)
    jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/public/WEB-INF/classes/ehcache.xml   (with props)
Modified:
    jspwiki/trunk/jspwiki-portable/src/overlay/launchers/tomcat/woas.sh
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/CachingProvider.java

Modified: jspwiki/trunk/jspwiki-portable/src/overlay/launchers/tomcat/woas.sh
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-portable/src/overlay/launchers/tomcat/woas.sh?rev=1687766&r1=1687765&r2=1687766&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-portable/src/overlay/launchers/tomcat/woas.sh (original)
+++ jspwiki/trunk/jspwiki-portable/src/overlay/launchers/tomcat/woas.sh Fri Jun 26 12:21:39 2015
@@ -19,6 +19,7 @@ export CATALINA_BASE=${JSPWIKI_HOME}
 export CATALINA_OUT=${CATALINA_BASE}/logs/catalina.out
 export CATALINA_TMPDIR=${CATALINA_BASE}/temp
 export CATALINA_OPTS="-Xmx128m"
+# export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 -Xmx128m"
 
 # invoke the Tomcat start script from the JSPWIKI_HOME
 # in order to use relative path names

Added: jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/private/WEB-INF/classes/ehcache.xml
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/private/WEB-INF/classes/ehcache.xml?rev=1687766&view=auto
==============================================================================
--- jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/private/WEB-INF/classes/ehcache.xml (added)
+++ jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/private/WEB-INF/classes/ehcache.xml Fri Jun 26 12:21:39 2015
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<ehcache>
+
+    <!-- Sets the path to the directory where cache .data files are created.
+
+         If the path is a Java System Property it is replaced by
+         its value in the running VM. The following properties are translated:
+
+            user.home - User's home directory
+            user.dir - User's current working directory
+            java.io.tmpdir - Default temp file path
+    -->
+    <diskStore path="java.io.tmpdir" />
+    <!--
+    The following attributes are required:
+
+    maxElementsInMemory            - Sets the maximum number of objects that will be created in memory
+    eternal                        - Sets whether elements are eternal. If eternal,  timeouts are ignored and the
+                                     element is never expired.
+    overflowToDisk                 - Sets whether elements can overflow to disk when the in-memory cache
+                                     has reached the maxInMemory limit.
+
+    The following attributes are optional:
+    timeToIdleSeconds              - Sets the time to idle for an element before it expires.
+                                     i.e. The maximum amount of time between accesses before an element expires
+                                     Is only used if the element is not eternal.
+                                     Optional attribute. A value of 0 means that an Element can idle for infinity.
+                                     The default value is 0.
+    timeToLiveSeconds              - Sets the time to live for an element before it expires.
+                                     i.e. The maximum time between creation time and when an element expires.
+                                     Is only used if the element is not eternal.
+                                     Optional attribute. A value of 0 means that and Element can live for infinity.
+                                     The default value is 0.
+    diskPersistent                 - Whether the disk store persists between restarts of the Virtual Machine.
+                                     The default value is false.
+    diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
+                                     is 120 seconds.
+    memoryStoreEvictionPolicy      - Policy would be enforced upon reaching the maxElementsInMemory limit. Default
+                                     policy is Least Recently Used (specified as LRU). Other policies available -
+                                     First In First Out (specified as FIFO) and Less Frequently Used
+                                     (specified as LFU)
+    -->
+    <!-- the default JSPWiki caches -->
+    <cache name="JSPWiki.jspwiki.renderingCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.pageCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.pageTextCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.pageHistoryCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.attachmentsCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.attachmentCollectionsCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.dynamicAttachmentCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.rssCache" maxElementsInMemory="128" />
+</ehcache>

Propchange: jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/private/WEB-INF/classes/ehcache.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/public/WEB-INF/classes/ehcache.xml
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/public/WEB-INF/classes/ehcache.xml?rev=1687766&view=auto
==============================================================================
--- jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/public/WEB-INF/classes/ehcache.xml (added)
+++ jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/public/WEB-INF/classes/ehcache.xml Fri Jun 26 12:21:39 2015
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<ehcache>
+
+    <!-- Sets the path to the directory where cache .data files are created.
+
+         If the path is a Java System Property it is replaced by
+         its value in the running VM. The following properties are translated:
+
+            user.home - User's home directory
+            user.dir - User's current working directory
+            java.io.tmpdir - Default temp file path
+    -->
+    <diskStore path="java.io.tmpdir" />
+    <!--
+    The following attributes are required:
+
+    maxElementsInMemory            - Sets the maximum number of objects that will be created in memory
+    eternal                        - Sets whether elements are eternal. If eternal,  timeouts are ignored and the
+                                     element is never expired.
+    overflowToDisk                 - Sets whether elements can overflow to disk when the in-memory cache
+                                     has reached the maxInMemory limit.
+
+    The following attributes are optional:
+    timeToIdleSeconds              - Sets the time to idle for an element before it expires.
+                                     i.e. The maximum amount of time between accesses before an element expires
+                                     Is only used if the element is not eternal.
+                                     Optional attribute. A value of 0 means that an Element can idle for infinity.
+                                     The default value is 0.
+    timeToLiveSeconds              - Sets the time to live for an element before it expires.
+                                     i.e. The maximum time between creation time and when an element expires.
+                                     Is only used if the element is not eternal.
+                                     Optional attribute. A value of 0 means that and Element can live for infinity.
+                                     The default value is 0.
+    diskPersistent                 - Whether the disk store persists between restarts of the Virtual Machine.
+                                     The default value is false.
+    diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
+                                     is 120 seconds.
+    memoryStoreEvictionPolicy      - Policy would be enforced upon reaching the maxElementsInMemory limit. Default
+                                     policy is Least Recently Used (specified as LRU). Other policies available -
+                                     First In First Out (specified as FIFO) and Less Frequently Used
+                                     (specified as LFU)
+    -->
+    <!-- the default JSPWiki caches -->
+    <cache name="JSPWiki.jspwiki.renderingCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.pageCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.pageTextCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.pageHistoryCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.attachmentsCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.attachmentCollectionsCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.dynamicAttachmentCache" maxElementsInMemory="128" timeToLiveSeconds="7200" />
+
+    <cache name="JSPWiki.jspwiki.rssCache" maxElementsInMemory="128" />
+</ehcache>

Propchange: jspwiki/trunk/jspwiki-portable/src/overlay/woas/webapps/public/WEB-INF/classes/ehcache.xml
------------------------------------------------------------------------------
    svn:executable = *

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/CachingProvider.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/CachingProvider.java?rev=1687766&r1=1687765&r2=1687766&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/CachingProvider.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/CachingProvider.java Fri Jun 26 12:21:39 2015
@@ -18,15 +18,14 @@
  */
 package org.apache.wiki.providers;
 
-import java.io.IOException;
-import java.util.*;
-
 import net.sf.ehcache.Cache;
-import net.sf.ehcache.Element;
 import net.sf.ehcache.CacheManager;
-
+import net.sf.ehcache.Element;
 import org.apache.log4j.Logger;
-import org.apache.wiki.*;
+import org.apache.wiki.PageManager;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.parser.MarkupParser;
@@ -35,6 +34,14 @@ import org.apache.wiki.search.QueryItem;
 import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.TextUtil;
 
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.TreeSet;
+
 
 /**
  *  Provides a caching page provider.  This class rests on top of a
@@ -87,8 +94,11 @@ public class CachingProvider implements
 
     private boolean          m_gotall = false;
 
-    /** The capacity of the caches, if you want something else, tweak ehcache.xml. */
+    // The default settings of the caches, if you want something else, provide an "ehcache.xml" file
+    // Please note that JSPWiki ships with a default "ehcache.xml" in the classpath
     public static final int   DEFAULT_CACHECAPACITY   = 1000; // Good most wikis
+    public static final int   DEFAULT_CACHETIMETOLIVESECONDS = 24*3600;
+    public static final int   DEFAULT_CACHETIMETOIDLESECONDS = 24*3600;
 
     /**
      *  {@inheritDoc}
@@ -105,7 +115,7 @@ public class CachingProvider implements
             m_cache = m_cacheManager.getCache(cacheName);
         } else {
             log.info("cache with name " + cacheName +  " not found in ehcache.xml, creating it with defaults.");
-            m_cache = new Cache(cacheName, DEFAULT_CACHECAPACITY, false, false, 0, 0);
+            m_cache = new Cache(cacheName, DEFAULT_CACHECAPACITY, false, false, DEFAULT_CACHETIMETOLIVESECONDS, DEFAULT_CACHETIMETOIDLESECONDS);
             m_cacheManager.addCache(m_cache);
         }
 
@@ -114,7 +124,7 @@ public class CachingProvider implements
             m_textCache= m_cacheManager.getCache(textCacheName);
         } else {
             log.info("cache with name " + textCacheName +  " not found in ehcache.xml, creating it with defaults.");
-            m_textCache = new Cache(textCacheName, DEFAULT_CACHECAPACITY, false, false, 0, 0);
+            m_textCache = new Cache(textCacheName, DEFAULT_CACHECAPACITY, false, false, DEFAULT_CACHETIMETOLIVESECONDS, DEFAULT_CACHETIMETOIDLESECONDS);
             m_cacheManager.addCache(m_textCache);
         }
 
@@ -123,7 +133,7 @@ public class CachingProvider implements
             m_historyCache= m_cacheManager.getCache(historyCacheName);
         } else {
             log.info("cache with name " + historyCacheName +  " not found in ehcache.xml, creating it with defaults.");
-            m_historyCache = new Cache(historyCacheName, DEFAULT_CACHECAPACITY, false, false, 0, 0);
+            m_historyCache = new Cache(historyCacheName, DEFAULT_CACHECAPACITY, false, false, DEFAULT_CACHETIMETOLIVESECONDS, DEFAULT_CACHETIMETOIDLESECONDS);
             m_cacheManager.addCache(m_historyCache);
         }