[exo-jcr-commits] exo-jcr SVN: r1537 - in jcr/trunk/exo.jcr.component.core/src: test/resources/conf/cluster and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jan 22 04:30:16 EST 2010
Author: nfilotto
Date: 2010-01-22 04:30:15 -0500 (Fri, 22 Jan 2010)
New Revision: 1537
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java
Modified:
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
Log:
EXOJCR-402: Add an EvictionActionPolicy as workaround of https://jira.jboss.org/jira/browse/JBCACHE-1567
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java 2010-01-22 09:30:15 UTC (rev 1537)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.DefaultEvictionActionPolicy;
+import org.jboss.cache.eviction.EvictionActionPolicy;
+
+import java.util.Set;
+
+/**
+ * This class is used to prevent the memory leak described here http://community.jboss.org/thread/147084
+ * and corresponding to the JIRA https://jira.jboss.org/jira/browse/JBCACHE-1567
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto at exoplatform.com
+ * 22 janv. 2010
+ */
+public class ParentNodeEvictionActionPolicy implements EvictionActionPolicy
+{
+ Cache<?, ?> cache;
+
+ private static final Log log = LogFactory.getLog(DefaultEvictionActionPolicy.class);
+
+ public void setCache(Cache<?, ?> cache)
+ {
+ this.cache = cache;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean evict(Fqn fqn)
+ {
+ boolean result;
+ try
+ {
+ if (log.isTraceEnabled())
+ log.trace("Evicting Fqn " + fqn);
+ cache.evict(fqn);
+ result = true;
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Unable to evict " + fqn, e);
+ result = false;
+ }
+ if (fqn.size() != 3)
+ {
+ return result;
+ }
+ try
+ {
+ Fqn parentFqn = fqn.getParent();
+ if (parentFqn.get(0).equals(JBossCacheWorkspaceStorageCache.CHILD_NODES)
+ || parentFqn.get(0).equals(JBossCacheWorkspaceStorageCache.CHILD_PROPS))
+ {
+ // The expected data structure is of type $CHILD_NODES/${node-id}/${sub-node-name} or
+ // $CHILD_PROPS/${node-id}/${sub-property-name}
+ Set<Object> names = cache.getChildrenNames(parentFqn);
+ if (names.isEmpty() || (names.size() == 1 && names.contains(fqn.get(2))))
+ {
+ if (log.isTraceEnabled())
+ log.trace("Evicting Fqn " + fqn);
+ cache.evict(parentFqn);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Unable to evict " + fqn, e);
+ }
+ return result;
+ }
+}
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-22 08:13:52 UTC (rev 1536)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-22 09:30:15 UTC (rev 1537)
@@ -80,7 +80,7 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ParentNodeEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="10000" />
<property name="timeToLive" value="120000" />
</default>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-22 08:13:52 UTC (rev 1536)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-22 09:30:15 UTC (rev 1537)
@@ -80,7 +80,7 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ParentNodeEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="10000" />
<property name="timeToLive" value="120000" />
</default>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-22 08:13:52 UTC (rev 1536)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-22 09:30:15 UTC (rev 1537)
@@ -11,7 +11,7 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="1000000">
+ <default algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ParentNodeEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="minTimeToLive" value="60000" />
</default>
More information about the exo-jcr-commits
mailing list