[jbosscache-commits] JBoss Cache SVN: r7075 - in core/trunk/src: main/java/org/jboss/cache/config/parsing/element and 4 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Nov 4 05:43:18 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-11-04 05:43:18 -0500 (Tue, 04 Nov 2008)
New Revision: 7075

Modified:
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
   core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
   core/trunk/src/main/resources/config-samples/eviction-enabled.xml
   core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
   core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
   core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
Log:
JBCACHE-1435 Remove on evict policy attempts to prune buddy backup tree
JBCACHE-1436  JBoss configuration schema requires <property> for <region> eviction config


Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-11-04 08:23:33 UTC (rev 7074)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-11-04 10:43:18 UTC (rev 7075)
@@ -1,24 +1,24 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, 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.
- */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, 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.cache.buddyreplication;
 
 import org.jboss.cache.CacheException;
@@ -92,7 +92,7 @@
       return Fqn.fromList(elements, true);
    }
 
-   public boolean isBackupFqn(Fqn name)
+   public static boolean isBackupFqn(Fqn name)
    {
       return name != null && name.hasElement(BuddyManager.BUDDY_BACKUP_SUBTREE);
    }

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java	2008-11-04 08:23:33 UTC (rev 7074)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java	2008-11-04 10:43:18 UTC (rev 7075)
@@ -187,7 +187,7 @@
 
    public static void parseEvictionPolicyConfig(Element element, EvictionAlgorithmConfig target)
    {
-      target.reset();
+//      target.reset();
       Properties p = XmlConfigHelper.extractProperties(element);
       XmlConfigHelper.setValues(target, p, false, true);
    }

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java	2008-11-04 08:23:33 UTC (rev 7074)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java	2008-11-04 10:43:18 UTC (rev 7075)
@@ -25,6 +25,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Cache;
 import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 
 /**
  * An eviction action policy that calls {@link org.jboss.cache.Cache#removeNode(org.jboss.cache.Fqn)} to evict a node.
@@ -35,7 +36,7 @@
 public class RemoveOnEvictActionPolicy implements EvictionActionPolicy
 {
    Cache<?, ?> cache;
-   private static final Log log = LogFactory.getLog(DefaultEvictionActionPolicy.class);
+   private static final Log log = LogFactory.getLog(RemoveOnEvictActionPolicy.class);
 
    public void setCache(Cache<?, ?> cache)
    {
@@ -44,6 +45,11 @@
 
    public boolean evict(Fqn fqn)
    {
+      // eviction code may also try and evict the fqn of a buddy.  If the Fqn is that of a buddy we need to ensure that
+      // this call is ignored since a proper remove will happen on the data owner when the data is evicted, and that
+      // remove will propagate here.
+      if (BuddyFqnTransformer.isBackupFqn(fqn)) return true;
+
       try
       {
          return cache.removeNode(fqn);

Modified: core/trunk/src/main/resources/config-samples/eviction-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/eviction-enabled.xml	2008-11-04 08:23:33 UTC (rev 7074)
+++ core/trunk/src/main/resources/config-samples/eviction-enabled.xml	2008-11-04 10:43:18 UTC (rev 7075)
@@ -36,5 +36,6 @@
          <property name="timeToLive" value="8000" />
          <property name="maxAge" value="10000" />
       </region>
+      <region name="/org/jboss/data1/inherit" eventQueueSize="100" />      
    </eviction>
 </jbosscache>

Modified: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd	2008-11-04 08:23:33 UTC (rev 7074)
+++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd	2008-11-04 10:43:18 UTC (rev 7075)
@@ -177,7 +177,7 @@
 
    <xs:complexType name="evictionRegionType">
       <xs:sequence>
-         <xs:element name="property" maxOccurs="unbounded" type="tns:propertyType"/>
+         <xs:element name="property" minOccurs="0" maxOccurs="unbounded" type="tns:propertyType"/>
       </xs:sequence>
       <xs:attribute name="name" type="xs:string"/>
       <xs:attribute name="algorithmClass" type="xs:string"/>

Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java	2008-11-04 08:23:33 UTC (rev 7074)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java	2008-11-04 10:43:18 UTC (rev 7075)
@@ -7,6 +7,7 @@
 import org.jboss.cache.config.MissingPolicyException;
 import org.jboss.cache.config.parsing.element.EvictionElementParser;
 import org.jboss.cache.eviction.DefaultEvictionActionPolicy;
+import org.jboss.cache.eviction.FIFOAlgorithmConfig;
 import org.jboss.cache.eviction.LFUAlgorithmConfig;
 import org.jboss.cache.eviction.LRUAlgorithmConfig;
 import org.jboss.cache.eviction.MRUAlgorithmConfig;
@@ -48,6 +49,36 @@
       assert evictionConfig.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
    }
 
+   public void testRegionWithNoProperties()
+   {
+      String xml =
+            "   <eviction wakeUpInterval=\"5\">\n" +
+                  "      <default algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\">\n" +
+                  "         <property name=\"maxNodes\" value=\"10\"></property>\n" +
+                  "         <property name=\"minTimeToLive\" value=\"10\"></property>\n" +
+                  "      </default>\n" +
+                  "      <region name=\"/org/jboss/abc\" eventQueueSize=\"21\">\n" +
+                  "      </region>\n" +
+                  "      <region name=\"/org/jboss/xyz\" algorithmClass=\"org.jboss.cache.eviction.FIFOAlgorithm\">\n" +
+                  "      </region>\n" +
+                  "   </eviction>";
+      EvictionConfig evictionConfig = getEvictionConfig(xml, false);
+      assert evictionConfig.getDefaultEvictionRegionConfig().getEventQueueSize() == EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+      assert evictionConfig.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
+      EvictionRegionConfig abc = evictionConfig.getEvictionRegionConfig("/org/jboss/abc");
+      EvictionRegionConfig xyz = evictionConfig.getEvictionRegionConfig("/org/jboss/xyz");
+
+      assert abc.getEventQueueSize() == 21;
+      assert abc.getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig;
+      assert ((MRUAlgorithmConfig) abc.getEvictionAlgorithmConfig()).getMaxNodes() == 10;
+      assert ((MRUAlgorithmConfig) abc.getEvictionAlgorithmConfig()).getMinTimeToLive() == 10;
+
+      assert xyz.getEventQueueSize() == EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+      assert xyz.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmConfig;
+      assert ((FIFOAlgorithmConfig) xyz.getEvictionAlgorithmConfig()).getMaxNodes() == -1;
+      assert ((FIFOAlgorithmConfig) xyz.getEvictionAlgorithmConfig()).getMinTimeToLive() == -1;      
+   }
+
    /**
     * test unnecessary propertys
     */

Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java	2008-11-04 08:23:33 UTC (rev 7074)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java	2008-11-04 10:43:18 UTC (rev 7075)
@@ -232,7 +232,7 @@
       LRUAlgorithmConfig secondConfiguration = (LRUAlgorithmConfig) second.getEvictionAlgorithmConfig();
       assert secondConfiguration.getMaxAge() == -1;
       assert secondConfiguration.getTimeToLive() == 1002;
-      assert secondConfiguration.getMaxNodes() == -1;
+      assert secondConfiguration.getMaxNodes() == 5000;
 
       EvictionRegionConfig third = regionConfigs.get(1);
       MRUAlgorithmConfig thirdConfiguration = (MRUAlgorithmConfig) third.getEvictionAlgorithmConfig();




More information about the jbosscache-commits mailing list