Author: areshetnyak
Date: 2010-04-08 03:16:37 -0400 (Thu, 08 Apr 2010)
New Revision: 2219
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCacheExp.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
Log:
EXOJCR-545 : Add implementation BufferedJBossCache with ExpitationAlgorithm
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-04-07
14:03:09 UTC (rev 2218)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-04-08
07:16:37 UTC (rev 2219)
@@ -30,6 +30,7 @@
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jgroups.Address;
@@ -668,6 +669,18 @@
public static enum ChangesType {
REMOVE, REMOVE_KEY, PUT, PUT_KEY, PUT_TO_LIST;
}
+
+ protected static void putMap(Fqn fqn, Map<? extends Serializable, ? extends
Object> data, Cache<Serializable, Object> cache, boolean localMode)
+ {
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(localMode);
+ cache.put(fqn, data);
+ }
+
+ protected static void putObject(Fqn fqn, Serializable key, Object value,
Cache<Serializable, Object> cache, boolean localMode)
+ {
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(localMode);
+ cache.put(fqn, key, value);
+ }
/**
* Container for changes
@@ -760,8 +773,7 @@
@Override
public void apply()
{
- setCacheLocalMode();
- cache.put(fqn, data);
+ putMap(fqn, data, cache, localMode);
}
}
@@ -785,8 +797,7 @@
@Override
public void apply()
{
- setCacheLocalMode();
- cache.put(fqn, key, value);
+ putObject(fqn, key, value, cache, localMode);
}
}
@@ -825,8 +836,8 @@
newSet.addAll((Set<Object>)existingObject);
}
newSet.add(value);
- setCacheLocalMode();
- cache.put(fqn, key, newSet);
+
+ putObject(fqn, key, newSet, cache, localMode);
}
else
{
@@ -866,8 +877,8 @@
{
Set<Object> newSet = new
HashSet<Object>((Set<Object>)existingObject);
newSet.remove(value);
- setCacheLocalMode();
- cache.put(fqn, key, newSet);
+
+ putObject(fqn, key, newSet, cache, localMode);
}
}
}
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCacheExp.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCacheExp.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCacheExp.java 2010-04-08
07:16:37 UTC (rev 2219)
@@ -0,0 +1,84 @@
+/*
+ * 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 java.io.Serializable;
+import java.util.Map;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
+ * @version $Id$
+ */
+public class BufferedJBossCacheExp extends BufferedJBossCache
+{
+ /**
+ * The expiration timeout.
+ */
+ public final static long DEFAULT_EXPIRATION_TIMEOUT = 900000; // 15 minutes.
+
+ public final long expirationTimeOut;
+
+ public BufferedJBossCacheExp(Cache<Serializable, Object> parentCache, long
expirationTimeOut)
+ {
+ super(parentCache);
+ this.expirationTimeOut = expirationTimeOut;
+ }
+
+ public BufferedJBossCacheExp(Cache<Serializable, Object> parentCache)
+ {
+ super(parentCache);
+ this.expirationTimeOut = DEFAULT_EXPIRATION_TIMEOUT;
+ }
+
+ protected static void putMap(Fqn fqn, Map<? extends Serializable, ? extends
Object> data, Cache<Serializable, Object> cache, boolean localMode)
+ {
+ putExpiration(fqn, cache, localMode);
+
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(localMode);
+ cache.put(fqn, data);
+
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(localMode);
+ cache.put(fqn, ExpirationAlgorithmConfig.EXPIRATION_KEY, new
Long(System.currentTimeMillis() + DEFAULT_EXPIRATION_TIMEOUT));
+ }
+
+ protected static void putObject(Fqn fqn, Serializable key, Object value,
Cache<Serializable, Object> cache, boolean localMode)
+ {
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(localMode);
+ cache.put(fqn, key, value);
+ }
+
+ public static void putExpiration(Fqn efqn, Cache<Serializable, Object> cache,
boolean localMode)
+ {
+ for (int i = 2; i <= efqn.size(); i++)
+ {
+ Fqn pfqn = efqn.getSubFqn(0, i);
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(localMode);
+ cache.put(pfqn, ExpirationAlgorithmConfig.EXPIRATION_KEY, new
Long(System.currentTimeMillis() + DEFAULT_EXPIRATION_TIMEOUT));
+ }
+ }
+
+
+
+}
Property changes on:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCacheExp.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
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-04-07
14:03:09 UTC (rev 2218)
+++
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-04-08
07:16:37 UTC (rev 2219)
@@ -11,9 +11,11 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <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 algorithmClass="org.jboss.cache.eviction.ExpirationAlgorithm"
+
actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ParentNodeEvictionActionPolicy"
+ eventQueueSize="1000000">
+ <property name="maxNodes" value="50000" />
+ <property name="warnNoExpirationKey" value="true" />
</default>
</eviction>