[exo-jcr-commits] exo-jcr SVN: r1267 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: test/resources/conf/standalone and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jan 4 06:12:24 EST 2010


Author: areshetnyak
Date: 2010-01-04 06:12:24 -0500 (Mon, 04 Jan 2010)
New Revision: 1267

Added:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java
Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
Log:
EXOJCR-333 : The implementation ExoEvictionActionPolicy was added. The eviction configuration was added.

Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java	2010-01-04 11:12:24 UTC (rev 1267)
@@ -0,0 +1,85 @@
+/*
+ * 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.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.EvictionActionPolicy;
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak at exoplatform.com.ua">Alex Reshetnyak</a> 
+ * @version $Id$
+ */
+public class ExoEvictionActionPolicy
+   implements EvictionActionPolicy
+{
+   private static final Log LOG = ExoLogger.getLogger("jcr.ExoEvictionActionPolicy");
+
+   private Cache<?, ?> cache;
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean evict(Fqn fqn)
+   {
+
+      if (fqn.size() == 3 && JBossCacheWorkspaceStorageCache.CHILD_NODES_LIST.equals(fqn.get(0)))
+      {
+         return eviction(fqn.getParent());
+      }
+      else if (fqn.size() == 3 && JBossCacheWorkspaceStorageCache.CHILD_NODES_LIST.equals(fqn.get(0)))
+      {
+         return eviction(fqn.getParent());
+      }
+      else
+      {
+         return eviction(fqn);
+      }
+   }
+
+   private boolean eviction(Fqn fqn)
+   {
+      try
+      {
+         if (LOG.isDebugEnabled())
+            LOG.debug("Evicting Fqn " + fqn);
+
+         cache.evict(fqn);
+         return true;
+      }
+      catch (Exception e)
+      {
+         LOG.error("Unable to evict " + fqn, e);
+         return false;
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setCache(Cache<?, ?> cache)
+   {
+      this.cache = cache;
+   }
+
+}


Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml	2010-01-04 10:56:02 UTC (rev 1266)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml	2010-01-04 11:12:24 UTC (rev 1267)
@@ -1,10 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-   xmlns="urn:jboss:jbosscache-core:config:3.1">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
 
    <!-- Configure the TransactionManager -->
    <transaction transactionManagerLookupClass="org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup" />
-   
+
    <!-- Enable batching -->
-   <invocationBatching enabled="true"/>
+   <invocationBatching enabled="true" />
+
+   <!-- Eviction configuration -->
+   <eviction wakeUpInterval="5000">
+      <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+         <property name="maxNodes" value="5000" />
+         <property name="timeToLiveSeconds" value="120" />
+      </default>
+      <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy">
+         <property name="maxNodes" value="5000" />
+         <property name="timeToLiveSeconds" value="120" />
+      </region>
+   </eviction>
+
 </jbosscache>



More information about the exo-jcr-commits mailing list