[jboss-cvs] JBossAS SVN: r80398 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 3 14:48:13 EST 2008
Author: bstansberry at jboss.com
Date: 2008-11-03 14:48:13 -0500 (Mon, 03 Nov 2008)
New Revision: 80398
Added:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithmConfiguration.java
Removed:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUPolicy.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithm.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
Log:
[EJBTHREE-1566] Convert StatefulTreeCache to use JBoss Cache 3
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithm.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithm.java 2008-11-03 19:10:58 UTC (rev 80397)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithm.java 2008-11-03 19:48:13 UTC (rev 80398)
@@ -58,10 +58,9 @@
log.trace("Attempting to evict cache node with fqn of " + fqn);
}
- EvictionPolicy policy = region.getEvictionPolicy();
try
{
- policy.evict(fqn);
+ evictionActionPolicy.evict(fqn);
}
catch (ContextInUseException e)
{
Copied: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithmConfiguration.java (from rev 80397, projects/ejb3/dev/Branch_JBoss_Cache_3/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithmConfiguration.java)
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithmConfiguration.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUAlgorithmConfiguration.java 2008-11-03 19:48:13 UTC (rev 80398)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.cache.tree;
+
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+
+/**
+ *
+ * @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
+ */
+public class AbortableLRUAlgorithmConfiguration extends LRUAlgorithmConfig
+{
+ @Override
+ public String getEvictionAlgorithmClassName()
+ {
+ return AbortableLRUAlgorithm.class.getName();
+ }
+}
Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUPolicy.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUPolicy.java 2008-11-03 19:10:58 UTC (rev 80397)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/AbortableLRUPolicy.java 2008-11-03 19:48:13 UTC (rev 80398)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.ejb3.cache.tree;
-
-import org.jboss.cache.eviction.LRUPolicy;
-
-/**
- * LRUPolicy subclass with an algorithm that doesn't error log
- * ContextInUseException.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public class AbortableLRUPolicy extends LRUPolicy
-{
- public AbortableLRUPolicy()
- {
- super();
- algorithm = new AbortableLRUAlgorithm();
- }
-
-}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2008-11-03 19:10:58 UTC (rev 80397)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2008-11-03 19:48:13 UTC (rev 80398)
@@ -26,6 +26,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
import javax.ejb.EJBException;
import javax.ejb.NoSuchEJBException;
@@ -38,8 +39,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.Region;
import org.jboss.cache.RegionNotEmptyException;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
+import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeActivated;
import org.jboss.cache.notifications.annotation.NodePassivated;
@@ -301,14 +301,21 @@
removalTask = new RemovalTimeoutTask("SFSB Removal Thread - " + this.ejbContainer.getObjectName().getCanonicalName());
}
- protected EvictionPolicyConfig getEvictionPolicyConfig()
+ protected EvictionRegionConfig getEvictionRegionConfig(Fqn fqn)
{
- LRUConfiguration epc = new LRUConfiguration();
- // Override the standard policy class
- epc.setEvictionPolicyClass(AbortableLRUPolicy.class.getName());
- epc.setTimeToLiveSeconds((int) cacheConfig.idleTimeoutSeconds());
- epc.setMaxNodes(cacheConfig.maxSize());
- return epc;
+ AbortableLRUAlgorithmConfiguration algoCfg = new AbortableLRUAlgorithmConfiguration();
+ EvictionRegionConfig erc = new EvictionRegionConfig(fqn, algoCfg);
+
+ log.debug("Setting time to live to " + cacheConfig.idleTimeoutSeconds() + " seconds and maxNodes to " + cacheConfig.maxSize());
+
+ algoCfg.setTimeToLive((int) cacheConfig.idleTimeoutSeconds(), TimeUnit.SECONDS);
+ algoCfg.setMaxNodes(cacheConfig.maxSize());
+
+ // JBC 2.x used '0' to denote no limit; 3.x uses '-1' since '0' now denotes '0'.
+ if (algoCfg.getTimeToLive() == 0) algoCfg.setTimeToLive(-1);
+ if (algoCfg.getMaxNodes() == 0) algoCfg.setMaxNodes(-1);
+
+ return erc;
}
public void start()
@@ -338,8 +345,8 @@
// Try to create an eviction region per ejb
region = cache.getRegion(cacheNode, true);
- EvictionPolicyConfig epc = getEvictionPolicyConfig();
- region.setEvictionPolicy(epc);
+ EvictionRegionConfig erc = getEvictionRegionConfig(cacheNode);
+ region.setEvictionRegionConfig(erc);
if (cache.getCacheStatus() != CacheStatus.STARTED)
{
More information about the jboss-cvs-commits
mailing list