JBoss Cache SVN: r6564 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 14 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-08-15 17:16:37 -0400 (Fri, 15 Aug 2008)
New Revision: 6564
Added:
core/trunk/src/main/resources/schema/
core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
Removed:
core/trunk/src/main/resources/jbosscache-config-3.0.xsd
Modified:
core/trunk/src/main/java/org/jboss/cache/Fqn.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java
core/trunk/src/main/resources/config-samples/buddy-replication.xml
core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
core/trunk/src/main/resources/config-samples/eviction-enabled.xml
core/trunk/src/main/resources/config-samples/invalidation-async.xml
core/trunk/src/main/resources/config-samples/local.xml
core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml
core/trunk/src/main/resources/config-samples/total-replication.xml
core/trunk/src/main/resources/config2to3.xslt
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
core/trunk/src/test/resources/configs/buddy-replication-cache.xml
core/trunk/src/test/resources/configs/clonable-config.xml
core/trunk/src/test/resources/configs/local-lru-eviction.xml
core/trunk/src/test/resources/configs/local-passivation.xml
core/trunk/src/test/resources/configs/local-tx.xml
core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
core/trunk/src/test/resources/configs/mux.xml
core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml
core/trunk/src/test/resources/configs/parser-test.xml
core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
core/trunk/src/test/resources/configs/replSync.xml
core/trunk/src/test/resources/configs/string-property-replaced.xml
core/trunk/src/test/resources/jbc2-registry-configs.xml
core/trunk/src/test/resources/unit-test-cache-service.xml
Log:
Use JBossEntityResolver to find schema
Modify schema to use a namespace
Correct simple type pattern for locking scheme
Modify parser to use the namespace
Update configuration files
Add root element checking to prevent NPEs
Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -110,12 +110,13 @@
size = 0;
}
- protected Fqn(List<Object> names, boolean safe)
+ @SuppressWarnings("unchecked")
+ protected Fqn(List<?> names, boolean safe)
{
if (names != null)
{
// if not safe make a defensive copy
- elements = safe ? names : Immutables.immutableListCopy(names);
+ elements = safe ? (List<Object>) names : Immutables.immutableListCopy(names);
size = elements.size();
}
else
@@ -141,9 +142,9 @@
* @since 2.2.0
*/
@SuppressWarnings("unchecked")
- public static Fqn fromList(List<?> names)
+ public static <T> Fqn fromList(List<T> names)
{
- return new Fqn((List<Object>)names, false);
+ return new Fqn(names, false);
}
/**
@@ -159,7 +160,7 @@
@SuppressWarnings("unchecked")
public static Fqn fromList(List<?> names, boolean safe)
{
- return new Fqn((List<Object>)names, safe);
+ return new Fqn(names, safe);
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -109,7 +109,8 @@
if (name == null || name.trim().length() == 0)
throw new ConfigurationException("Element " + element + " has no name attribute");
XmlConfigurationParser parser = new XmlConfigurationParser();
- Configuration c = parser.parseElement(element);
+ // FIXME - This should be using a valid schema!!!
+ Configuration c = parser.parseElementIgnoringRoot(element);
// Prove that we can successfully clone it
c = c.clone();
result.put(name.trim(), c);
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -54,8 +54,9 @@
continue;
}
+ // Ignore Namespace until JGroups defines one
Element tag = (Element) node;
- String protocol = tag.getTagName();
+ String protocol = tag.getLocalName();
buffer.append(protocol);
processAttributes(buffer, tag);
buffer.append(':');
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -364,16 +364,34 @@
* @return a DOM Element
* @throws Exception if unable to parse the String or if it doesn't contain valid XML.
*/
- public static Element stringToElement(String xml) throws Exception
+ public static Element stringToElementInCoreNS(String xml) throws Exception
{
+ xml = "<wrapper xmlns='" + XmlParserBase.JBOSSCACHE_CORE_NS + "'>" + xml + "</wrapper>";
ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
Document d = builder.parse(bais);
bais.close();
- return d.getDocumentElement();
+ return getFirstChildElement(d.getDocumentElement());
}
/**
+ * Gets the first child element of an element
+ *
+ * @param element the parent
+ * @return the first child element or null if there isn't one
+ */
+ public static Element getFirstChildElement(Element element)
+ {
+ Node child = element.getFirstChild();
+ while (child != null && child.getNodeType() != Node.ELEMENT_NODE)
+ child = child.getNextSibling();
+
+ return (Element)child;
+ }
+
+ /**
* Returns the root element of a given input stream
*
* @param is stream to parse
@@ -387,6 +405,7 @@
InputSource xmlInp = new InputSource(is);
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ docBuilderFactory.setNamespaceAware(true);
DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
doc = parser.parse(xmlInp);
Element root = doc.getDocumentElement();
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -35,6 +35,7 @@
import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.util.FileLookup;
+import org.jboss.util.xml.JBossEntityResolver;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.ErrorHandler;
@@ -62,11 +63,19 @@
*/
public class XmlConfigurationParser extends XmlParserBase
{
+
private static final Log log = LogFactory.getLog(XmlConfigurationParser.class);
+ private static final JBossEntityResolver resolver = new JBossEntityResolver();
+
public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
- public static final String SCHEMA_LOCATION_SYSTEM_PROPERTY = "jbosscache.config.schemaLocation";
+ static
+ {
+ // Globally register this namespace
+ JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.0.xsd");
+ }
+
/**
* the resulting configuration.
*/
@@ -74,7 +83,6 @@
private Element root;
private ErrorHandler errorHandler;
private boolean isValidating;
- private String schemaLocation;
/**
* If validation is on (default) one can specify an error handler for handling validation errors.
@@ -84,7 +92,6 @@
{
this.errorHandler = errorHandler;
isValidating = System.getProperty(VALIDATING_SYSTEM_PROPERTY) == null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY);
- schemaLocation = System.getProperty(SCHEMA_LOCATION_SYSTEM_PROPERTY);
}
/**
@@ -131,7 +138,7 @@
public Configuration parseStream(InputStream configStream)
{
readRoot(configStream);
- return processElements();
+ return processElements(false);
}
/**
@@ -143,20 +150,36 @@
{
this.root = root;
this.root.normalize();
- return processElements();
+ return processElements(false);
}
+ // FIXME: CacheConfigsXmlParser should be using a valid schema!
+ @Deprecated
+ public Configuration parseElementIgnoringRoot(Element root)
+ {
+ this.root = root;
+ this.root.normalize();
+ return processElements(true);
+ }
+
public boolean isValidating()
{
return isValidating;
}
- private Configuration processElements()
+ private Configuration processElements(boolean ignoreRoot)
{
- if ("server".equalsIgnoreCase(root.getNodeName()))
+ if (!ignoreRoot)
{
- throw new OldFileFormatException();
+ if ("server".equalsIgnoreCase(root.getNodeName()))
+ {
+ throw new OldFileFormatException();
+ }
+
+ if (! "jbosscache".equals(root.getLocalName()) || ! JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))
+ throw new ConfigurationException("Expected root element {" + JBOSSCACHE_CORE_NS + "}" + "jbosscache");
}
+
try
{
configureLocking(getSingleElement("locking"));
@@ -300,7 +323,7 @@
config.setClusterName(clusterName);
String multiplexerStack = getAttributeValue(element, "multiplexerStack");
if (existsAttribute(multiplexerStack)) config.setMultiplexerStack(multiplexerStack);
- Element clusterConfig = getSingleElement("jgroupsConfig", element);
+ Element clusterConfig = getSingleElementInCoreNS("jgroupsConfig", element);
if (clusterConfig != null)
{
JGroupsStackParser stackParser = new JGroupsStackParser();
@@ -324,13 +347,13 @@
if (async != null)
{
config.setCacheMode(Configuration.CacheMode.INVALIDATION_ASYNC);
- configureAsyncMode(getSingleElement("async", element));
+ configureAsyncMode(getSingleElementInCoreNS("async", element));
}
Element sync = getSingleElement("sync");
if (sync != null)
{
config.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
- configureSyncMode(getSingleElement("sync", element));
+ configureSyncMode(getSingleElementInCoreNS("sync", element));
}
}
@@ -341,15 +364,15 @@
if (async != null)
{
config.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
- configureAsyncMode(getSingleElement("async", element));
+ configureAsyncMode(getSingleElementInCoreNS("async", element));
}
Element sync = getSingleElement("sync");
if (sync != null)
{
config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- configureSyncMode(getSingleElement("sync", element));
+ configureSyncMode(getSingleElementInCoreNS("sync", element));
}
- configureBuddyReplication(getSingleElement("buddy", element));
+ configureBuddyReplication(getSingleElementInCoreNS("buddy", element));
}
private void configureSyncMode(Element element)
@@ -387,7 +410,7 @@
private Element getSingleElement(String elementName)
{
- return getSingleElement(elementName, root);
+ return getSingleElementInCoreNS(elementName, root);
}
private void readRoot(InputStream config)
@@ -395,22 +418,16 @@
try
{
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ docBuilderFactory.setNamespaceAware(true);
if (isValidating)
{
docBuilderFactory.setValidating(true);
- docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
- if (schemaLocation != null)
- {
- if (log.isTraceEnabled()) log.trace("Using the schema location set to: '" + schemaLocation + '\'');
- docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaLocation);
- }
- else if (log.isTraceEnabled())
- {
- log.trace("Validation is enabled, using the schema decalred in the .xml configuration file");
- }
+ docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", JBOSSCACHE_CORE_NS);
}
+
DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+ parser.setEntityResolver(resolver);
parser.setErrorHandler(errorHandler);
Document doc = parser.parse(config);
root = doc.getDocumentElement();
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -33,6 +33,8 @@
*/
public abstract class XmlParserBase
{
+ public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.0";
+
/**
* @see Integer#parseInt(String)
*/
@@ -68,9 +70,9 @@
/**
* Convenient method for retrieving a single element with the give name.
*/
- protected Element getSingleElement(String elementName, Element parent)
+ protected Element getSingleElement(String namespace, String elementName, Element parent)
{
- NodeList nodeList = parent.getElementsByTagName(elementName);
+ NodeList nodeList = parent.getElementsByTagNameNS(namespace, elementName);
if (nodeList.getLength() == 0)
{
return null;
@@ -79,6 +81,14 @@
}
/**
+ * Convenient method for retrieving a single element with the give name.
+ */
+ protected Element getSingleElementInCoreNS(String elementName, Element parent)
+ {
+ return getSingleElement(JBOSSCACHE_CORE_NS, elementName, parent);
+ }
+
+ /**
* Beside querying the element for it's attribute value, it will look into the value, if any, and replace the
* jboss properties(e.g. ${someValue:defaultValue}.
* @see StringPropertyReplacer#replaceProperties(value);
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -31,8 +31,8 @@
if (existsAttribute(buddyCommunicationTimeout))
brc.setBuddyCommunicationTimeout(getInt(buddyCommunicationTimeout));
- parseDataGravitationElement(getSingleElement("dataGravitation", element), brc);
- BuddyReplicationConfig.BuddyLocatorConfig blc = parseBuddyLocatorConfig(getSingleElement("locator", element));
+ parseDataGravitationElement(getSingleElementInCoreNS("dataGravitation", element), brc);
+ BuddyReplicationConfig.BuddyLocatorConfig blc = parseBuddyLocatorConfig(getSingleElementInCoreNS("locator", element));
brc.setBuddyLocatorConfig(blc);
return brc;
}
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-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -52,7 +52,7 @@
// if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefaultEventQueueSize(getInt(defaultEventQueueSize));
List<EvictionRegionConfig> evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
- Element defaultRegion = getSingleElement("default", evictionElement);
+ Element defaultRegion = getSingleElementInCoreNS("default", evictionElement);
if (defaultRegion != null)
{
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -28,7 +28,7 @@
if (existsAttribute(passivation)) cacheLoaderConfig.setPassivation(getBoolean(passivation));
String shared = getAttributeValue(element, "shared");
if (existsAttribute(shared)) cacheLoaderConfig.setShared(getBoolean(shared));
- String preload = getPreloadString(getSingleElement("preload", element));
+ String preload = getPreloadString(getSingleElementInCoreNS("preload", element));
if (preload != null) cacheLoaderConfig.setPreload(preload);
NodeList cacheLoaderNodes = element.getElementsByTagName("loader");
@@ -58,7 +58,7 @@
throw new ConfigurationException("Missing 'class' attribute for cache loader configuration");
iclc.setClassName(clClass);
iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement, "properties"));
- CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = parseSingletonStoreConfig(getSingleElement("singletonStore", indivElement));
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = parseSingletonStoreConfig(getSingleElementInCoreNS("singletonStore", indivElement));
if (ssc != null)
{
iclc.setSingletonStoreConfig(ssc);
Modified: core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -27,6 +27,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
+import java.net.URL;
/**
* Holds the logic of looking up a file, in the following sequence:
Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<!--
isolationLevel : SERIALIZABLE - (not supported in mvcc)
Modified: core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<!--
isolationLevel : SERIALIZABLE - (not supported in mvcc)
Modified: core/trunk/src/main/resources/config-samples/eviction-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<!--
isolationLevel : SERIALIZABLE - (not supported in mvcc)
Modified: core/trunk/src/main/resources/config-samples/invalidation-async.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<!--
isolationLevel : SERIALIZABLE - (not supported in mvcc)
Modified: core/trunk/src/main/resources/config-samples/local.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/local.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config-samples/local.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<!-- By not specifying neither an 'replication' nor an 'invalidation' element, the cache is defaulted to local -->
Modified: core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<!--
isolationLevel : SERIALIZABLE - (not supported in mvcc)
Modified: core/trunk/src/main/resources/config-samples/total-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/total-replication.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config-samples/total-replication.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<!--
isolationLevel : SERIALIZABLE - (not supported in mvcc)
Modified: core/trunk/src/main/resources/config2to3.xslt
===================================================================
--- core/trunk/src/main/resources/config2to3.xslt 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/config2to3.xslt 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns="urn:jboss:jbosscache-core:config:3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
@@ -435,4 +435,4 @@
</xsl:if>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
Deleted: core/trunk/src/main/resources/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,255 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
- xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
- <xs:element name="jbosscache">
- <xs:complexType>
- <xs:all>
- <xs:element name="locking" type="lockingType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="transaction" type="transactionType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="startup" type="startupType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="stateRetrieval" type="stateRetrievalType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="shutdown" type="shutdownType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="serialization" type="serializationType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="replication" type="replicationType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="invalidation" type="invalidationType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="jmxStatistics" type="jmxStatisticsType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="listeners" type="listenersType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="invocationBatching" type="invocationBatchingType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="transport" type="transportType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="eviction" type="evictionType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="loaders" type="loadersType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="customInterceptors" type="customInterceptorsType" minOccurs="0" maxOccurs="1"/>
- </xs:all>
- </xs:complexType>
- </xs:element>
-
- <xs:complexType name="lockingType">
- <xs:attribute name="isolationLevel">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern value="SERIALIZABLE|REPEATABLE_READ|READ_COMMITTED|NONE|\$\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="lockParentForChildInsertRemove" type="booleanType"/>
- <xs:attribute name="lockAcquisitionTimeout" type="positiveInteger"/>
- <xs:attribute name="nodeLockingScheme">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern value="mvcc|optimistic|pessimistic|\$\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="writeSkewCheck" type="booleanType"/>
- <xs:attribute name="concurrencyLevel" type="xs:integer"/>
- </xs:complexType>
-
- <xs:complexType name="transactionType">
- <xs:attribute name="transactionManagerLookupClass" type="xs:string"/>
- <xs:attribute name="syncRollbackPhase" type="booleanType"/>
- <xs:attribute name="syncCommitPhase" type="booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="startupType">
- <xs:attribute name="regionsInactiveOnStartup" type="booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="stateRetrievalType">
- <xs:attribute name="fetchInMemoryState" type="booleanType"/>
- <xs:attribute name="timeout" type="positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="shutdownType">
- <xs:attribute name="hookBehavior">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:pattern value="DEFAULT|REGISTER|DONT_REGISTER|\$\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
-
- <xs:complexType name="serializationType">
- <xs:attribute name="objectInputStreamPoolSize" type="positiveInteger"/>
- <xs:attribute name="objectOutputStreamPoolSize" type="positiveInteger"/>
- <xs:attribute name="version" type="xs:string"/>
- <xs:attribute name="marshallerClass" type="xs:string"/>
- <xs:attribute name="useLazyDeserialization" type="booleanType"/>
- <xs:attribute name="useRegionBasedMarshalling" type="booleanType"/>
- </xs:complexType>
-
- <xs:simpleType name="booleanType">
- <xs:restriction base="xs:string">
- <xs:pattern value="\$\{.*\}|true|false"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="positiveInteger">
- <xs:restriction base="xs:string">
- <xs:pattern value="\$\{.*\}|\+?[0-9]*"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:complexType name="replicationType">
- <xs:sequence>
- <xs:choice>
- <xs:element name="sync" type="syncType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="async" type="asyncType" minOccurs="0" maxOccurs="1"/>
- </xs:choice>
- <xs:element name="buddy" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:all minOccurs="0">
- <xs:element name="dataGravitation" maxOccurs="1">
- <xs:complexType>
- <xs:attribute name="auto" type="booleanType"/>
- <xs:attribute name="removeOnFind" type="booleanType"/>
- <xs:attribute name="searchBackupTrees" type="booleanType"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="locator" maxOccurs="1">
- <xs:complexType>
- <xs:all>
- <xs:element name="properties" type="xs:string" maxOccurs="1"/>
- </xs:all>
- <xs:attribute name="class" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="enabled" type="booleanType"/>
- <xs:attribute name="poolName" type="xs:string"/>
- <xs:attribute name="communicationTimeout" type="xs:integer"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="invalidationType">
- <xs:choice>
- <xs:element name="sync" type="syncType"/>
- <xs:element name="async" type="asyncType"/>
- </xs:choice>
- </xs:complexType>
-
- <xs:complexType name="jmxStatisticsType">
- <xs:attribute name="enabled" type="booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="listenersType">
- <xs:attribute name="asyncPoolSize" type="positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="invocationBatchingType">
- <xs:attribute name="enabled" type="booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="transportType">
- <xs:sequence>
- <xs:element name="jgroupsConfig" type="xs:anyType" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- <xs:attribute name="clusterName" type="xs:string"/>
- <xs:attribute name="multiplexerStack" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="syncType">
- <xs:attribute name="replTimeout" type="positiveInteger"/>
- </xs:complexType>
-
-
- <xs:complexType name="asyncType">
- <xs:attribute name="useReplQueue" type="booleanType"/>
- <xs:attribute name="replQueueInterval" type="positiveInteger"/>
- <xs:attribute name="replQueueMaxElements" type="positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="evictionType">
- <xs:sequence>
- <xs:element name="default" type="evictionRegionType" minOccurs="0" maxOccurs="1"/>
- <xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="evictionRegionType"/>
- </xs:sequence>
- <xs:attribute name="wakeUpInterval" type="positiveInteger" use="required"/>
- <xs:attribute name="defaultPolicyClass" type="xs:string"/>
- <xs:attribute name="defaultEventQueueSize" type="positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="evictionRegionType">
- <xs:sequence>
- <xs:element name="attribute" maxOccurs="unbounded" type="attributeType"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="policyClass" type="xs:string"/>
- <xs:attribute name="eventQueueSize" type="positiveInteger"/>
- </xs:complexType>
-
- <xs:complexType name="loadersType">
- <xs:sequence>
- <xs:element name="preload" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="node" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="fqn" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="loader" maxOccurs="unbounded">
- <xs:complexType>
- <xs:all>
- <xs:element name="properties"/>
- <xs:element name="singletonStore" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:all>
- <xs:element name="properties" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:all>
- <xs:attribute name="enabled" type="booleanType"/>
- <xs:attribute name="class" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="async" type="booleanType"/>
- <xs:attribute name="fetchPersistentState" type="booleanType"/>
- <xs:attribute name="ignoreModifications" type="booleanType"/>
- <xs:attribute name="purgeOnStartup" type="booleanType"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="passivation" type="booleanType"/>
- <xs:attribute name="shared" type="booleanType"/>
- </xs:complexType>
-
- <xs:complexType name="customInterceptorsType">
- <xs:sequence>
- <xs:element name="interceptor" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="attribute" maxOccurs="unbounded" type="attributeType" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="position">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:enumeration value="first"/>
- <xs:enumeration value="last"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="before" type="xs:string"/>
- <xs:attribute name="after" type="xs:string"/>
- <xs:attribute name="index" type="positiveInteger"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="attributeType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="name" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-</xs:schema>
-
Copied: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd (from rev 6561, core/trunk/src/main/resources/jbosscache-config-3.0.xsd)
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd (rev 0)
+++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2008-08-15 21:16:37 UTC (rev 6564)
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:tns="urn:jboss:jbosscache-core:config:3.0" targetNamespace="urn:jboss:jbosscache-core:config:3.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
+
+ <xs:element name="jbosscache">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="locking" type="tns:lockingType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="transaction" type="tns:transactionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="startup" type="tns:startupType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="stateRetrieval" type="tns:stateRetrievalType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="shutdown" type="tns:shutdownType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="serialization" type="tns:serializationType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="replication" type="tns:replicationType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="invalidation" type="tns:invalidationType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="jmxStatistics" type="tns:jmxStatisticsType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="listeners" type="tns:listenersType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="invocationBatching" type="tns:invocationBatchingType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="transport" type="tns:transportType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="eviction" type="tns:evictionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="loaders" type="tns:loadersType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="customInterceptors" type="tns:customInterceptorsType" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="lockingType">
+ <xs:attribute name="isolationLevel">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern value="SERIALIZABLE|REPEATABLE_READ|READ_COMMITTED|NONE|\$\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="lockParentForChildInsertRemove" type="tns:booleanType"/>
+ <xs:attribute name="lockAcquisitionTimeout" type="tns:positiveInteger"/>
+ <xs:attribute name="nodeLockingScheme">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[Mm][Vv][Cc][Cc]|[Oo][Pp][Tt][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|[Pp][Ee][Ss][Ss][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|\$\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="writeSkewCheck" type="tns:booleanType"/>
+ <xs:attribute name="concurrencyLevel" type="xs:integer"/>
+ </xs:complexType>
+
+ <xs:complexType name="transactionType">
+ <xs:attribute name="transactionManagerLookupClass" type="xs:string"/>
+ <xs:attribute name="syncRollbackPhase" type="tns:booleanType"/>
+ <xs:attribute name="syncCommitPhase" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="startupType">
+ <xs:attribute name="regionsInactiveOnStartup" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="stateRetrievalType">
+ <xs:attribute name="fetchInMemoryState" type="tns:booleanType"/>
+ <xs:attribute name="timeout" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="shutdownType">
+ <xs:attribute name="hookBehavior">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:pattern value="DEFAULT|REGISTER|DONT_REGISTER|\$\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="serializationType">
+ <xs:attribute name="objectInputStreamPoolSize" type="tns:positiveInteger"/>
+ <xs:attribute name="objectOutputStreamPoolSize" type="tns:positiveInteger"/>
+ <xs:attribute name="version" type="xs:string"/>
+ <xs:attribute name="marshallerClass" type="xs:string"/>
+ <xs:attribute name="useLazyDeserialization" type="tns:booleanType"/>
+ <xs:attribute name="useRegionBasedMarshalling" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:simpleType name="booleanType">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="\$\{.*\}|true|false"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="positiveInteger">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="\$\{.*\}|\+?[0-9]*"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="replicationType">
+ <xs:sequence>
+ <xs:choice>
+ <xs:element name="sync" type="tns:syncType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="async" type="tns:asyncType" minOccurs="0" maxOccurs="1"/>
+ </xs:choice>
+ <xs:element name="buddy" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:all minOccurs="0">
+ <xs:element name="dataGravitation" maxOccurs="1">
+ <xs:complexType>
+ <xs:attribute name="auto" type="tns:booleanType"/>
+ <xs:attribute name="removeOnFind" type="tns:booleanType"/>
+ <xs:attribute name="searchBackupTrees" type="tns:booleanType"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="locator" maxOccurs="1">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties" type="xs:string" maxOccurs="1"/>
+ </xs:all>
+ <xs:attribute name="class" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ <xs:attribute name="poolName" type="xs:string"/>
+ <xs:attribute name="communicationTimeout" type="xs:integer"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="invalidationType">
+ <xs:choice>
+ <xs:element name="sync" type="tns:syncType"/>
+ <xs:element name="async" type="tns:asyncType"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="jmxStatisticsType">
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="listenersType">
+ <xs:attribute name="asyncPoolSize" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="invocationBatchingType">
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="transportType">
+ <xs:sequence>
+ <xs:element name="jgroupsConfig" type="xs:anyType" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:attribute name="clusterName" type="xs:string"/>
+ <xs:attribute name="multiplexerStack" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="syncType">
+ <xs:attribute name="replTimeout" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+
+ <xs:complexType name="asyncType">
+ <xs:attribute name="useReplQueue" type="tns:booleanType"/>
+ <xs:attribute name="replQueueInterval" type="tns:positiveInteger"/>
+ <xs:attribute name="replQueueMaxElements" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="evictionType">
+ <xs:sequence>
+ <xs:element name="default" type="tns:evictionRegionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="tns:evictionRegionType"/>
+ </xs:sequence>
+ <xs:attribute name="wakeUpInterval" type="tns:positiveInteger" use="required"/>
+ <xs:attribute name="defaultPolicyClass" type="xs:string"/>
+ <xs:attribute name="defaultEventQueueSize" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="evictionRegionType">
+ <xs:sequence>
+ <xs:element name="attribute" maxOccurs="unbounded" type="tns:attributeType"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="policyClass" type="xs:string"/>
+ <xs:attribute name="eventQueueSize" type="tns:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="loadersType">
+ <xs:sequence>
+ <xs:element name="preload" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="node" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="fqn" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="loader" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties"/>
+ <xs:element name="singletonStore" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ <xs:attribute name="enabled" type="tns:booleanType"/>
+ <xs:attribute name="class" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="async" type="tns:booleanType"/>
+ <xs:attribute name="fetchPersistentState" type="tns:booleanType"/>
+ <xs:attribute name="ignoreModifications" type="tns:booleanType"/>
+ <xs:attribute name="purgeOnStartup" type="tns:booleanType"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="passivation" type="tns:booleanType"/>
+ <xs:attribute name="shared" type="tns:booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="customInterceptorsType">
+ <xs:sequence>
+ <xs:element name="interceptor" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="attribute" maxOccurs="unbounded" type="tns:attributeType" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="position">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="first"/>
+ <xs:enumeration value="last"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="before" type="xs:string"/>
+ <xs:attribute name="after" type="xs:string"/>
+ <xs:attribute name="index" type="tns:positiveInteger"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="attributeType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="name" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+</xs:schema>
+
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -554,7 +554,7 @@
" </properties>\n" +
" </loader>\n" +
" </loaders>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
LoadersElementParser elementParser = new LoadersElementParser();
return elementParser.parseLoadersElement(element);
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -61,7 +61,7 @@
private BuddyReplicationConfig getBuddyReplicationConfig(String xmlConfig)
throws Exception
{
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xmlConfig);
BuddyElementParser replicationElementParser = new BuddyElementParser();
return replicationElementParser.parseBuddyElement(element);
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -76,7 +76,7 @@
private BuddyReplicationConfig getBuddyReplicationConfig(String xmlConfig)
throws Exception
{
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xmlConfig);
BuddyElementParser elementParser = new BuddyElementParser();
BuddyReplicationConfig config = elementParser.parseBuddyElement(element);
return config;
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -26,7 +26,7 @@
public void testDefaultValues() throws Exception
{
String xmlConfig = "<buddyReplication enabled=\"true\"/>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xmlConfig);
BuddyReplicationConfig brConfig = parser.parseBuddyElement(element);
assert brConfig.getBuddyLocatorConfig().getClassName().equals(NextMemberBuddyLocator.class.getName()) : "default buddy locator class is NextMemberBuddyLocator";
assert brConfig.getBuddyLocatorConfig().getBuddyLocatorProperties().isEmpty();
@@ -49,7 +49,7 @@
" </properties>\n" +
" </locator>\n" +
" </buddyReplication>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xmlConfig);
BuddyReplicationConfig brConfig = parser.parseBuddyElement(element);
assert brConfig.getBuddyLocatorConfig().getClassName().equals(NextMemberBuddyLocator.class.getName()) : "default buddy locator class is NextMemberBuddyLocator";
assert brConfig.getBuddyLocatorConfig().getBuddyLocatorProperties().get("numBuddies").equals("3");
@@ -66,7 +66,7 @@
" </properties>\n" +
" </locator>\n" +
" </buddyReplication>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xmlConfig);
BuddyReplicationConfig brConfig = parser.parseBuddyElement(element);
assert brConfig.isEnabled();
assert brConfig.getBuddyPoolName().equals("groupOne");
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -139,7 +139,7 @@
private CacheLoaderConfig getCacheLoaderConfig(String xmlStr)
throws Exception
{
- Element element = XmlConfigHelper.stringToElement(xmlStr);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xmlStr);
return parser.parseLoadersElement(element);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -62,7 +62,7 @@
" <interceptor after=\"org.jboss.cache.interceptors.CallInterceptor\"\n" +
" class=\"org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor\"/>\n" +
" </customInterceptors>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
List<CustomInterceptorConfig> configs = parser.parseCustomInterceptors(element);
assert configs.size() == 5;
CustomInterceptorConfig one = configs.get(0);
@@ -104,7 +104,7 @@
" <attribute name=\"nonexistenAttribute\">value3</attribute>\n" +
" </interceptor>\n" +
" </customInterceptors>";
- Element el = XmlConfigHelper.stringToElement(xml);
+ Element el = XmlConfigHelper.stringToElementInCoreNS(xml);
try
{
parser.parseCustomInterceptors(el);
@@ -126,7 +126,7 @@
" <attribute name=\"notExists\">value1</attribute>\n" +
" </interceptor>\n" +
" </customInterceptors>";
- Element el = XmlConfigHelper.stringToElement(xml);
+ Element el = XmlConfigHelper.stringToElementInCoreNS(xml);
try
{
parser.parseCustomInterceptors(el);
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-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -222,7 +222,7 @@
Element el;
try
{
- el = XmlConfigHelper.stringToElement(xml);
+ el = XmlConfigHelper.stringToElementInCoreNS(xml);
}
catch (Exception e)
{
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -68,7 +68,7 @@
" <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
" <pbcast.FLUSH timeout=\"0\"/>\n" +
"</jgroupsConfig>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
String result = parser.parseClusterConfigXml(element);
assert result.indexOf("ucast_recv_buf_size=20000000") > 0;
assert result.indexOf("num_initial_members=3") > 0;
@@ -78,7 +78,7 @@
public void testParsingEmptyConfig() throws Exception
{
String xml = "<jgroupsConfig/>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
String result = parser.parseClusterConfigXml(element);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -28,7 +28,7 @@
"<attribute name=\"maxElementsPerNode\">100</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(100, config.getMaxElementsPerNode());
@@ -43,7 +43,7 @@
"<attribute name=\"maxNodes\">1000</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
try
{
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -65,7 +65,7 @@
"<attribute name=\"maxElementsPerNode\">100</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -29,7 +29,7 @@
"<attribute name=\"maxNodes\">1000</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -43,7 +43,7 @@
String xml = "<region name=\"abc\">" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
try
{
@@ -64,7 +64,7 @@
"<attribute name=\"maxNodes\">1000</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
try
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -31,7 +31,7 @@
"<attribute name=\"maxNodes\">20</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -46,7 +46,7 @@
"<region name=\"abc\">" +
"<attribute name=\"minNodes\">10</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -61,7 +61,7 @@
"<region name=\"abc\">" +
"<attribute name=\"maxNodes\">20</attribute>" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -33,7 +33,7 @@
"<attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -49,7 +49,7 @@
"<attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
"<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -65,7 +65,7 @@
"<attribute name=\"maxNodes\">10000</attribute>\n" +
"<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
boolean caught = false;
try
{
@@ -82,7 +82,7 @@
"<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
"</region>";
- element = XmlConfigHelper.stringToElement(xml);
+ element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -38,7 +38,7 @@
"<region name=\"/org/jboss/data\">\n" +
"<attribute name=\"maxNodes\">5000</attribute>\n" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -50,7 +50,7 @@
String xml = "<region name=\"/Test/\">\n" +
"<attribute name=\"maxNodes\">10000</attribute>\n" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
@@ -61,7 +61,7 @@
{
String xml = "<region name=\"/Test/\">\n" +
"</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
boolean caught = false;
try
{
@@ -77,7 +77,7 @@
"<attribute name=\"maxNodes\">10000</attribute>\n" +
"</region>";
- element = XmlConfigHelper.stringToElement(xml);
+ element = XmlConfigHelper.stringToElementInCoreNS(xml);
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -41,7 +41,7 @@
private void testConfigBlock(String xml) throws Exception
{
- Element element = XmlConfigHelper.stringToElement(xml);
+ Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
NullEvictionAlgorithmConfig config = new NullEvictionAlgorithmConfig();
EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
}
Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -175,8 +175,8 @@
XmlConfigurationParser parser = new UnitTestXmlConfigurationParser();
Configuration conf = parser.parseElement(root);
- Element list = (Element) root.getElementsByTagName("protocol_stacks").item(0);
- NodeList stacks = list.getElementsByTagName("stack");
+ Element list = (Element) root.getElementsByTagNameNS("*","protocol_stacks").item(0);
+ NodeList stacks = list.getElementsByTagNameNS("*", "stack");
for (int i = 0; i < stacks.getLength(); i++)
{
@@ -184,7 +184,7 @@
String stackName = stack.getAttribute("name");
if (stackName.startsWith(JGROUPS_CHANNEL))
{
- Element jgroupsStack = (Element) stack.getElementsByTagName("config").item(0);
+ Element jgroupsStack = (Element) stack.getElementsByTagNameNS("*", "config").item(0);
if (mode == CacheMode.REPL_ASYNC && !stackName.contains("-"))
{
conf.setClusterConfig(jgroupsStack);
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -277,7 +277,7 @@
" </properties>\n" +
" </locator>\n" +
" </buddy>";
- return XmlConfigHelper.stringToElement(xmlStr);
+ return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
protected static Element getCacheLoaderConfig() throws Exception
@@ -302,7 +302,7 @@
" <singletonStore enabled=\"false\" /> \n" +
" </loader>\n" +
" </loaders>";
- return XmlConfigHelper.stringToElement(xmlStr);
+ return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
protected static Element getEvictionPolicyConfig() throws Exception
@@ -326,7 +326,7 @@
" <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
"</region>\n" +
" </eviction>";
- return XmlConfigHelper.stringToElement(xmlStr);
+ return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
protected static Element getClusterConfig() throws Exception
@@ -383,7 +383,7 @@
" <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
" <pbcast.FLUSH timeout=\"0\"/>\n" +
"</jgroupsConfig>";
- return XmlConfigHelper.stringToElement(xml);
+ return XmlConfigHelper.stringToElementInCoreNS(xml);
}
protected String getDefaultProperties()
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -59,7 +59,7 @@
private static Element strToElement(String s) throws Exception
{
- return XmlConfigHelper.stringToElement(s);
+ return XmlConfigHelper.stringToElementInCoreNS(s);
}
public void testSingleCacheLoader() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-08-15 21:16:37 UTC (rev 6564)
@@ -104,7 +104,7 @@
" </loader>" +
" </loaders>";
LoadersElementParser parser = new LoadersElementParser();
- CacheLoaderConfig cacheLoaderConfig = parser.parseLoadersElement(XmlConfigHelper.stringToElement(xml));
+ CacheLoaderConfig cacheLoaderConfig = parser.parseLoadersElement(XmlConfigHelper.stringToElementInCoreNS(xml));
Configuration c = cache.getConfiguration();
c.setCacheLoaderConfig(cacheLoaderConfig);
cache.start();
Modified: core/trunk/src/test/resources/configs/buddy-replication-cache.xml
===================================================================
--- core/trunk/src/test/resources/configs/buddy-replication-cache.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/buddy-replication-cache.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000"/>
Modified: core/trunk/src/test/resources/configs/clonable-config.xml
===================================================================
--- core/trunk/src/test/resources/configs/clonable-config.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/clonable-config.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="SERIALIZABLE" lockAcquisitionTimeout="1" nodeLockingScheme="optimistic"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval fetchInMemoryState="false" timeout="3"/>
Modified: core/trunk/src/test/resources/configs/local-lru-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/local-passivation.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-passivation.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/local-passivation.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/local-tx.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-tx.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/local-tx.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/mux.xml
===================================================================
--- core/trunk/src/test/resources/configs/mux.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/mux.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
Modified: core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml
===================================================================
--- core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000" nodeLockingScheme="mvcc"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000" fetchInMemoryState="false"/>
Modified: core/trunk/src/test/resources/configs/parser-test.xml
===================================================================
--- core/trunk/src/test/resources/configs/parser-test.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/parser-test.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -3,7 +3,7 @@
<!-- file used for functional test of the xml parser -->
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
Modified: core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000"/>
Modified: core/trunk/src/test/resources/configs/replSync.xml
===================================================================
--- core/trunk/src/test/resources/configs/replSync.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/replSync.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<serialization useRegionBasedMarshalling="true"/>
Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml
===================================================================
--- core/trunk/src/test/resources/configs/string-property-replaced.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking lockAcquisitionTimeout="${test.property.LockAcquisitionTimeout:15000}"
nodeLockingScheme="${test.property.NodeLockingScheme:OPTIMISTIC}"/>
<transaction syncCommitPhase="${test.property.SyncCommitPhase:true}" syncRollbackPhase="true"/>
Modified: core/trunk/src/test/resources/jbc2-registry-configs.xml
===================================================================
(Binary files differ)
Modified: core/trunk/src/test/resources/unit-test-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-15 12:14:09 UTC (rev 6563)
+++ core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-15 21:16:37 UTC (rev 6564)
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-
-<jbosscache>
-
+<jbosscache xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<serialization useRegionBasedMarshalling="false"/>
16 years, 4 months
JBoss Cache SVN: r6563 - core/branches/1.4.X/src/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2008-08-15 08:14:09 -0400 (Fri, 15 Aug 2008)
New Revision: 6563
Modified:
core/branches/1.4.X/src/org/jboss/cache/TreeCache.java
Log:
[JBCACHE-1393] Fixed javadoc.
Modified: core/branches/1.4.X/src/org/jboss/cache/TreeCache.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2008-08-15 10:59:40 UTC (rev 6562)
+++ core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2008-08-15 12:14:09 UTC (rev 6563)
@@ -3816,7 +3816,7 @@
* @param key
* @param value
* @param timeout Number of milliseconds to wait until a lock has been acquired. A TimeoutException will
- * be thrown if not successful. 0 means to wait forever
+ * be thrown if not successful. 0 means no wait at all.
* @return
* @throws CacheException
* @deprecated This is a kludge created specifically form the Hibernate 3.0 release. This method should
16 years, 4 months
JBoss Cache SVN: r6562 - in core/trunk/src: main/java/org/jboss/cache/config and 21 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-15 06:59:40 -0400 (Fri, 15 Aug 2008)
New Revision: 6562
Added:
core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurationComponent.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionActionPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.java
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
Removed:
core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java
core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.java
core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionConfiguration.java
core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPolicy.java
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/Region.java
core/trunk/src/main/java/org/jboss/cache/RegionImpl.java
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyConfig.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfiguration.java
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionException.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.java
core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java
core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java
core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/util/Util.java
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
core/trunk/src/test/resources/unit-test-cache-service.xml
Log:
Changes to eviction interfaces
Modified: core/trunk/src/main/java/org/jboss/cache/Region.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Region.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/Region.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -7,11 +7,8 @@
package org.jboss.cache;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionPolicyConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.EvictedEventNode;
-import org.jboss.cache.eviction.EvictionPolicy;
-import org.jboss.cache.eviction.LRUPolicy;
+import org.jboss.cache.eviction.EvictionEvent;
/**
* Defines characteristics such as class loading and eviction of {@link org.jboss.cache.Node}s belonging to a Region in a {@link Cache}.
@@ -19,7 +16,7 @@
* All nodes and child nodes of this Fqn belong to this region.
* <p/>
* If a region is to be recognised as an eviction region (region of type {@link Type#EVICTION} then
- * it <b>must</b> have an {@link org.jboss.cache.config.EvictionPolicyConfig} set using {@link #setEvictionPolicy(org.jboss.cache.config.EvictionPolicyConfig)}.
+ * it <b>must</b> have an {@link org.jboss.cache.config.EvictionRegionConfig} set using {@link #setEvictionRegionConfig(org.jboss.cache.config.EvictionRegionConfig)}.
* <p/>
* Similarly, to be recognised as a marshalling region (region of type {@link Type#MARSHALLING} then it <b>must</b> have a
* {@link ClassLoader} registered using {@link #registerContextClassLoader(ClassLoader)}.
@@ -33,7 +30,6 @@
*/
public interface Region extends Comparable<Region>
{
-
/**
* Types of regions.
*/
@@ -114,67 +110,52 @@
ClassLoader getClassLoader();
/**
- * Configures an eviction policy for this region.
- *
- * @param evictionPolicyConfig configuration to set
+ * Processes the eviction queues (primary and recycle queues) associated with this region. A no-op if this is not an eviction region.
*/
- void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig);
+ void processEvictionQueues();
/**
- * Returns an eviction policy configuration.
- *
- * @return an eviction policy configuration
+ * Clears the node event queue used for processing eviction.
*/
- EvictionPolicyConfig getEvictionPolicyConfig();
+ void resetEvictionQueues();
/**
- * Returns an eviction policy.
+ * Configures this region for eviction.
*
- * @return an eviction policy
+ * @param evictionRegionConfig configuration to set
*/
- EvictionPolicy getEvictionPolicy();
+ void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig);
/**
- * Returns an eviction region configuration for this region.
- *
- * @return an eviction region configuration
+ * @return the eviction region config, if any, set on the current region.
*/
EvictionRegionConfig getEvictionRegionConfig();
/**
- * Clears the node event queue used for processing eviction.
+ * Registers an eviction event on the region's eviction event queue for later processing by
+ * {@link #processEvictionQueues()}.
*
- * @see #nodeEventQueueSize()
+ * @param fqn passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
+ * @param eventType passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
+ * @param elementDifference passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
+ * @return an EvictedEventNode that has been created for this queue
*/
- void resetEvictionQueues();
+ EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType, int elementDifference);
/**
- * Returns the size of the node event queue, used by the eviction thread.
+ * An overloaded version of {@link #registerEvictionEvent(Fqn, org.jboss.cache.eviction.EvictionEvent.Type, int)} which
+ * uses a default elementDifference value.
*
- * @return number of events
+ * @param fqn passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
+ * @param eventType passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
+ * @return an EvictedEventNode that has been created for this queue
*/
- int nodeEventQueueSize();
+ EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType);
/**
- * Returns the most recent {@link org.jboss.cache.eviction.EvictedEventNode} added to the event queue by
- * {@link #putNodeEvent(EvictedEventNode)}.
- *
- * @return the last {@link org.jboss.cache.eviction.EvictedEventNode}, or null if no more events exist
- */
- EvictedEventNode takeLastEventNode();
-
- /**
- * Adds an {@link org.jboss.cache.eviction.EvictedEventNode} to the internal queue for processing
- * by the eviction thread.
- *
- * @param event event to add
- */
- void putNodeEvent(EvictedEventNode event);
-
- /**
* Marks a {@link org.jboss.cache.Node} as currently in use, by adding an event to the eviction queue.
- * If there is an {@link EvictionPolicy} associated with this region, and
- * it respects this event (e.g., {@link LRUPolicy} does), then the {@link org.jboss.cache.Node} will not
+ * If there is an {@link org.jboss.cache.config.EvictionRegionConfig} associated with this region, and
+ * it respects this event (e.g., {@link org.jboss.cache.eviction.LRUAlgorithm} does), then the {@link org.jboss.cache.Node} will not
* be evicted until {@link #unmarkNodeCurrentlyInUse(Fqn)} is invoked.
* <p/>
* This mechanism can be used to prevent eviction of data that the application
Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -9,16 +9,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.EvictedEventNode;
-import org.jboss.cache.eviction.EvictionPolicy;
-import org.jboss.cache.eviction.NodeEventType;
+import org.jboss.cache.eviction.EvictionActionPolicy;
+import org.jboss.cache.eviction.EvictionAlgorithm;
+import org.jboss.cache.eviction.EvictionEvent;
import org.jboss.cache.util.Util;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
/**
* Default implementation of a {@link Region}
@@ -28,16 +27,17 @@
public class RegionImpl implements Region
{
private static final Log log = LogFactory.getLog(RegionImpl.class);
-
+ private static final boolean trace = log.isTraceEnabled();
private final RegionManager regionManager;
private Fqn fqn;
private Status status;
private ClassLoader classLoader;
- private BlockingQueue<EvictedEventNode> nodeEventQueue = null;
+ private BlockingQueue<EvictionEvent> evictionEventQueue = null;
private int capacityWarnThreshold = 0;
- private EvictionRegionConfig configuration = new EvictionRegionConfig();
- private EvictionPolicy policy;
+ private EvictionRegionConfig evictionRegionConfig;
+ private EvictionAlgorithm evictionAlgorithm;
+
/**
* Constructs a marshalling region from an fqn and region manager.
*/
@@ -51,11 +51,10 @@
/**
* Constructs an eviction region from a policy and configuration, defined by an fqn and region manager.
*/
- public RegionImpl(EvictionPolicy policy, EvictionRegionConfig config, Fqn fqn, RegionManager regionManager)
+ public RegionImpl(EvictionRegionConfig config, Fqn fqn, RegionManager regionManager)
{
this(fqn, regionManager);
- this.configuration = config;
- this.policy = policy;
+ this.evictionRegionConfig = config;
createQueue();
}
@@ -105,6 +104,11 @@
return classLoader;
}
+ public void processEvictionQueues()
+ {
+ evictionAlgorithm.process(evictionEventQueue);
+ }
+
public Fqn getFqn()
{
return fqn;
@@ -127,17 +131,19 @@
// -------- eviction stuff -----
+ public BlockingQueue<EvictionEvent> getEvictionEventQueue()
+ {
+ return evictionEventQueue;
+ }
+
public void markNodeCurrentlyInUse(Fqn fqn, long timeout)
{
- EvictedEventNode markUse = new EvictedEventNode(fqn, NodeEventType.MARK_IN_USE_EVENT);
- markUse.setInUseTimeout(timeout);
- putNodeEvent(markUse);
+ registerEvictionEvent(fqn, EvictionEvent.Type.MARK_IN_USE_EVENT, 0).setInUseTimeout(timeout);
}
public void unmarkNodeCurrentlyInUse(Fqn fqn)
{
- EvictedEventNode markNoUse = new EvictedEventNode(fqn, NodeEventType.UNMARK_USE_EVENT);
- putNodeEvent(markNoUse);
+ registerEvictionEvent(fqn, EvictionEvent.Type.UNMARK_USE_EVENT, 0);
}
@Override
@@ -147,8 +153,8 @@
"fqn=" + fqn +
"; classloader=" + classLoader +
"; status=" + status +
- "; eviction=" + (getEvictionPolicy() != null) +
- "; timerThreadRegistered=" + (getEvictionPolicy() != null && regionManager.getEvictionTimerTask().isRegionRegisteredForProcessing(this)) +
+ "; eviction=" + (evictionAlgorithm != null) +
+ "; timerThreadRegistered=" + (evictionAlgorithm != null && regionManager.getEvictionTimerTask().isRegionRegisteredForProcessing(this)) +
'}';
}
@@ -176,105 +182,97 @@
return (fqn != null ? fqn.hashCode() : 0);
}
- public void putNodeEvent(EvictedEventNode event)
+ public void resetEvictionQueues()
{
- try
- {
- if (nodeEventQueue == null) createQueue();// in case the queue does not exist yet.
- if (nodeEventQueue.size() > capacityWarnThreshold)
- {
- log.warn("putNodeEvent(): eviction node event queue size is at 98% threshold value of capacity: " + configuration.getEventQueueSize() +
- " Region: " + fqn +
- " You will need to reduce the wakeUpIntervalSeconds parameter.");
- }
- nodeEventQueue.put(event);
- }
- catch (InterruptedException e)
- {
- log.debug("give up put", e);
- }
+ evictionEventQueue.clear();
}
- public EvictedEventNode takeLastEventNode()
+ public void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
{
+ this.evictionRegionConfig = evictionRegionConfig;
+ evictionAlgorithm = createEvictionAlgorithm(evictionRegionConfig.getEvictionAlgorithmConfig(), evictionRegionConfig.getEvictionActionPolicyClassName());
+ regionManager.getEvictionTimerTask().addRegionToProcess(this);
+ if (evictionEventQueue == null) createQueue();
+ evictionAlgorithm.initialize();
+ }
+
+ public EvictionRegionConfig getEvictionRegionConfig()
+ {
+ return evictionRegionConfig;
+ }
+
+ public EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType)
+ {
+ return registerEvictionEvent(fqn, eventType, 0);
+ }
+
+ public EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType, int elementDifference)
+ {
+ if (evictionAlgorithm.canIgnoreEvent(eventType)) return null;
+
+ EvictionEvent event = new EvictionEvent(fqn, eventType, elementDifference);
try
{
- return nodeEventQueue.poll(0, TimeUnit.SECONDS);
+ if (evictionEventQueue == null) createQueue();// in case the queue does not exist yet.
+ if (evictionEventQueue.size() > capacityWarnThreshold)
+ {
+ if (log.isWarnEnabled())
+ log.warn("putNodeEvent(): eviction node event queue size is at 98% threshold value of capacity: " + evictionRegionConfig.getEventQueueSize() +
+ " Region: " + fqn +
+ " You will need to reduce the wakeUpIntervalSeconds parameter.");
+ }
+ evictionEventQueue.put(event);
}
catch (InterruptedException e)
{
+ if (log.isDebugEnabled()) log.debug("Interrupted on adding event", e);
+ // reinstate interrupt flag
Thread.currentThread().interrupt();
}
- return null;
+ return event;
}
- public int nodeEventQueueSize()
- {
- return nodeEventQueue.size();
- }
-
- public void resetEvictionQueues()
- {
- nodeEventQueue.clear();
- }
-
private void createQueue()
{
- if (nodeEventQueue == null)
+ if (evictionEventQueue == null)
{
- if (configuration == null)
+ if (evictionRegionConfig == null)
{
throw new IllegalArgumentException("null eviction configuration");
}
- int size = configuration.getEventQueueSize();
+ int size = evictionRegionConfig.getEventQueueSize();
capacityWarnThreshold = (98 * size) / 100 - 100;
if (capacityWarnThreshold <= 0)
{
throw new RuntimeException("Capacity warn threshold used in eviction is smaller than 1.");
}
- nodeEventQueue = new LinkedBlockingQueue<EvictedEventNode>(size);
+ evictionEventQueue = new LinkedBlockingQueue<EvictionEvent>(size);
}
}
- public EvictionRegionConfig getEvictionRegionConfig()
+ private EvictionAlgorithm createEvictionAlgorithm(EvictionAlgorithmConfig algoConfig, String evictionActionPolicyClass)
{
- return this.configuration;
- }
+ if (algoConfig == null)
+ throw new IllegalArgumentException("Eviction algorithm class must not be null!");
- public EvictionPolicyConfig getEvictionPolicyConfig()
- {
- return configuration == null ? null : configuration.getEvictionPolicyConfig();
- }
+ if (evictionActionPolicyClass == null)
+ throw new IllegalArgumentException("Eviction action policy class must not be null!");
- public EvictionPolicy getEvictionPolicy()
- {
- return policy;
- }
-
- public void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig)
- {
- configuration.setEvictionPolicyConfig(evictionPolicyConfig);
- policy = createPolicy(evictionPolicyConfig.getEvictionPolicyClass());
- regionManager.getEvictionTimerTask().addRegionToProcess(this);
- if (nodeEventQueue == null) createQueue();
- }
-
- private EvictionPolicy createPolicy(String className)
- {
- if (className == null)
- {
- throw new IllegalArgumentException("null className");
- }
try
{
- if (log.isTraceEnabled()) log.trace("Instantiating " + className);
- EvictionPolicy ep = (EvictionPolicy) Util.loadClass(className).newInstance();
- ep.setCache(regionManager.getCache());
- return ep;
+ if (trace) log.trace("Instantiating " + evictionActionPolicyClass);
+ EvictionActionPolicy actionPolicy = (EvictionActionPolicy) Util.getInstance(evictionActionPolicyClass);
+ actionPolicy.setCache(regionManager.getCache());
+
+ if (trace) log.trace("Instantiating " + algoConfig.getEvictionAlgorithmClassName());
+ EvictionAlgorithm algorithm = (EvictionAlgorithm) Util.getInstance(algoConfig.getEvictionAlgorithmClassName());
+ algorithm.setEvictionActionPolicy(actionPolicy);
+ algorithm.assignToRegion(fqn, regionManager.getCache(), algoConfig, regionManager.getConfiguration());
+ return algorithm;
}
catch (Exception e)
{
- log.fatal("Unable to instantiate eviction policy class " + className, e);
+ log.fatal("Unable to instantiate eviction algorithm " + algoConfig.getEvictionAlgorithmClassName(), e);
throw new IllegalStateException(e);
}
}
@@ -282,14 +280,13 @@
public Region copy(Fqn newRoot)
{
RegionImpl clone;
- clone = new RegionImpl(policy, configuration, Fqn.fromRelativeFqn(newRoot, fqn), regionManager);
+ clone = new RegionImpl(evictionRegionConfig, Fqn.fromRelativeFqn(newRoot, fqn), regionManager);
clone.status = status;
// we also need to copy all of the eviction event nodes to the clone's queue
clone.createQueue();
- for (EvictedEventNode een : this.nodeEventQueue)
+ for (EvictionEvent een : this.evictionEventQueue)
{
- EvictedEventNode cloneEEN = een.copy(newRoot);
- clone.putNodeEvent(cloneEEN);
+ clone.registerEvictionEvent(een.getFqn(), een.getEventType(), een.getElementDifference());
}
return clone;
}
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,5 +1,6 @@
package org.jboss.cache;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.eviction.EvictionTimerTask;
@@ -176,4 +177,9 @@
* @return the eviction timer task attached to the region manager
*/
EvictionTimerTask getEvictionTimerTask();
+
+ /**
+ * @return the configuration
+ */
+ Configuration getConfiguration();
}
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,8 +8,8 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.EvictionTimerTask;
import org.jboss.cache.factories.annotations.Destroy;
@@ -92,16 +92,21 @@
@Start
public void start()
{
- log.trace("Starting region manager");
+ if (trace) log.trace("Starting region manager");
isUsingBR = configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled();
if (configuration.getEvictionConfig() != null
&& configuration.getEvictionConfig().isValidConfig())
{
+ // start with the default region
+ EvictionRegionConfig defaultRegion = configuration.getEvictionConfig().getDefaultEvictionRegionConfig();
+ defaultRegion.getEvictionAlgorithmConfig().validate();
+
// validate individual region configs now
for (EvictionRegionConfig erc : configuration.getEvictionConfig().getEvictionRegionConfigs())
{
- EvictionPolicyConfig epc = erc.getEvictionPolicyConfig();
- if (epc != null) epc.validate();
+ evictionConfig.applyDefaults(erc);
+ EvictionAlgorithmConfig eac = erc.getEvictionAlgorithmConfig();
+ if (eac != null) eac.validate();
}
setEvictionConfig(configuration.getEvictionConfig());
@@ -200,7 +205,7 @@
// mandates that class loaders be registered for marshalling regions.
if (type == ANY
|| (type == MARSHALLING && r.getClassLoader() != null)
- || (type == EVICTION && r.getEvictionPolicyConfig() != null))
+ || (type == EVICTION && r.getEvictionRegionConfig() != null))
{
return r;
}
@@ -235,7 +240,7 @@
// mandates that class loaders be registered for marshalling regions.
if (type == ANY
|| (type == MARSHALLING && r.getClassLoader() != null)
- || (type == EVICTION && r.getEvictionPolicyConfig() != null))
+ || (type == EVICTION && r.getEvictionRegionConfig() != null))
{
nextBestThing = r;
}
@@ -264,7 +269,7 @@
Region r = regionsRegistry.remove(fqn);
if (r == null) return false;
- if (isUsingEvictions() && r.getEvictionPolicy() != null)
+ if (isUsingEvictions() && r.getEvictionRegionConfig() != null)
{
evictionTimerTask.removeRegionToProcess(r);
}
@@ -276,6 +281,11 @@
return evictionTimerTask;
}
+ public Configuration getConfiguration()
+ {
+ return configuration;
+ }
+
public void activate(Fqn fqn) throws RegionNotEmptyException
{
activate(fqn, false);
@@ -600,7 +610,7 @@
case ANY:
return true;
case EVICTION:
- return r.getEvictionPolicy() != null && evictionTimerTask.isRegionRegisteredForProcessing(r);
+ return r.getEvictionRegionConfig() != null && evictionTimerTask.isRegionRegisteredForProcessing(r);
case MARSHALLING:
return r.isActive() && r.getClassLoader() != null;
}
@@ -671,7 +681,7 @@
// we need to loop thru the regions and only select specific regions to rtn.
for (Region r : regionsRegistry.values())
{
- if ((type == EVICTION && r.getEvictionPolicy() != null && evictionTimerTask.isRegionRegisteredForProcessing(r)) ||
+ if ((type == EVICTION && r.getEvictionRegionConfig() != null && evictionTimerTask.isRegionRegisteredForProcessing(r)) ||
(type == MARSHALLING && r.isActive() && r.getClassLoader() != null))
regions.add(r);
}
@@ -698,24 +708,24 @@
// JBAS-1288
// Try to establish a default region if there isn't one already
- boolean needDefault;
+// boolean needDefault;
List<EvictionRegionConfig> ercs = evictionConfig.getEvictionRegionConfigs();
// Only add a default region if there are no regions. This is
// contrary to the idea that there *must* be a default region, but some
// unit tests fail w/ APPROACH 1, so for now we go with this approach.
- needDefault = ercs.size() == 0;
+// needDefault = ercs.size() == 0;
+ ercs.add(0, evictionConfig.getDefaultEvictionRegionConfig());
+// if (needDefault)
+// {
+// // This may throw ConfigurationException if there is no default
+// // eviction policy class
+// EvictionRegionConfig dflt = evictionConfig.createDefaultEvictionRegionConfig();
+// ercs.add(0, dflt); // put it first
+// // Need to pass this back into the evictionConfig so it knows
+// // about the new region
+// evictionConfig.setEvictionRegionConfigs(ercs);
+// }
- if (needDefault)
- {
- // This may throw ConfigurationException if there is no default
- // eviction policy class
- EvictionRegionConfig dflt = evictionConfig.createDefaultEvictionRegionConfig();
- ercs.add(0, dflt); // put it first
- // Need to pass this back into the evictionConfig so it knows
- // about the new region
- evictionConfig.setEvictionRegionConfigs(ercs);
- }
-
// create regions for the regions defined in the evictionConfig.
// scan to be sure the _default_ region isn't added twice
boolean setDefault = false;
@@ -724,18 +734,19 @@
Fqn fqn = erc.getRegionFqn();
if (trace) log.trace("Creating eviction region " + fqn);
- if (fqn.equals(DEFAULT_REGION))
+ if (fqn.equals(DEFAULT_REGION) || fqn.isRoot())
{
if (setDefault)
{
throw new ConfigurationException("A default region for evictions has already been set for this cache");
}
- if (trace) log.trace("Applying settings for " + DEFAULT_REGION + " to Fqn.ROOT");
+ if (trace) log.trace("Applying settings for default region to Fqn.ROOT");
fqn = Fqn.ROOT;
setDefault = true;
}
Region r = getRegion(fqn, true);
- r.setEvictionPolicy(erc.getEvictionPolicyConfig());
+ evictionConfig.applyDefaults(erc);
+ r.setEvictionRegionConfig(erc);
}
}
Added: core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurationComponent.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurationComponent.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurationComponent.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,14 @@
+package org.jboss.cache.config;
+
+import java.io.Serializable;
+
+/**
+ * Interface for all configurable components
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface CloneableConfigurationComponent extends Serializable, Cloneable
+{
+ CloneableConfigurationComponent clone() throws CloneNotSupportedException;
+}
Modified: core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -14,7 +14,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -28,7 +27,7 @@
* @version $Revision$
* @see #testImmutability(String)
*/
-public abstract class ConfigurationComponent implements Serializable, Cloneable
+public abstract class ConfigurationComponent implements CloneableConfigurationComponent
{
private static final long serialVersionUID = 4879873994727821938L;
@@ -120,11 +119,6 @@
}
}
- /**
- * Sets a back-reference to the cache associated with this configuration
- *
- * @param cache
- */
public void setCache(CacheSPI cache)
{
this.cache = cache;
@@ -150,7 +144,7 @@
}
@Override
- public ConfigurationComponent clone() throws CloneNotSupportedException
+ public CloneableConfigurationComponent clone() throws CloneNotSupportedException
{
ConfigurationComponent c = (ConfigurationComponent) super.clone();
c.setCache(null);
Added: core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,41 @@
+package org.jboss.cache.config;
+
+/**
+ * An interface used to configure an eviction algorithm. Replaces the deprecated {@link org.jboss.cache.config.EvictionPolicyConfig}.
+ * <p/>
+ * In it's most basic form, it is implemented by {@link org.jboss.cache.eviction.EvictionAlgorithmConfigBase}, but
+ * more specific eviction policies may subclass {@link org.jboss.cache.eviction.EvictionAlgorithmConfigBase} or re-implement
+ * this interface to provide access to more config variables.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface EvictionAlgorithmConfig extends CloneableConfigurationComponent
+{
+ /**
+ * Gets the class name of the {@link org.jboss.cache.eviction.EvictionAlgorithm} implementation
+ * this object will configure.
+ *
+ * @return fully qualified class name
+ */
+ String getEvictionAlgorithmClassName();
+
+ /**
+ * Validate the configuration. Will be called after any configuration
+ * properties are set.
+ *
+ * @throws ConfigurationException if any values for the configuration
+ * properties are invalid
+ */
+ void validate() throws ConfigurationException;
+
+ /**
+ * Resets the values to their defaults.
+ */
+ void reset();
+
+ /**
+ * @return a clone of the EvictionAlgorithmConfig.
+ */
+ EvictionAlgorithmConfig clone() throws CloneNotSupportedException;
+}
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -22,11 +22,11 @@
package org.jboss.cache.config;
import org.jboss.cache.Fqn;
-import org.jboss.cache.RegionManagerImpl;
-import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.eviction.DefaultEvictionActionPolicy;
-import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
public class EvictionConfig extends ConfigurationComponent
{
@@ -35,51 +35,96 @@
*/
private static final long serialVersionUID = -7979639000026975201L;
- public static final int WAKEUP_DEFAULT = 5;
-
+ public static final int WAKEUP_DEFAULT = 5000;
public static final int EVENT_QUEUE_SIZE_DEFAULT = 200000;
+ public static final String EVICTION_ACTION_POLICY_CLASS_DEFAULT = DefaultEvictionActionPolicy.class.getName();
- private String defaultEvictionPolicyClass;
-
- @Deprecated
- private int wakeupIntervalSeconds = WAKEUP_DEFAULT;
-
/**
* value expressed in millis
*/
@Dynamic
- private long wakeupInterval = WAKEUP_DEFAULT * 1000;
+ private long wakeupInterval = WAKEUP_DEFAULT;
private int defaultEventQueueSize = EVENT_QUEUE_SIZE_DEFAULT;
// Dynamic to support runtime adds/removes of regions
@Dynamic
private List<EvictionRegionConfig> evictionRegionConfigs;
+ private EvictionRegionConfig defaultEvictionRegionConfig;
public EvictionConfig()
{
+ evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+ defaultEvictionRegionConfig = new EvictionRegionConfig(Fqn.ROOT);
+ defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
+ defaultEvictionRegionConfig.setEvictionActionPolicyClassName(DefaultEvictionActionPolicy.class.getName());
}
- public EvictionConfig(String defaultEvictionClass)
+ /**
+ * @deprecated Use {@link #EvictionConfig(EvictionRegionConfig)} instead.
+ */
+ @Deprecated
+ public EvictionConfig(String defaultEvictionPolicyClass)
{
- setDefaultEvictionPolicyClass(defaultEvictionClass);
+ this();
+ setDefaultEvictionPolicyClass(defaultEvictionPolicyClass);
}
+ public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig)
+ {
+ evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+ try
+ {
+ this.defaultEvictionRegionConfig = defaultEvictionRegionConfig.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new ConfigurationException(e);
+ }
+ this.defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
+ if (this.defaultEvictionRegionConfig.getEvictionActionPolicyClassName() == null)
+ this.defaultEvictionRegionConfig.setEvictionActionPolicyClassName(DefaultEvictionActionPolicy.class.getName());
+ }
+
+ public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig, int wakeupInterval)
+ {
+ this(defaultEvictionRegionConfig);
+ this.wakeupInterval = wakeupInterval;
+ }
+
public boolean isValidConfig()
{
- return (defaultEvictionPolicyClass != null && defaultEvictionPolicyClass.length() > 0)
+ return (defaultEvictionRegionConfig != null && defaultEvictionRegionConfig.getEvictionActionPolicyClassName() != null && defaultEvictionRegionConfig.getEvictionAlgorithmConfig() != null)
|| (evictionRegionConfigs != null && evictionRegionConfigs.size() > 0);
}
+ public EvictionRegionConfig getDefaultEvictionRegionConfig()
+ {
+ return defaultEvictionRegionConfig;
+ }
+
+ public void setDefaultEvictionRegionConfig(EvictionRegionConfig defaultEvictionRegionConfig)
+ {
+ this.defaultEvictionRegionConfig = defaultEvictionRegionConfig;
+ this.defaultEvictionRegionConfig.setEventQueueSizeIfUnset(EVENT_QUEUE_SIZE_DEFAULT);
+ }
+
+ /**
+ * @deprecated use {@link #getDefaultEvictionRegionConfig()} instead.
+ */
+ @Deprecated
public String getDefaultEvictionPolicyClass()
{
- return defaultEvictionPolicyClass;
+ throw new ConfigurationException("Please use getDefaultEvictionRegionConfig() instead.");
}
+ /**
+ * @deprecated use {@link #setDefaultEvictionRegionConfig(EvictionRegionConfig)} instead.
+ */
+ @Deprecated
public void setDefaultEvictionPolicyClass(String defaultEvictionPolicyClass)
{
- testImmutability("defaultEvictionPolicyClass");
- this.defaultEvictionPolicyClass = defaultEvictionPolicyClass;
+ throw new ConfigurationException("Please use setDefaultEvictionRegionConfig() instead.");
}
/**
@@ -96,70 +141,33 @@
* @throws ConfigurationException if a
* {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class}
* has not been set or there is a problem instantiating the configuration.
+ * @deprecated the default region is now created when this instance is constructed. Use {@link #getDefaultEvictionRegionConfig()} instead.
*/
+ @Deprecated
public EvictionRegionConfig createDefaultEvictionRegionConfig()
{
- if (defaultEvictionPolicyClass != null)
- {
- try
- {
- Class<?> cpolicy = Class.forName(defaultEvictionPolicyClass);
- EvictionPolicy policy = (EvictionPolicy) cpolicy.newInstance();
- EvictionRegionConfig erc = new EvictionRegionConfig();
- EvictionPolicyConfig epc = policy.getEvictionConfigurationClass().newInstance();
- erc.setEvictionPolicyConfig(epc);
- erc.setRegionFqn(RegionManagerImpl.DEFAULT_REGION);
- return erc;
- }
- catch (Exception e)
- {
- log.error("Unable to create EvictionRegionConfig for default region", e);
- throw new ConfigurationException("Unable to create EvictionRegionConfig for default region", e);
- }
- }
- else
- {
- throw new ConfigurationException("Cannot create EvictionRegionConfig for default region; no defaultEvictionPolicyClass configured");
- }
+ return getDefaultEvictionRegionConfig();
}
public List<EvictionRegionConfig> getEvictionRegionConfigs()
{
- if (evictionRegionConfigs == null)
- {
- evictionRegionConfigs = new ArrayList<EvictionRegionConfig>(1);
- }
return evictionRegionConfigs;
}
- public int getDefaultEventQueueSize()
+ public void setEvictionRegionConfigs(List<EvictionRegionConfig> evictionRegionConfigs)
{
- return defaultEventQueueSize;
+ testImmutability("evictionRegionConfigs");
+ this.evictionRegionConfigs = evictionRegionConfigs;
}
- public void setDefaultEventQueueSize(int eventQueueSize)
+ public void addEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
{
- this.defaultEventQueueSize = eventQueueSize;
- }
-
- public void setEvictionRegionConfigs(List<EvictionRegionConfig> evictionRegionConfigs)
- {
testImmutability("evictionRegionConfigs");
-
- // Make sure region configs built by MC have the event queue size
- if (evictionRegionConfigs != null)
- {
- for (EvictionRegionConfig cfg : evictionRegionConfigs)
- {
- cfg.setDefaultEventQueueSize(getDefaultEventQueueSize());
- }
- }
- replaceChildConfigs(this.evictionRegionConfigs, evictionRegionConfigs);
- this.evictionRegionConfigs = evictionRegionConfigs;
+ evictionRegionConfigs.add(evictionRegionConfig);
}
/**
- * value expressed in millis
+ * @return the wake up interval of the eviction thread, in milliseconds.
*/
public long getWakeupInterval()
{
@@ -167,22 +175,35 @@
}
/**
- * value expressed in millis
+ * Set the wake up interval for the eviction thread. 0 or a negative number disables the eviction thread.
+ *
+ * @param wakeupInterval interval, in milliseconds.
*/
public void setWakeupInterval(long wakeupInterval)
{
- testImmutability("WakeupInterval");
+ testImmutability("wakeupInterval");
this.wakeupInterval = wakeupInterval;
- this.wakeupIntervalSeconds = (int) wakeupInterval / 1000;
}
/**
+ * Set the wake up interval for the eviction thread. 0 or a negative number disables the eviction thread.
+ *
+ * @param wakeupInterval interval
+ * @param timeUnit for the interval provided
+ */
+ public void setWakeupInterval(long wakeupInterval, TimeUnit timeUnit)
+ {
+ testImmutability("wakeupInterval");
+ this.wakeupInterval = timeUnit.toMillis(wakeupInterval);
+ }
+
+ /**
* @deprecated Use {@link #getWakeupIntervalSeconds()}.
*/
@Deprecated
public int getWakeupIntervalSeconds()
{
- return wakeupIntervalSeconds;
+ return (int) TimeUnit.MILLISECONDS.toSeconds(wakeupInterval);
}
/**
@@ -191,9 +212,7 @@
@Deprecated
public void setWakeupIntervalSeconds(int wakeupIntervalSeconds)
{
- testImmutability("wakeupIntervalSeconds");
- this.wakeupIntervalSeconds = wakeupIntervalSeconds;
- this.wakeupInterval = wakeupIntervalSeconds * 1000;
+ setWakeupInterval(wakeupIntervalSeconds, TimeUnit.SECONDS);
}
public boolean equals(Object o)
@@ -205,9 +224,6 @@
if (defaultEventQueueSize != that.defaultEventQueueSize) return false;
if (wakeupInterval != that.wakeupInterval) return false;
- if (wakeupIntervalSeconds != that.wakeupIntervalSeconds) return false;
- if (defaultEvictionPolicyClass != null ? !defaultEvictionPolicyClass.equals(that.defaultEvictionPolicyClass) : that.defaultEvictionPolicyClass != null)
- return false;
if (evictionRegionConfigs != null ? !evictionRegionConfigs.equals(that.evictionRegionConfigs) : that.evictionRegionConfigs != null)
return false;
@@ -217,9 +233,7 @@
public int hashCode()
{
int result;
- result = (defaultEvictionPolicyClass != null ? defaultEvictionPolicyClass.hashCode() : 0);
- result = 31 * result + wakeupIntervalSeconds;
- result = 31 * result + (int) (wakeupInterval ^ (wakeupInterval >>> 32));
+ result = 31 + (int) (wakeupInterval ^ (wakeupInterval >>> 32));
result = 31 * result + defaultEventQueueSize;
result = 31 * result + (evictionRegionConfigs != null ? evictionRegionConfigs.hashCode() : 0);
return result;
@@ -231,12 +245,8 @@
EvictionConfig clone = (EvictionConfig) super.clone();
if (evictionRegionConfigs != null)
{
- List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>(evictionRegionConfigs.size());
- for (EvictionRegionConfig erc : evictionRegionConfigs)
- {
- ercs.add(erc.clone());
- }
- clone.setEvictionRegionConfigs(ercs);
+ // needs to be a deep copy
+ for (EvictionRegionConfig erc : evictionRegionConfigs) clone.addEvictionRegionConfig(erc.clone());
}
return clone;
}
@@ -258,4 +268,24 @@
}
return null;
}
+
+ /**
+ * Applies defaults to a config passed in
+ *
+ * @param config config to apply defaults to
+ */
+ public void applyDefaults(EvictionRegionConfig config)
+ {
+ if (config == null) return; // no op
+ config.setDefaults(defaultEvictionRegionConfig);
+ }
+
+ /**
+ * @deprecated set these attributes on the default eviction region config.
+ */
+ @Deprecated
+ public void setDefaultEventQueueSize(int queueSize)
+ {
+ defaultEvictionRegionConfig.setEventQueueSize(queueSize);
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyConfig.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -17,7 +17,9 @@
* to provide access to more config variables.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @deprecated see {@link org.jboss.cache.config.EvictionAlgorithmConfig}
*/
+@Deprecated
public interface EvictionPolicyConfig
{
/**
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -22,7 +22,9 @@
package org.jboss.cache.config;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.Modernizable;
import org.jboss.cache.util.Util;
import java.lang.reflect.Method;
@@ -40,38 +42,88 @@
private Fqn regionFqn;
@Dynamic
private Integer eventQueueSize;
- private EvictionPolicyConfig evictionPolicyConfig;
+ private EvictionAlgorithmConfig evictionAlgorithmConfig;
+ @Deprecated
+ private EvictionPolicyConfig deprecatedConfig;
+ private String evictionActionPolicyClassName;
public EvictionRegionConfig()
{
}
+ /**
+ * @deprecated use {@link #EvictionRegionConfig(org.jboss.cache.Fqn, EvictionAlgorithmConfig)} instead.
+ */
+ @Deprecated
+ @SuppressWarnings("deprecation")
public EvictionRegionConfig(Fqn regionFqn, EvictionPolicyConfig evictionPolicyConfig)
{
this.regionFqn = regionFqn;
- this.evictionPolicyConfig = evictionPolicyConfig;
+ if (evictionPolicyConfig instanceof Modernizable)
+ {
+ this.evictionAlgorithmConfig = ((Modernizable) evictionPolicyConfig).modernize();
+ deprecatedConfig = evictionPolicyConfig;
+ }
+ else
+ {
+ throw new ConfigurationException("Unable to convert " + evictionPolicyConfig.getClass().getName() +
+ " to a more modern format, implementing " + EvictionAlgorithmConfig.class.getSimpleName() + ". Please use " +
+ EvictionAlgorithmConfig.class.getSimpleName() + " which replaces the deprecated " + EvictionPolicyConfig.class.getSimpleName());
+ }
}
+ public EvictionRegionConfig(Fqn regionFqn, EvictionAlgorithmConfig evictionAlgorithmConfig)
+ {
+ this.regionFqn = regionFqn;
+ this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+ }
+
+ public EvictionRegionConfig(Fqn fqn)
+ {
+ this.regionFqn = fqn;
+ }
+
+ /**
+ * @deprecated use {@link #getEvictionAlgorithmConfig()} instead.
+ */
+ @Deprecated
public EvictionPolicyConfig getEvictionPolicyConfig()
{
- return evictionPolicyConfig;
+ if (deprecatedConfig != null)
+ return deprecatedConfig;
+ else
+ throw new CacheException("Not supported. Please use " + EvictionAlgorithmConfig.class.getSimpleName() +
+ " instead of " + EvictionPolicyConfig.class.getSimpleName());
}
- public void setEvictionPolicyConfig(EvictionPolicyConfig config)
+ public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
{
- testImmutability("evictionPolicyConfig");
- if (this.evictionPolicyConfig instanceof ConfigurationComponent)
+ return evictionAlgorithmConfig;
+ }
+
+ /**
+ * @deprecated see {@link #setEvictionAlgorithmConfig(EvictionAlgorithmConfig)}
+ */
+ @Deprecated
+ public void setEvictionPolicyConfig(EvictionPolicyConfig evictionPolicyConfig)
+ {
+ if (evictionPolicyConfig instanceof Modernizable)
{
- removeChildConfig((ConfigurationComponent) this.evictionPolicyConfig);
+ deprecatedConfig = evictionPolicyConfig;
+ setEvictionAlgorithmConfig(((Modernizable) evictionPolicyConfig).modernize());
}
- if (config instanceof ConfigurationComponent)
+ else
{
- addChildConfig((ConfigurationComponent) config);
+ throw new ConfigurationException("Unable to convert " + evictionPolicyConfig.getClass().getName() +
+ " to a more modern format, implementing " + EvictionAlgorithmConfig.class.getSimpleName() + ". Please use " +
+ EvictionAlgorithmConfig.class.getSimpleName() + " which replaces the deprecated " + EvictionPolicyConfig.class.getSimpleName());
}
+ }
- // don't validate here - instead validate when we start things up. See RegionManager.start()
-
- this.evictionPolicyConfig = config;
+ public void setEvictionAlgorithmConfig(EvictionAlgorithmConfig config)
+ {
+ testImmutability("evictionAlgorithmConfig");
+ this.evictionAlgorithmConfig = config;
}
public Fqn getRegionFqn()
@@ -113,13 +165,15 @@
this.eventQueueSize = queueSize;
}
- public void setDefaultEventQueueSize(int queueSize)
+ public void setDefaults(EvictionRegionConfig defaults)
{
- if (eventQueueSize == null)
- setEventQueueSize(queueSize);
+ // go thru each element that is unset here and copy from "defaults"
+ if (eventQueueSize == null) eventQueueSize = defaults.getEventQueueSize();
+ if (evictionAlgorithmConfig == null) evictionAlgorithmConfig = defaults.getEvictionAlgorithmConfig();
+ if (evictionActionPolicyClassName == null)
+ evictionActionPolicyClassName = defaults.getEvictionActionPolicyClassName();
}
-
@Override
public boolean equals(Object obj)
{
@@ -130,9 +184,9 @@
{
EvictionRegionConfig other = (EvictionRegionConfig) obj;
boolean equalRegions = Util.safeEquals(this.regionFqn, other.regionFqn);
- boolean equalConfigurations = Util.safeEquals(this.evictionPolicyConfig, other.evictionPolicyConfig);
+ boolean equalConfigurations = Util.safeEquals(this.evictionAlgorithmConfig, other.evictionAlgorithmConfig);
boolean equalEventQueuSizes = this.getEventQueueSize() == other.getEventQueueSize();
- return equalRegions && equalConfigurations && equalConfigurations;
+ return equalRegions && equalConfigurations && equalConfigurations && equalEventQueuSizes;
}
return false;
}
@@ -150,36 +204,84 @@
public EvictionRegionConfig clone() throws CloneNotSupportedException
{
EvictionRegionConfig clone = (EvictionRegionConfig) super.clone();
- if (evictionPolicyConfig != null)
+ if (evictionAlgorithmConfig != null)
{
- if (!(evictionPolicyConfig instanceof Cloneable))
+ if (!(evictionAlgorithmConfig instanceof Cloneable))
{
- throw new CloneNotSupportedException(evictionPolicyConfig + " is not Cloneable");
+ throw new CloneNotSupportedException(evictionAlgorithmConfig + " is not Cloneable");
}
- if (evictionPolicyConfig instanceof ConfigurationComponent)
+ if (evictionAlgorithmConfig instanceof ConfigurationComponent)
{
- clone.setEvictionPolicyConfig((EvictionPolicyConfig) ((ConfigurationComponent) evictionPolicyConfig).clone());
+ clone.setEvictionAlgorithmConfig((EvictionAlgorithmConfig) ((ConfigurationComponent) evictionAlgorithmConfig).clone());
}
else
{
try
{
- Method cloneMethod = evictionPolicyConfig.getClass().getDeclaredMethod("clone");
- EvictionPolicyConfig epc = (EvictionPolicyConfig) cloneMethod.invoke(evictionPolicyConfig);
- clone.setEvictionPolicyConfig(epc);
+ Method cloneMethod = this.evictionAlgorithmConfig.getClass().getDeclaredMethod("clone");
+ EvictionAlgorithmConfig evictionAlgorithmConfig = (EvictionAlgorithmConfig) cloneMethod.invoke(this.evictionAlgorithmConfig);
+ clone.setEvictionAlgorithmConfig(evictionAlgorithmConfig);
}
catch (Exception e)
{
- CloneNotSupportedException cnse = new CloneNotSupportedException("Cannot invoke clone() on " + evictionPolicyConfig);
+ CloneNotSupportedException cnse = new CloneNotSupportedException("Cannot invoke clone() on " + evictionAlgorithmConfig);
cnse.initCause(e);
throw cnse;
}
}
}
+ if (deprecatedConfig != null)
+ {
+ if (!(deprecatedConfig instanceof Cloneable))
+ {
+ throw new CloneNotSupportedException(deprecatedConfig + " is not Cloneable");
+ }
+
+ if (deprecatedConfig instanceof ConfigurationComponent)
+ {
+ clone.setEvictionAlgorithmConfig((EvictionAlgorithmConfig) ((ConfigurationComponent) deprecatedConfig).clone());
+ }
+ else
+ {
+ try
+ {
+ Method cloneMethod = this.deprecatedConfig.getClass().getDeclaredMethod("clone");
+ EvictionAlgorithmConfig evictionAlgorithmConfig = (EvictionAlgorithmConfig) cloneMethod.invoke(this.deprecatedConfig);
+ clone.setEvictionAlgorithmConfig(evictionAlgorithmConfig);
+ }
+ catch (Exception e)
+ {
+ CloneNotSupportedException cnse = new CloneNotSupportedException("Cannot invoke clone() on " + deprecatedConfig);
+ cnse.initCause(e);
+ throw cnse;
+ }
+ }
+ }
+
+ clone.evictionActionPolicyClassName = evictionActionPolicyClassName;
+
return clone;
}
+ public boolean isDefaultRegion()
+ {
+ return regionFqn.isRoot();
+ }
+ public String getEvictionActionPolicyClassName()
+ {
+ return evictionActionPolicyClassName == null ? EvictionConfig.EVICTION_ACTION_POLICY_CLASS_DEFAULT : evictionActionPolicyClassName;
+ }
+
+ public void setEvictionActionPolicyClassName(String evictionActionPolicyClassName)
+ {
+ this.evictionActionPolicyClassName = evictionActionPolicyClassName;
+ }
+
+ public void setEventQueueSizeIfUnset(int eventQueueSize)
+ {
+ if (this.eventQueueSize == null) this.eventQueueSize = eventQueueSize;
+ }
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -22,11 +22,17 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -472,7 +478,9 @@
Class paramTypes[] = m.getParameterTypes();
if (paramTypes.length != 1)
{
- throw new ConfigurationException("Setter " + setter + " does not contain the expected number of params. Has " + paramTypes.length + " instead of just 1.");
+ if (log.isTraceEnabled())
+ log.trace("Rejecting setter " + m + " on class " + objectClass + " due to incorrect number of parameters");
+ continue; // try another param with the same name.
}
Class parameterType = paramTypes[0];
@@ -499,7 +507,8 @@
}
}
}
- if (!setterFound && failOnMissingSetter) throw new ConfigurationException("Couldn't find a setter method for parameter " + propName);
+ if (!setterFound && failOnMissingSetter)
+ throw new ConfigurationException("Couldn't find a setter named [" + setter + "] which takes a single parameter, for parameter " + propName);
}
}
@@ -535,4 +544,22 @@
}
return new ParsedAttributes(stringAttribs, xmlAttribs);
}
+
+ public static String toString(Element e)
+ {
+ try
+ {
+ TransformerFactory tfactory = TransformerFactory.newInstance();
+ Transformer xform = tfactory.newTransformer();
+ Source src = new DOMSource(e);
+ java.io.StringWriter writer = new StringWriter();
+ Result result = new javax.xml.transform.stream.StreamResult(writer);
+ xform.transform(src, result);
+ return writer.toString();
+ }
+ catch (Exception ex)
+ {
+ return "Unable to convert to string: " + ex.toString();
+ }
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -19,10 +19,9 @@
import org.jboss.cache.config.EvictionPolicyConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.config.MissingPolicyException;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.util.FileLookup;
import org.jboss.cache.util.Util;
-import org.jboss.cache.util.FileLookup;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -383,7 +382,7 @@
eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
}
- ec.setDefaultEventQueueSize(eventQueueSize);
+ ec.getDefaultEvictionRegionConfig().setEventQueueSize(eventQueueSize);
NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
if (list != null && list.getLength() > 0)
@@ -474,7 +473,8 @@
policy.getEvictionConfigurationClass(), e);
}
- EvictionElementParser.parseEvictionPolicyConfig(element, epc);
+ // TODO FIX this!!!
+// EvictionElementParser.parseEvictionPolicyConfig(element, epc);
erc.setEvictionPolicyConfig(epc);
return erc;
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-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,16 +1,21 @@
package org.jboss.cache.config.parsing.element;
-import org.jboss.cache.RegionManagerImpl;
-import org.jboss.cache.config.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.MissingPolicyException;
import org.jboss.cache.config.parsing.ParsedAttributes;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.XmlParserBase;
-import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.eviction.EvictionAlgorithm;
import org.jboss.cache.util.Util;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -25,8 +30,11 @@
*/
public class EvictionElementParser extends XmlParserBase
{
+ private static final Log log = LogFactory.getLog(EvictionElementParser.class);
+
public EvictionConfig parseEvictionElement(Element evictionElement)
{
+ if (log.isTraceEnabled()) log.trace("Parsing eviction element " + XmlConfigHelper.toString(evictionElement));
EvictionConfig evictionConfig = new EvictionConfig();
String wakeUpInterval = getAttributeValue(evictionElement, "wakeUpInterval");
if (existsAttribute(wakeUpInterval))
@@ -35,37 +43,39 @@
}
else
{
- throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
+ throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
}
- String defaultPolicyClassStr = getAttributeValue(evictionElement, "defaultPolicyClass");
- if (existsAttribute(defaultPolicyClassStr)) evictionConfig.setDefaultEvictionPolicyClass(defaultPolicyClassStr);
- String defaultEventQueueSize = getAttributeValue(evictionElement, "defaultEventQueueSize");
- if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefaultEventQueueSize(getInt(defaultEventQueueSize));
+// String defaultPolicyClassStr = getAttributeValue(evictionElement, "defaultPolicyClass");
+// if (existsAttribute(defaultPolicyClassStr)) evictionConfig.setDefaultEvictionPolicyClass(defaultPolicyClassStr);
+// String defaultEventQueueSize = getAttributeValue(evictionElement, "defaultEventQueueSize");
+// if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefaultEventQueueSize(getInt(defaultEventQueueSize));
- List<EvictionRegionConfig> evictionRegionConfigs = new ArrayList<EvictionRegionConfig>(3);
- Element rootRegion = getSingleElement("default", evictionElement);
- String defaultPolicyClass = evictionConfig.getDefaultEvictionPolicyClass();
- int defaultEvQueueSize = evictionConfig.getDefaultEventQueueSize();
- if (rootRegion != null)
+ List<EvictionRegionConfig> evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+ Element defaultRegion = getSingleElement("default", evictionElement);
+
+ if (defaultRegion != null)
{
- EvictionRegionConfig erc = getEvictionRegionConfig(rootRegion, defaultPolicyClass, defaultEvQueueSize);
- erc.setRegionName(RegionManagerImpl.DEFAULT_REGION.toString());
- evictionRegionConfigs.add(erc);
+ EvictionRegionConfig defaultRegionConfig = getEvictionRegionConfig(defaultRegion, null, true);
+ if (defaultRegionConfig.getEvictionAlgorithmConfig() == null)
+ throw new ConfigurationException("Default eviction region should have an evictionAlgorithmClass defined.");
+ evictionConfig.setDefaultEvictionRegionConfig(defaultRegionConfig);
}
NodeList regions = evictionElement.getElementsByTagName("region");
for (int i = 0; i < regions.getLength(); i++)
{
Element regionConfig = (Element) regions.item(i);
- EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig, defaultPolicyClass, defaultEvQueueSize);
+ EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig, evictionConfig.getDefaultEvictionRegionConfig(), false);
+ evictionConfig.applyDefaults(erc);
evictionRegionConfigs.add(erc);
}
evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
return evictionConfig;
}
- private EvictionRegionConfig getEvictionRegionConfig(Element element, String defaultPolicyClass, int defaultEventQueueSize)
+ @SuppressWarnings("unchecked")
+ private EvictionRegionConfig getEvictionRegionConfig(Element element, EvictionRegionConfig defaultRegion, boolean isDefault)
{
EvictionRegionConfig erc = new EvictionRegionConfig();
erc.setRegionName(getAttributeValue(element, "name"));
@@ -74,53 +84,99 @@
{
erc.setEventQueueSize(getInt(queueSize));
}
- else
+ else if (defaultRegion == null)
{
- erc.setEventQueueSize(defaultEventQueueSize);
+ erc.setEventQueueSize(EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
}
- String policyClass = getAttributeValue(element, "policyClass");
- if (!existsAttribute(policyClass))
+
+ String algorithmClassName = getAttributeValue(element, "algorithmClass");
+ EvictionAlgorithmConfig eac = null; // every eviction region config needs an algorithm config.
+
+ if (existsAttribute(algorithmClassName))
{
- if (defaultPolicyClass == null)
+ EvictionAlgorithm algorithm;
+ Class<? extends EvictionAlgorithm> algorithmClass;
+ // try using a 'getInstance()' factory.
+
+ try
{
- throw new MissingPolicyException("There is no Eviction Policy Class specified on the region or for the entire cache!");
+ algorithmClass = Util.loadClass(algorithmClassName);
}
- else
+ catch (Exception e)
{
- policyClass = defaultPolicyClass;
+ throw new RuntimeException("Unable to load eviction algorithm class [" + algorithmClassName + "]", e);
}
+
+
+ try
+ {
+ algorithm = Util.getInstance(algorithmClass);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to construct eviction algorithm class [" + algorithmClassName + "]", e);
+ }
+
+ try
+ {
+ eac = Util.getInstance(algorithm.getConfigurationClass());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to instantiate eviction algorithm configuration class [" +
+ algorithm.getConfigurationClass() + "]", e);
+ }
}
- EvictionPolicy policy;
- try
+ else
{
- policy = (EvictionPolicy) Util.loadClass(policyClass).newInstance();
+ if (!isDefault)
+ {
+ if (defaultRegion == null || defaultRegion.getEvictionAlgorithmConfig() == null)
+ {
+ throw new MissingPolicyException("There is no Eviction Algorithm Class specified on the region or for the entire cache!");
+ }
+ else
+ {
+ try
+ {
+ eac = defaultRegion.getEvictionAlgorithmConfig().clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new ConfigurationException("Unable to clone eviction algorithm configuration from default", e);
+ }
+ }
+ }
}
- catch (Exception e)
+
+ if (eac != null)
{
- throw new RuntimeException("Eviction class is not properly loaded in classloader", e);
+ parseEvictionPolicyConfig(element, eac, defaultRegion != null);
+
+ erc.setEvictionAlgorithmConfig(eac);
}
- EvictionPolicyConfig epc;
- try
+ String actionPolicyClass = getAttributeValue(element, "actionPolicyClass");
+ if (existsAttribute(actionPolicyClass))
{
- epc = policy.getEvictionConfigurationClass().newInstance();
+ erc.setEvictionActionPolicyClassName(actionPolicyClass);
}
- catch (Exception e)
+ else if (defaultRegion == null)
{
- throw new RuntimeException("Failed to instantiate eviction configuration of class " +
- policy.getEvictionConfigurationClass(), e);
+ // this is the default region. Make sure we set the default EvictionActionPolicyClass.
+ erc.setEvictionActionPolicyClassName(EvictionConfig.EVICTION_ACTION_POLICY_CLASS_DEFAULT);
}
- parseEvictionPolicyConfig(element, epc);
- erc.setEvictionPolicyConfig(epc);
+
+
return erc;
}
- public static void parseEvictionPolicyConfig(Element element, EvictionPolicyConfig target)
+ public static void parseEvictionPolicyConfig(Element element, EvictionAlgorithmConfig target, boolean validate)
{
target.reset();
ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
XmlConfigHelper.setValues(target, attributes.stringAttribs, false, true);
XmlConfigHelper.setValues(target, attributes.xmlAttribs, true, true);
- target.validate();
+ if (validate) target.validate();
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,10 +8,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.eviction.EvictionEvent.Type;
import org.jboss.cache.lock.TimeoutException;
import java.util.concurrent.BlockingQueue;
@@ -32,33 +34,29 @@
{
private static final Log log = LogFactory.getLog(BaseEvictionAlgorithm.class);
private static final boolean trace = log.isTraceEnabled();
-
+ protected EvictionActionPolicy evictionActionPolicy;
+ protected EvictionAlgorithmConfig evictionAlgorithmConfig;
/**
- * Mapped region.
- */
- protected Region region;
-
- /**
* Contains Fqn instances.
*/
protected BlockingQueue<Fqn> recycleQueue;
-
/**
* Contains NodeEntry instances.
*/
protected EvictionQueue evictionQueue;
-
protected boolean allowTombstones = false;
+ protected Configuration configuration;
+ protected Fqn regionFqn;
+ protected CacheSPI<?, ?> cache;
/**
* This method will create an EvictionQueue implementation and prepare it for use.
*
- * @param region MarshRegion to setup an eviction queue for.
* @return The created EvictionQueue to be used as the eviction queue for this algorithm.
- * @throws EvictionException
+ * @throws EvictionException if there are problems
* @see EvictionQueue
*/
- protected abstract EvictionQueue setupEvictionQueue(Region region) throws EvictionException;
+ protected abstract EvictionQueue setupEvictionQueue() throws EvictionException;
/**
* This method will check whether the given node should be evicted or not.
@@ -73,52 +71,64 @@
recycleQueue = new LinkedBlockingQueue<Fqn>(500000);
}
- protected void initialize(Region region) throws EvictionException
+ public void initialize()
{
- if (region == null)
- throw new IllegalArgumentException("region");
- this.region = region;
- evictionQueue = setupEvictionQueue(region);
- log.debug("initialized: " + this);
- // hacky temp solution till we have an ioc fwk to inject configuration elements as needed
- Configuration c = region.getCacheConfiguration();
- Configuration.CacheMode cm = c != null ? c.getCacheMode() : Configuration.CacheMode.LOCAL;
- allowTombstones = c != null && c.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC &&
+ evictionQueue = setupEvictionQueue();
+ if (log.isDebugEnabled()) log.debug("Initialized: " + this);
+ Configuration.CacheMode cm = configuration != null ? configuration.getCacheMode() : Configuration.CacheMode.LOCAL;
+ allowTombstones = configuration != null && configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC &&
(cm == Configuration.CacheMode.INVALIDATION_ASYNC || cm == Configuration.CacheMode.INVALIDATION_SYNC);
+ }
+ public EvictionActionPolicy getEvictionActionPolicy()
+ {
+ return evictionActionPolicy;
}
+ public void setEvictionActionPolicy(EvictionActionPolicy evictionActionPolicy)
+ {
+ this.evictionActionPolicy = evictionActionPolicy;
+ }
+
+ public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
+ {
+ return evictionAlgorithmConfig;
+ }
+
+ public void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
+ {
+ this.regionFqn = fqn;
+ this.cache = cache;
+ this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+ this.configuration = configuration;
+ }
+
+ public boolean canIgnoreEvent(Type eventType)
+ {
+ return false; // don't ignore anything!
+ }
+
/**
- * Process the given region.
+ * Process the given eviction event queue. Eviction Processing encompasses the following:
* <p/>
- * Eviction Processing encompasses the following:
- * <p/>
* - Add/Remove/Visit Nodes
* - Prune according to Eviction Algorithm
* - Empty/Retry the recycle queue of previously evicted but locked (during actual cache eviction) nodes.
*
- * @param region Cache region to process for eviction.
+ * @param eventQueue queue containing eviction events
* @throws EvictionException
*/
- public void process(Region region) throws EvictionException
+ public void process(BlockingQueue<EvictionEvent> eventQueue) throws EvictionException
{
- if (this.region == null)
- {
- this.initialize(region);
- }
-
- if (trace)
- {
- log.trace("process(): region: " + region.getFqn());
- }
-
- this.processQueues(region);
+ if (trace) log.trace("process(): region: " + regionFqn);
+ this.processQueues(eventQueue);
this.emptyRecycleQueue();
this.prune();
}
- public void resetEvictionQueue(Region region)
+ public void resetEvictionQueue()
{
+ // a no-op
}
/**
@@ -132,6 +142,19 @@
return this.evictionQueue;
}
+ protected EvictionEvent getNextInQueue(BlockingQueue<EvictionEvent> queue)
+ {
+ try
+ {
+ return queue.poll(0, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ return null;
+ }
+
/**
* Event processing for Evict/Add/Visiting of nodes.
* <p/>
@@ -139,17 +162,15 @@
* - On RemoveEvents, the removed element is removed from the eviction queue.
* - On VisitEvents, the visited node has its eviction statistics updated (idleTime, numberOfNodeVisists, etc..)
*
- * @param region Cache region to process for eviction.
- * @throws EvictionException
+ * @param queue queue to inspect
+ * @throws EvictionException in the event of problems
*/
- protected void processQueues(Region region) throws EvictionException
+ protected void processQueues(BlockingQueue<EvictionEvent> queue) throws EvictionException
{
- EvictedEventNode node;
+ EvictionEvent node;
int count = 0;
- while ((node = region.takeLastEventNode()) != null)
+ while ((node = getNextInQueue(queue)) != null)
{
-// Fqn fqn = node.getFqn();
-
count++;
switch (node.getEventType())
{
@@ -179,11 +200,7 @@
}
}
- if (trace)
- {
- log.trace("processed " + count + " node events in region: " + region.getFqn());
- }
-
+ if (trace) log.trace("processed " + count + " node events");
}
protected void evict(NodeEntry ne)
@@ -221,15 +238,11 @@
*/
protected boolean evictCacheNode(Fqn fqn)
{
- if (trace)
- {
- log.trace("Attempting to evict cache node with fqn of " + fqn);
- }
+ if (trace) log.trace("Attempting to evict cache node with fqn of " + fqn);
- EvictionPolicy policy = region.getEvictionPolicy();
try
{
- policy.evict(fqn);
+ evictionActionPolicy.evict(fqn);
}
catch (TimeoutException e)
{
@@ -280,18 +293,18 @@
}
/**
- * Convenience method, which calls {@link #processAddedNodes(EvictedEventNode, int, boolean)} using values in the
+ * Convenience method, which calls {@link #processAddedNodes(EvictionEvent, int)} using values in the
* evictedEventNode for number of added elements and the resetElementCount flag.
*
* @param evictedEventNode an evictedEventNode to process
* @throws EvictionException on problems
*/
- protected void processAddedNodes(EvictedEventNode evictedEventNode) throws EvictionException
+ protected void processAddedNodes(EvictionEvent evictedEventNode) throws EvictionException
{
processAddedNodes(evictedEventNode, evictedEventNode.getElementDifference());
}
- protected void processAddedNodes(EvictedEventNode evictedEventNode, int numAddedElements) throws EvictionException
+ protected void processAddedNodes(EvictionEvent evictedEventNode, int numAddedElements) throws EvictionException
{
Fqn fqn = evictedEventNode.getFqn();
@@ -342,7 +355,7 @@
*
* @throws EvictionException
*/
- protected void processRemovedNodes(EvictedEventNode evictedEventNode) throws EvictionException
+ protected void processRemovedNodes(EvictionEvent evictedEventNode) throws EvictionException
{
Fqn fqn = evictedEventNode.getFqn();
@@ -394,7 +407,7 @@
*
* @throws EvictionException
*/
- protected void processVisitedNodes(EvictedEventNode evictedEventNode) throws EvictionException
+ protected void processVisitedNodes(EvictionEvent evictedEventNode) throws EvictionException
{
Fqn fqn = evictedEventNode.getFqn();
NodeEntry ne = evictionQueue.getNodeEntry(fqn);
@@ -414,7 +427,7 @@
ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
}
- protected void processRemovedElement(EvictedEventNode evictedEventNode) throws EvictionException
+ protected void processRemovedElement(EvictionEvent evictedEventNode) throws EvictionException
{
Fqn fqn = evictedEventNode.getFqn();
NodeEntry ne = evictionQueue.getNodeEntry(fqn);
@@ -435,7 +448,7 @@
ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
}
- protected void processAddedElement(EvictedEventNode evictedEventNode) throws EvictionException
+ protected void processAddedElement(EvictionEvent evictedEventNode) throws EvictionException
{
Fqn fqn = evictedEventNode.getFqn();
NodeEntry ne = evictionQueue.getNodeEntry(fqn);
@@ -552,7 +565,6 @@
public String toString()
{
return super.toString() +
- " reqion=" + region.getFqn() +
" recycle=" + recycleQueue.size() +
" evict=" + evictionQueue.getNumberOfNodes();
}
@@ -565,9 +577,9 @@
*/
protected boolean isYoungerThanMinimumTimeToLive(NodeEntry entry)
{
- if (region.getEvictionPolicyConfig() instanceof EvictionPolicyConfigBase)
+ if (evictionAlgorithmConfig instanceof EvictionAlgorithmConfigBase)
{
- EvictionPolicyConfigBase cfg = (EvictionPolicyConfigBase) region.getEvictionPolicyConfig();
+ EvictionAlgorithmConfigBase cfg = (EvictionAlgorithmConfigBase) evictionAlgorithmConfig;
long minTTL = cfg.getMinTimeToLive();
return minTTL >= 1 && (entry.getModifiedTimeStamp() + minTTL > System.currentTimeMillis());
}
@@ -577,5 +589,4 @@
return false;
}
}
-
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -9,7 +9,9 @@
* @author Ben Wang 2-2004
* @author Daniel Huang - dhuang(a)jboss.org
* @version $Revision$
+ * @deprecated see {@link org.jboss.cache.eviction.EvictionActionPolicy}
*/
+@Deprecated
public abstract class BaseEvictionPolicy implements EvictionPolicy
{
protected CacheSPI cache_;
@@ -42,7 +44,7 @@
* @see org.jboss.cache.eviction.EvictionPolicy#canIgnoreEvent(org.jboss.cache.Fqn)
*
*/
- public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
+ public boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType)
{
return false;
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvictionAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvictionAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,9 +8,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Region;
+import java.util.concurrent.BlockingQueue;
+
/**
* An abstract SortedEvictionAlgorithm.
* <p/>
@@ -28,19 +29,13 @@
private static final boolean trace = log.isTraceEnabled();
@Override
- public void process(Region region) throws EvictionException
+ protected void processQueues(BlockingQueue<EvictionEvent> queue) throws EvictionException
{
- super.process(region);
- }
-
- @Override
- protected void processQueues(Region region) throws EvictionException
- {
boolean evictionNodesModified = false;
- EvictedEventNode node;
+ EvictionEvent node;
int count = 0;
- while ((node = region.takeLastEventNode()) != null)
+ while ((node = getNextInQueue(queue)) != null)
{
count++;
switch (node.getEventType())
Added: core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionActionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionActionPolicy.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionActionPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,37 @@
+package org.jboss.cache.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+
+/**
+ * Default eviction action policy that calls {@link org.jboss.cache.Cache#evict(org.jboss.cache.Fqn)} to evict a node.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class DefaultEvictionActionPolicy implements EvictionActionPolicy
+{
+ Cache<?, ?> cache;
+ private static final Log log = LogFactory.getLog(DefaultEvictionActionPolicy.class);
+
+ public void setCache(Cache<?, ?> cache)
+ {
+ this.cache = cache;
+ }
+
+ public boolean evict(Fqn fqn)
+ {
+ try
+ {
+ cache.evict(fqn);
+ return true;
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e);
+ return false;
+ }
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,9 +6,8 @@
*/
package org.jboss.cache.eviction;
-import org.jboss.cache.Region;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
-
/**
* @author Daniel Huang
* @version $Revision$
@@ -16,7 +15,7 @@
public class ElementSizeAlgorithm extends BaseSortedEvictionAlgorithm
{
@Override
- protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ protected EvictionQueue setupEvictionQueue() throws EvictionException
{
return new ElementSizeQueue();
}
@@ -27,10 +26,8 @@
// check the minimum time to live and see if we should not evict the node. This check will
// ensure that, if configured, nodes are kept alive for at least a minimum period of time.
if (isYoungerThanMinimumTimeToLive(ne)) return false;
-
- ElementSizeConfiguration config = (ElementSizeConfiguration) region.getEvictionPolicyConfig();
-
int size = this.getEvictionQueue().getNumberOfNodes();
+ ElementSizeAlgorithmConfig config = (ElementSizeAlgorithmConfig) evictionAlgorithmConfig;
return config.getMaxNodes() != 0 && size > config.getMaxNodes() || ne.getNumberOfElements() > config.getMaxElementsPerNode();
}
@@ -43,4 +40,8 @@
((ElementSizeQueue) this.evictionQueue).prune();
}
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return ElementSizeAlgorithmConfig.class;
+ }
}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfiguration.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.Dynamic;
+
+/**
+ * Configuration for {@link ElementSizeAlgorithm}.
+ * <p/>
+ * Requires a positive "maxElementsPerNode" value otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class ElementSizeAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = 2510593544656833758L;
+
+ @Dynamic
+ private int maxElementsPerNode;
+
+ public ElementSizeAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = ElementSizeAlgorithm.class.getName();
+ // Force configuration of maxElementsPerNode
+ setMaxElementsPerNode(-1);
+ }
+
+ public ElementSizeAlgorithmConfig(int maxNodes, int maxElementsPerNode)
+ {
+ this();
+ setMaxNodes(maxNodes);
+ setMaxElementsPerNode(maxElementsPerNode);
+ }
+
+ public int getMaxElementsPerNode()
+ {
+ return maxElementsPerNode;
+ }
+
+ public void setMaxElementsPerNode(int maxElementsPerNode)
+ {
+ testImmutability("maxElementsPerNode");
+ this.maxElementsPerNode = maxElementsPerNode;
+ }
+
+ /**
+ * Requires a positive maxElementsPerNode value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ if (maxElementsPerNode < 0)
+ {
+ throw new ConfigurationException("maxElementsPerNode must be must be " +
+ "configured to a value greater than or equal to 0");
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder str = new StringBuilder();
+ str.append("ElementSizeConfiguration: maxElementsPerNode =");
+ str.append(getMaxElementsPerNode()).append(" maxNodes =").append(getMaxNodes());
+ return str.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj instanceof ElementSizeAlgorithmConfig && super.equals(obj))
+ {
+ return this.maxElementsPerNode == ((ElementSizeAlgorithmConfig) obj).maxElementsPerNode;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + maxElementsPerNode;
+ return result;
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ setMaxElementsPerNode(-1);
+ }
+
+ @Override
+ public ElementSizeAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (ElementSizeAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfiguration.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfiguration.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,7 +8,10 @@
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.Dynamic;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import java.util.concurrent.TimeUnit;
+
/**
* Configuration for {@link ElementSizePolicy}.
* <p/>
@@ -26,7 +29,9 @@
* @author Daniel Huang
* @author Brian Stansberry
* @version $Revision$
+ * @deprecated see {@link org.jboss.cache.eviction.ElementSizeAlgorithmConfig}
*/
+@Deprecated
public class ElementSizeConfiguration extends EvictionPolicyConfigBase
{
/**
@@ -50,6 +55,16 @@
setEvictionPolicyClass(ElementSizePolicy.class.getName());
}
+ @Override
+ public EvictionAlgorithmConfig modernize()
+ {
+ ElementSizeAlgorithmConfig modernCfg = new ElementSizeAlgorithmConfig();
+ modernCfg.setMaxElementsPerNode(getMaxElementsPerNode());
+ modernCfg.setMaxNodes(getMaxNodes());
+ modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECONDS);
+ return modernCfg;
+ }
+
public int getMaxElementsPerNode()
{
return maxElementsPerNode;
@@ -116,6 +131,4 @@
{
return (ElementSizeConfiguration) super.clone();
}
-
-
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -9,7 +9,9 @@
/**
* @author Daniel Huang
* @version $Revison: $
+ * @deprecated see ElementSizeAlgorithm
*/
+@Deprecated
public class ElementSizePolicy extends BaseEvictionPolicy
{
private ElementSizeAlgorithm algorithm;
Deleted: core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,102 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.eviction;
-
-import org.jboss.cache.Fqn;
-
-/**
- * Value object used in evicted event node queue.
- *
- * @author Ben Wang 2-2004
- * @author Daniel Huang (dhuang(a)jboss.org)
- * @see org.jboss.cache.Region
- */
-public class EvictedEventNode
-{
- private Fqn fqn;
- private NodeEventType type;
- private int elementDifference;
-
- private long inUseTimeout;
- private long creationTimestamp;
-
- public EvictedEventNode(Fqn fqn, NodeEventType type, int elementDifference)
- {
- this(fqn, type);
- setElementDifference(elementDifference);
- }
-
- public EvictedEventNode(Fqn fqn, NodeEventType event)
- {
- setFqn(fqn);
- setEventType(event);
- creationTimestamp = System.currentTimeMillis();
- }
-
- public long getCreationTimestamp()
- {
- return creationTimestamp;
- }
-
- public long getInUseTimeout()
- {
- return inUseTimeout;
- }
-
- public void setInUseTimeout(long inUseTimeout)
- {
- this.inUseTimeout = inUseTimeout;
- }
-
- public int getElementDifference()
- {
- return elementDifference;
- }
-
- public void setElementDifference(int elementDifference_)
- {
- this.elementDifference = elementDifference_;
- }
-
- public Fqn getFqn()
- {
- return fqn;
- }
-
- public void setFqn(Fqn fqn)
- {
- this.fqn = fqn;
- }
-
- public void setEventType(NodeEventType event)
- {
- type = event;
- }
-
- public NodeEventType getEventType()
- {
- return type;
- }
-
- @Override
- public String toString()
- {
- return "EvictedEventNode[fqn=" + fqn + " event=" + type + " diff=" + elementDifference + "]";
- }
-
- /**
- * Copies this evicted event node to create a new one with the same values, except with a new Fqn root.
- *
- * @param newRoot new Fqn root to use
- * @return a new EvictedEventNode instance
- * @see org.jboss.cache.Region#copy(org.jboss.cache.Fqn)
- */
- public EvictedEventNode copy(Fqn newRoot)
- {
- return new EvictedEventNode(Fqn.fromRelativeFqn(newRoot, fqn), type, elementDifference);
- }
-}
Added: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPolicy.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,28 @@
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+
+/**
+ * Performs an eviction on a given Fqn.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface EvictionActionPolicy
+{
+ /**
+ * Sets a reference to the cache.
+ *
+ * @param cache cache
+ */
+ void setCache(Cache<?, ?> cache);
+
+ /**
+ * Performs an eviction on a given node.
+ *
+ * @param fqn fqn to evict
+ * @return true if the eviction was successful, false if not.
+ */
+ boolean evict(Fqn fqn);
+}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,7 +1,13 @@
package org.jboss.cache.eviction;
-import org.jboss.cache.Region;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.eviction.EvictionEvent.Type;
+import java.util.concurrent.BlockingQueue;
+
/**
* Interface for all eviction algorithms.
* <p/>
@@ -15,19 +21,17 @@
public interface EvictionAlgorithm
{
/**
- * Entry point for evictin algorithm. This is an api called by the EvictionTimerTask
- * to process the node events in waiting and actual pruning, if necessary.
+ * Entry point for eviction algorithm. Invoking this will cause the algorithm to process the queue of {@link org.jboss.cache.eviction.EvictionEvent}
+ * passed in.
*
- * @param region MarshRegion that this algorithm will operate on.
+ * @param queue to process
*/
- void process(Region region) throws EvictionException;
+ void process(BlockingQueue<EvictionEvent> queue) throws EvictionException;
/**
- * Reset the whole eviction queue. Queue may needs to be reset due to corrupted state, for example.
- *
- * @param region MarshRegion that this algorithm will operate on.
+ * Reset the whole eviction queue. The queue may need to be reset due to corrupted state, for example.
*/
- void resetEvictionQueue(Region region);
+ void resetEvictionQueue();
/**
* Get the EvictionQueue implementation used by this algorithm.
@@ -36,4 +40,41 @@
*/
EvictionQueue getEvictionQueue();
+ /**
+ * Sets the eviction action policy, so the algorithm knows what to do when a node is to be evicted.
+ *
+ * @param evictionActionPolicy to set
+ */
+ void setEvictionActionPolicy(EvictionActionPolicy evictionActionPolicy);
+
+ /**
+ * Assigns the algorithm instance to a specific region.
+ *
+ * @param fqn of the region to be assigned to
+ * @param cache cache reference
+ * @param evictionAlgorithmConfig configuration for the current algorithm instance.
+ * @param configuration for the entire cache.
+ */
+ void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration);
+
+ /**
+ * Tests whether the algorithm would ignore certain event types on certain Fqns.
+ *
+ * @param eventType event type to test for
+ * @return true if the event representing the parameters would be ignored by this algorithm or not.
+ */
+ boolean canIgnoreEvent(Type eventType);
+
+ /**
+ * Invoked by the region manager when the enclosing region is initialized.
+ */
+ void initialize();
+
+ /**
+ * This is a helper so that the XML parser will be able to select and use the correct {@link org.jboss.cache.config.EvictionAlgorithmConfig} implementation
+ * class corresponding to this EvictionAlgorithm. E.g., the {@link FIFOAlgorithm} would return {@link org.jboss.cache.eviction.FIFOAlgorithmConfig}.class.
+ *
+ * @return a class that is used to configure this EvictionAlgorithm.
+ */
+ Class<? extends EvictionAlgorithmConfig> getConfigurationClass();
}
Added: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,113 @@
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.ConfigurationComponent;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.Dynamic;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A base class used for configuring eviction algorithms.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public abstract class EvictionAlgorithmConfigBase extends ConfigurationComponent implements EvictionAlgorithmConfig
+{
+ private static final long serialVersionUID = 4591691674370188932L;
+
+ protected String evictionAlgorithmClassName;
+ @Dynamic
+ protected int maxNodes = 0;
+ @Dynamic
+ protected long minTimeToLive;
+
+ /**
+ * Can only be instantiated by a subclass.
+ */
+ protected EvictionAlgorithmConfigBase()
+ {
+ }
+
+ public String getEvictionAlgorithmClassName()
+ {
+ return evictionAlgorithmClassName;
+ }
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ testImmutability("maxNodes");
+ this.maxNodes = maxNodes;
+ }
+
+ /**
+ * @return The minimum time to live, in milliseconds.
+ */
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ /**
+ * @param minTimeToLive time to live, in milliseconds
+ */
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ testImmutability("minTimeToLive");
+ this.minTimeToLive = minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long time, TimeUnit timeUnit)
+ {
+ testImmutability("minTimeToLive");
+ minTimeToLive = timeUnit.toMillis(time);
+ }
+
+ public void validate() throws ConfigurationException
+ {
+ // no-op
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof EvictionAlgorithmConfigBase)) return false;
+
+ EvictionAlgorithmConfigBase that = (EvictionAlgorithmConfigBase) o;
+
+ if (maxNodes != that.maxNodes) return false;
+ if (minTimeToLive != that.minTimeToLive) return false;
+ if (evictionAlgorithmClassName != null ? !evictionAlgorithmClassName.equals(that.evictionAlgorithmClassName) : that.evictionAlgorithmClassName != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (evictionAlgorithmClassName != null ? evictionAlgorithmClassName.hashCode() : 0);
+ result = 31 * result + maxNodes;
+ result = (int) (31 * result + minTimeToLive);
+ result = 31 * result + (int) (minTimeToLive ^ (minTimeToLive >>> 32));
+ return result;
+ }
+
+ public void reset()
+ {
+ evictionAlgorithmClassName = null;
+ maxNodes = 0;
+ minTimeToLive = 0;
+ }
+
+ public EvictionAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (EvictionAlgorithmConfig) super.clone();
+ }
+}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java (from rev 6553, core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.Fqn;
+
+/**
+ * An eviction event records activity on nodes in the cache. These are recorded on a {@link org.jboss.cache.Region} for processing
+ * later by calls to {@link org.jboss.cache.Region#processEvictionQueues()}.
+ * <p/>
+ *
+ * @see org.jboss.cache.Region
+ */
+public class EvictionEvent
+{
+ private Fqn fqn;
+ private Type type;
+ private int elementDifference;
+
+ private long inUseTimeout;
+ private long creationTimestamp;
+
+ public static enum Type
+ {
+ ADD_NODE_EVENT,
+ REMOVE_NODE_EVENT,
+ VISIT_NODE_EVENT,
+ ADD_ELEMENT_EVENT,
+ REMOVE_ELEMENT_EVENT,
+ MARK_IN_USE_EVENT,
+ UNMARK_USE_EVENT
+ }
+
+ public EvictionEvent(Fqn fqn, Type type, int elementDifference)
+ {
+ this.fqn = fqn;
+ this.type = type;
+ this.elementDifference = elementDifference;
+ this.creationTimestamp = System.currentTimeMillis();
+ }
+
+ public long getCreationTimestamp()
+ {
+ return creationTimestamp;
+ }
+
+ public long getInUseTimeout()
+ {
+ return inUseTimeout;
+ }
+
+ public void setInUseTimeout(long inUseTimeout)
+ {
+ this.inUseTimeout = inUseTimeout;
+ }
+
+ public int getElementDifference()
+ {
+ return elementDifference;
+ }
+
+ public void setElementDifference(int elementDifference)
+ {
+ this.elementDifference = elementDifference;
+ }
+
+ public Fqn getFqn()
+ {
+ return fqn;
+ }
+
+ public void setFqn(Fqn fqn)
+ {
+ this.fqn = fqn;
+ }
+
+ public void setEventType(Type event)
+ {
+ type = event;
+ }
+
+ public Type getEventType()
+ {
+ return type;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "EvictedEventNode[fqn=" + fqn + " event=" + type + " diff=" + elementDifference + "]";
+ }
+
+ /**
+ * Copies this evicted event node to create a new one with the same values, except with a new Fqn root.
+ *
+ * @param newRoot new Fqn root to use
+ * @return a new EvictedEventNode instance
+ * @see org.jboss.cache.Region#copy(org.jboss.cache.Fqn)
+ */
+ public EvictionEvent copy(Fqn newRoot)
+ {
+ return new EvictionEvent(Fqn.fromRelativeFqn(newRoot, fqn), type, elementDifference);
+ }
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,16 @@
+package org.jboss.cache.eviction;
+
+/**
+ * @deprecated left here for old interfaces. Use {@link org.jboss.cache.eviction.EvictionEvent.Type} instead.
+ */
+@Deprecated
+public enum EvictionEventType
+{
+ @Deprecated ADD_NODE_EVENT,
+ @Deprecated REMOVE_NODE_EVENT,
+ @Deprecated VISIT_NODE_EVENT,
+ @Deprecated ADD_ELEMENT_EVENT,
+ @Deprecated REMOVE_ELEMENT_EVENT,
+ @Deprecated MARK_IN_USE_EVENT,
+ @Deprecated UNMARK_USE_EVENT
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionException.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionException.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionException.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,11 +1,13 @@
package org.jboss.cache.eviction;
+import org.jboss.cache.CacheException;
+
/**
* @author Ben Wang, Feb 11, 2004
*/
-public class EvictionException extends Exception
+public class EvictionException extends CacheException
{
-
+
private static final long serialVersionUID = 4006783737166646935L;
public EvictionException()
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -18,7 +18,9 @@
*
* @author Ben Wang 2-2004
* @author Daniel Huang - dhuang(a)jboss.org - 10/2005
+ * @deprecated please use {@link EvictionActionPolicy} instead.
*/
+@Deprecated
public interface EvictionPolicy
{
/**
@@ -64,7 +66,7 @@
* This method provides a way to optimize the performance of eviction by
* signalling that the node associated with the specified Fqn should not be
* subject to normal eviction processing. It can also be used to filter
- * out certain {@link NodeEventType event types} in which the particular
+ * out certain {@link EvictionEventType event types} in which the particular
* eviction algorithm has no interest.
* </p>
* <p/>
@@ -84,5 +86,5 @@
* @return <code>true</code> to ignore events of this type for this Fqn,
* <code>false</code> to process events normally.
*/
- boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType);
+ boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType);
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -3,18 +3,20 @@
import org.jboss.cache.config.ConfigurationComponent;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.Dynamic;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.util.Util;
/**
* Base implementation of {@link EvictionPolicyConfig}. Adds properties
* for the most commonly used config elements.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @deprecated See {@link org.jboss.cache.eviction.EvictionAlgorithmConfigBase}.
*/
+@Deprecated
public abstract class EvictionPolicyConfigBase
extends ConfigurationComponent
- implements EvictionPolicyConfig
+ implements EvictionPolicyConfig, Modernizable
{
/**
* The serialVersionUID
@@ -25,15 +27,9 @@
@Dynamic
private int maxNodes = 0;
- @Deprecated
@Dynamic
private int minTimeToLiveSeconds = 0;
-
- /** value expressed in millis */
- @Dynamic
- private long minTimeToLive;
-
/**
* Can only be instantiated by a subclass.
* <p/>
@@ -66,36 +62,14 @@
this.maxNodes = maxNodes;
}
- /** value expressed in millis */
- public long getMinTimeToLive()
- {
- return minTimeToLive;
- }
-
- /** value expressed in millis */
- public void setMinTimeToLive(long minTimeToLive)
- {
- this.minTimeToLive = minTimeToLive;
- this.minTimeToLiveSeconds = (int)(minTimeToLive / 1000);
- }
-
- /**
- * Use {@link #getMinTimeToLive()}
- */
- @Deprecated
public int getMinTimeToLiveSeconds()
{
return this.minTimeToLiveSeconds;
}
- /**
- * Use {@link #setMinTimeToLive(long)}
- */
- @Deprecated
public void setMinTimeToLiveSeconds(int minTimeToLiveSeconds)
{
this.minTimeToLiveSeconds = minTimeToLiveSeconds;
- minTimeToLive = minTimeToLiveSeconds * 1000;
}
public void validate() throws ConfigurationException
@@ -111,7 +85,7 @@
EvictionPolicyConfigBase that = (EvictionPolicyConfigBase) o;
if (maxNodes != that.maxNodes) return false;
- if (minTimeToLive != that.minTimeToLive) return false;
+ if (minTimeToLiveSeconds != that.minTimeToLiveSeconds) return false;
if (evictionPolicyClass != null ? !evictionPolicyClass.equals(that.evictionPolicyClass) : that.evictionPolicyClass != null)
return false;
@@ -124,7 +98,7 @@
result = (evictionPolicyClass != null ? evictionPolicyClass.hashCode() : 0);
result = 31 * result + maxNodes;
result = 31 * result + minTimeToLiveSeconds;
- result = 31 * result + (int) (minTimeToLive ^ (minTimeToLive >>> 32));
+ result = 31 * result + (minTimeToLiveSeconds ^ (minTimeToLiveSeconds >>> 3));
return result;
}
@@ -133,7 +107,7 @@
setEvictionPolicyClass(null);
setMaxNodes(0);
setMinTimeToLiveSeconds(0);
- setMinTimeToLive(0);
+ setMinTimeToLiveSeconds(0);
setEvictionPolicyClassName();
}
@@ -144,4 +118,16 @@
* called in {@link #reset()}.
*/
abstract protected void setEvictionPolicyClassName();
+
+ /**
+ * A factory method that returns a more modernized {@link org.jboss.cache.eviction.ExpirationAlgorithmConfig} instance
+ * corresponding to this deprecated configuration element. It is expected that subclasses of this abstract class
+ * implement this method as needed, copying elements across accordingly.
+ *
+ * @return a new ElementSizeAlgorithmConfig instance with values identical to this current deprecated config.
+ */
+ public EvictionAlgorithmConfig modernize()
+ {
+ throw new UnsupportedOperationException("Not supported in this implementation (" + getClass().getName() + ")");
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -133,13 +133,9 @@
{
synchronized (region)
{
- final EvictionPolicy policy = region.getEvictionPolicy();
- final EvictionAlgorithm algo = policy.getEvictionAlgorithm();
- if (algo == null)
- throw new NullPointerException("algorithm null");
try
{
- algo.process(region);
+ region.processEvictionQueues();
}
catch (EvictionException e)
{
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -4,11 +4,13 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.Region;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.eviction.EvictionEvent.Type;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.concurrent.BlockingQueue;
/**
* Eviction algorithm that uses a key in the Node data that indicates the time
@@ -18,19 +20,19 @@
* java.lang.System#currentTimeMillis()}).
* <p/>
* This algorithm also obeys the configuration key {@link
- * ExpirationConfiguration#getMaxNodes()}, and will evict the soonest to
+ * ExpirationAlgorithmConfig#getMaxNodes()}, and will evict the soonest to
* expire entires first to reduce the region size. If there are not enough
* nodes with expiration keys set, a warning is logged.
* <p/>
* If a node in the eviction region does not have an expiration value, then
- * {@link org.jboss.cache.eviction.ExpirationConfiguration#getTimeToLive()} (if set) will be used.
+ * {@link ExpirationAlgorithmConfig#getTimeToLive()} (if set) will be used.
* The expiration is updated when a node is added or updated.
* <p/>
* If there is no time-to-live set, and a node in the eviction region does not
* have an expiration value, then that node will never be evicted. As
* forgetting to indicate an expiration value is likely a mistake, a warning
* message is logged by this class. This warning, however, can be disabled
- * through {@link ExpirationConfiguration#setWarnNoExpirationKey(boolean)}.
+ * through {@link ExpirationAlgorithmConfig#setWarnNoExpirationKey(boolean)}.
* <p/>
* A node's expiration time can be changed by setting a new value in the node.
* <p/>
@@ -54,22 +56,19 @@
private static final Log log = LogFactory.getLog(ExpirationAlgorithm.class);
private static final boolean trace = log.isTraceEnabled();
- private ExpirationConfiguration config;
+ private ExpirationAlgorithmConfig config;
- private ExpirationPolicy policy;
-
private SortedSet<ExpirationEntry> set;
/**
* Constructs a new algorithm with a policy.
*/
- public ExpirationAlgorithm(ExpirationPolicy policy)
+ public ExpirationAlgorithm()
{
- this.policy = policy;
this.set = new TreeSet<ExpirationEntry>();
}
- private void addEvictionEntry(EvictedEventNode node)
+ private void addEvictionEntry(EvictionEvent node)
{
Fqn fqn = node.getFqn();
addEvictionEntry(fqn);
@@ -80,7 +79,7 @@
Long l = getExpiration(fqn);
if (l == null)
{
- if (config.getWarnNoExpirationKey())
+ if (config.isWarnNoExpirationKey() && log.isWarnEnabled())
log.warn("No expiration key '" + config.getExpirationKeyName() + "' for Node: " + fqn);
else if (log.isDebugEnabled())
log.debug("No expiration key for Node: " + fqn);
@@ -102,18 +101,18 @@
@SuppressWarnings("unchecked")
private Long getExpiration(Fqn fqn)
{
- NodeSPI<String, Long> n = policy.getCache().peek(fqn, false);
+ NodeSPI n = cache.peek(fqn, false);
if (n == null)
return null;
- return n.getDirect(config.getExpirationKeyName());
+ return (Long) n.getDirect(config.getExpirationKeyName());
}
@Override
- protected void processQueues(Region region) throws EvictionException
+ protected void processQueues(BlockingQueue<EvictionEvent> queue) throws EvictionException
{
- EvictedEventNode node;
+ EvictionEvent node;
int count = 0;
- while ((node = region.takeLastEventNode()) != null)
+ while ((node = getNextInQueue(queue)) != null)
{
count++;
switch (node.getEventType())
@@ -139,13 +138,10 @@
}
}
- if (trace)
- {
- log.trace("processed " + count + " node events in region: " + region.getFqn());
- }
+ if (trace) log.trace("processed " + count + " node events in region: " + regionFqn);
}
- private void markInUse(EvictedEventNode node)
+ private void markInUse(EvictionEvent node)
{
long expiration = node.getInUseTimeout() + System.currentTimeMillis();
setExpiration(node.getFqn(), expiration);
@@ -185,7 +181,7 @@
}
@Override
- public void resetEvictionQueue(Region region)
+ public void resetEvictionQueue()
{
for (ExpirationEntry ee : set)
{
@@ -194,10 +190,9 @@
}
@Override
- protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ protected EvictionQueue setupEvictionQueue() throws EvictionException
{
- this.region = region;
- this.config = (ExpirationConfiguration) region.getEvictionPolicyConfig();
+ this.config = (ExpirationAlgorithmConfig) evictionAlgorithmConfig;
return new DummyEvictionQueue();
}
@@ -207,6 +202,17 @@
throw new UnsupportedOperationException();
}
+ @Override
+ public boolean canIgnoreEvent(Type eventType)
+ {
+ return (eventType == EvictionEvent.Type.VISIT_NODE_EVENT);
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return ExpirationAlgorithmConfig.class;
+ }
+
/**
* Ordered list of FQN, with the expiration taken from the Map at the time
* of processing.
@@ -345,7 +351,6 @@
{
throw new UnsupportedOperationException();
}
-
}
}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,123 @@
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.Dynamic;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Configuration for indicating the Node key for setting a specific eviction time.
+ */
+public class ExpirationAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+
+ private static final long serialVersionUID = 47338798734219507L;
+
+ /**
+ * Default key name for indicating expiration time.
+ */
+ public static final String EXPIRATION_KEY = "expiration";
+
+ /**
+ * Node key name used to indicate the expiration of a node.
+ */
+ @Dynamic
+ private String expirationKeyName = EXPIRATION_KEY;
+
+ @Dynamic
+ private boolean warnNoExpirationKey = true;
+
+ @Dynamic
+ private long timeToLive = 0;
+
+ public ExpirationAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = ExpirationAlgorithm.class.getName();
+ }
+
+ /**
+ * Returns the expirationKeyName.
+ * This key should point to a java.lang.Long value in the Node data.
+ */
+ public String getExpirationKeyName()
+ {
+ return expirationKeyName;
+ }
+
+ /**
+ * Sets the expirationKeyName.
+ */
+ public void setExpirationKeyName(String expirationKeyName)
+ {
+ this.expirationKeyName = expirationKeyName;
+ }
+
+ /**
+ * Returns true if the algorithm should warn if a expiration key is missing for a node.
+ */
+ public boolean isWarnNoExpirationKey()
+ {
+ return warnNoExpirationKey;
+ }
+
+ /**
+ * Sets if the algorithm should warn if a expiration key is missing for a node.
+ */
+ public void setWarnNoExpirationKey(boolean warnNoExpirationKey)
+ {
+ this.warnNoExpirationKey = warnNoExpirationKey;
+ }
+
+ /**
+ * @return time to live, in milliseconds
+ */
+ public long getTimeToLive()
+ {
+ return timeToLive;
+ }
+
+ /**
+ * Sets the time to live
+ *
+ * @param timeToLive value in milliseconds
+ */
+ public void setTimeToLive(long timeToLive)
+ {
+ this.timeToLive = timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive, TimeUnit timeUnit)
+ {
+ this.timeToLive = timeUnit.toMillis(timeToLive);
+ }
+
+ @Override
+ public ExpirationAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (ExpirationAlgorithmConfig) super.clone();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ if (!super.equals(o)) return false;
+
+ ExpirationAlgorithmConfig that = (ExpirationAlgorithmConfig) o;
+
+ if (timeToLive != that.timeToLive) return false;
+ if (warnNoExpirationKey != that.warnNoExpirationKey) return false;
+ if (expirationKeyName != null ? !expirationKeyName.equals(that.expirationKeyName) : that.expirationKeyName != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (expirationKeyName != null ? expirationKeyName.hashCode() : 0);
+ result = 31 * result + (warnNoExpirationKey ? 1 : 0);
+ result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
+ return result;
+ }
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,10 +1,16 @@
package org.jboss.cache.eviction;
import org.jboss.cache.config.Dynamic;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import java.util.concurrent.TimeUnit;
+
/**
* Configuration for indicating the Node key for setting a specific eviction time.
+ *
+ * @deprecated see {@link org.jboss.cache.eviction.ExpirationAlgorithmConfig}
*/
+@Deprecated
public class ExpirationConfiguration extends EvictionPolicyConfigBase
{
@@ -24,19 +30,27 @@
@Dynamic
private boolean warnNoExpirationKey = true;
- @Deprecated
@Dynamic
private int timeToLiveSeconds = 0;
- @Dynamic
- private long timeToLive = 0;
-
@Override
protected void setEvictionPolicyClassName()
{
setEvictionPolicyClass(ExpirationPolicy.class.getName());
}
+ @Override
+ public EvictionAlgorithmConfig modernize()
+ {
+ ExpirationAlgorithmConfig modernCfg = new ExpirationAlgorithmConfig();
+ modernCfg.setExpirationKeyName(getExpirationKeyName());
+ modernCfg.setTimeToLive(getTimeToLiveSeconds(), TimeUnit.SECONDS);
+ modernCfg.setWarnNoExpirationKey(getWarnNoExpirationKey());
+ modernCfg.setMaxNodes(getMaxNodes());
+ modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECONDS);
+ return modernCfg;
+ }
+
/**
* Returns the expirationKeyName.
* This key should point to a java.lang.Long value in the Node data.
@@ -70,36 +84,14 @@
this.warnNoExpirationKey = warnNoExpirationKey;
}
- /** value expressed in millis */
- public long getTimeToLive()
- {
- return timeToLive;
- }
-
- /** value expressed in millis */
- public void setTimeToLive(long timeToLive)
- {
- this.timeToLive = timeToLive;
- this.timeToLiveSeconds = (int) (timeToLive * 1000);
- }
-
- /**
- * Use {@link #getTimeToLive()}.
- */
- @Deprecated
public int getTimeToLiveSeconds()
{
return timeToLiveSeconds;
}
- /**
- * use {@link #setTimeToLive(long)}.
- */
- @Deprecated
public void setTimeToLiveSeconds(int timeToLiveSeconds)
{
this.timeToLiveSeconds = timeToLiveSeconds;
- timeToLive = timeToLiveSeconds * 1000;
}
@Override
@@ -107,6 +99,4 @@
{
return (ExpirationConfiguration) super.clone();
}
-
-
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,7 +6,9 @@
* Returns the {@link ExpirationAlgorithm} as the policy's algorithm.
*
* @author rosse
+ * @deprecated see ExpirationAlgorithm
*/
+@Deprecated
public class ExpirationPolicy extends BaseEvictionPolicy
{
@@ -14,7 +16,7 @@
public ExpirationPolicy()
{
- algorithm = new ExpirationAlgorithm(this);
+ algorithm = new ExpirationAlgorithm();
}
public EvictionAlgorithm getEvictionAlgorithm()
@@ -31,8 +33,8 @@
* Returns true if it's a visit node event.
*/
@Override
- public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
+ public boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType)
{
- return (eventType == NodeEventType.VISIT_NODE_EVENT);
+ return (eventType == EvictionEventType.VISIT_NODE_EVENT);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,7 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Region;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
/**
* First-in-first-out algorithm used to evict nodes.
@@ -24,7 +24,7 @@
@Override
- protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ protected EvictionQueue setupEvictionQueue() throws EvictionException
{
return new FIFOQueue();
}
@@ -39,7 +39,7 @@
// ensure that, if configured, nodes are kept alive for at least a minimum period of time.
if (isYoungerThanMinimumTimeToLive(ne)) return false;
- FIFOConfiguration config = (FIFOConfiguration) region.getEvictionPolicyConfig();
+ FIFOAlgorithmConfig config = (FIFOAlgorithmConfig) evictionAlgorithmConfig;
if (trace)
{
log.trace("Deciding whether node in queue " + ne.getFqn() + " requires eviction.");
@@ -48,5 +48,10 @@
int size = this.getEvictionQueue().getNumberOfNodes();
return config.getMaxNodes() != 0 && size > config.getMaxNodes();
}
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return FIFOAlgorithmConfig.class;
+ }
}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.ConfigurationException;
+
+/**
+ * Configuration for {@link FIFOAlgorithm}.
+ * <p/>
+ * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class FIFOAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -7229715009546277313L;
+
+ public FIFOAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = FIFOAlgorithm.class.getName();
+ // We require that maxNodes is set
+ setMaxNodes(-1);
+ }
+
+ public FIFOAlgorithmConfig(int maxNodes)
+ {
+ evictionAlgorithmClassName = FIFOAlgorithm.class.getName();
+ // We require that maxNodes is set
+ setMaxNodes(maxNodes);
+ }
+
+ /**
+ * Requires a positive maxNodes value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ if (getMaxNodes() < 0)
+ {
+ throw new ConfigurationException("maxNodes must be must be " +
+ "configured to a value greater than or equal to 0");
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder ret = new StringBuilder();
+ ret.append("FIFOAlgorithmConfig: maxNodes = ").append(getMaxNodes());
+ return ret.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return (obj instanceof FIFOAlgorithmConfig && super.equals(obj));
+ }
+
+ @Override
+ public void reset()
+ {
+ setMaxNodes(-1);
+ }
+
+ @Override
+ public FIFOAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (FIFOAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -7,7 +7,10 @@
package org.jboss.cache.eviction;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import java.util.concurrent.TimeUnit;
+
/**
* Configuration for {@link FIFOPolicy}.
* <p/>
@@ -23,7 +26,9 @@
*
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
+ * @deprecated see {@link org.jboss.cache.eviction.FIFOAlgorithmConfig}
*/
+@Deprecated
public class FIFOConfiguration extends EvictionPolicyConfigBase
{
/**
@@ -38,6 +43,15 @@
setMaxNodes(-1);
}
+ @Override
+ public EvictionAlgorithmConfig modernize()
+ {
+ FIFOAlgorithmConfig modernCfg = new FIFOAlgorithmConfig();
+ modernCfg.setMaxNodes(getMaxNodes());
+ modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECONDS);
+ return modernCfg;
+ }
+
/**
* Requires a positive maxNodes value or ConfigurationException
* is thrown.
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -13,7 +13,9 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @author Morten Kvistgaard
* @version $Revision$
+ * @deprecated see FIFOAlgorithm
*/
+@Deprecated
public class FIFOPolicy extends BaseEvictionPolicy
{
private FIFOAlgorithm algorithm;
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,7 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Region;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
/**
* Least Frequently Used algorithm for cache eviction.
@@ -49,7 +49,7 @@
// ensure that, if configured, nodes are kept alive for at least a minimum period of time.
if (isYoungerThanMinimumTimeToLive(ne)) return false;
- LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig();
+ LFUAlgorithmConfig config = (LFUAlgorithmConfig) evictionAlgorithmConfig;
int size = this.getEvictionQueue().getNumberOfNodes();
if (config.getMaxNodes() != 0 && size > config.getMaxNodes())
{
@@ -66,12 +66,11 @@
/**
* Will create a LFUQueue to be used as the underlying eviction queue.
*
- * @param region MarshRegion to create the eviction queue for.
* @return The created LFUQueue.
* @throws EvictionException
*/
@Override
- protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ protected EvictionQueue setupEvictionQueue() throws EvictionException
{
return new LFUQueue();
}
@@ -84,4 +83,9 @@
// clean up the Queue's eviction removals
((LFUQueue) this.evictionQueue).prune();
}
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return LFUAlgorithmConfig.class;
+ }
}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.Dynamic;
+
+/**
+ * Configuration implementation for {@link LFUAlgorithm}.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class LFUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = 1865801530398969179L;
+
+ @Dynamic
+ private int minNodes;
+
+ public LFUAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = LFUAlgorithm.class.getName();
+ }
+
+ public LFUAlgorithmConfig(int maxNodes, int minNodes)
+ {
+ this();
+ setMaxNodes(maxNodes);
+ setMinNodes(minNodes);
+ }
+
+ public int getMinNodes()
+ {
+ return minNodes;
+ }
+
+ public void setMinNodes(int minNodes)
+ {
+ testImmutability("minNodes");
+ this.minNodes = minNodes;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder ret = new StringBuilder();
+ ret.append("LFUAlgorithmConfig: maxNodes = ").append(getMaxNodes()).append(" minNodes = ").append(getMinNodes());
+ return ret.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof LFUAlgorithmConfig && super.equals(obj))
+ {
+ return (this.minNodes == ((LFUAlgorithmConfig) obj).minNodes);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + minNodes;
+ return result;
+ }
+
+ @Override
+ public LFUAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (LFUAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -7,7 +7,10 @@
package org.jboss.cache.eviction;
import org.jboss.cache.config.Dynamic;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import java.util.concurrent.TimeUnit;
+
/**
* Configuration implementation for {@link LFUPolicy}.
* <p/>
@@ -22,7 +25,9 @@
*
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
+ * @deprecated see {@link org.jboss.cache.eviction.LFUAlgorithmConfig}
*/
+@Deprecated
public class LFUConfiguration extends EvictionPolicyConfigBase
{
/**
@@ -51,6 +56,16 @@
}
@Override
+ public EvictionAlgorithmConfig modernize()
+ {
+ LFUAlgorithmConfig modernCfg = new LFUAlgorithmConfig();
+ modernCfg.setMaxNodes(getMaxNodes());
+ modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECONDS);
+ modernCfg.setMinNodes(getMinNodes());
+ return modernCfg;
+ }
+
+ @Override
public String toString()
{
StringBuilder ret = new StringBuilder();
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -11,7 +11,9 @@
*
* @author Daniel Huang - dhuang(a)jboss.org - 10/2005
* @version $Revision$
+ * @deprecated see LFUAlgorithm
*/
+@Deprecated
public class LFUPolicy extends BaseEvictionPolicy
{
private LFUAlgorithm algorithm;
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -9,7 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Region;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
import java.util.Iterator;
@@ -26,7 +26,7 @@
private static final boolean trace = log.isTraceEnabled();
@Override
- protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ protected EvictionQueue setupEvictionQueue() throws EvictionException
{
return new LRUQueue();
}
@@ -38,7 +38,7 @@
// ensure that, if configured, nodes are kept alive for at least a minimum period of time.
if (isYoungerThanMinimumTimeToLive(entry)) return false;
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) evictionAlgorithmConfig;
// no idle or max time limit
if (config.getTimeToLive() == 0 && config.getMaxAge() == 0) return false;
@@ -152,7 +152,7 @@
}
}
- int maxNodes = this.getConfiguration().getMaxNodes();
+ int maxNodes = ((LRUAlgorithmConfig) evictionAlgorithmConfig).getMaxNodes();
if (maxNodes <= 0)
{
return;
@@ -177,9 +177,8 @@
}
}
- protected LRUConfiguration getConfiguration()
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
{
- return (LRUConfiguration) region.getEvictionPolicyConfig();
+ return LRUAlgorithmConfig.class;
}
-
}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.Dynamic;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Configuration implementation for {@link LRUAlgorithm}.
+ * <p/>
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class LRUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -3426716488271559729L;
+
+ /**
+ * value expressed in millis
+ */
+ @Dynamic
+ private long timeToLive;
+
+ /**
+ * value expressed in millis
+ */
+ @Dynamic
+ private long maxAge;
+
+ public LRUAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = LRUAlgorithm.class.getName();
+ // Force config of ttls
+ setTimeToLive(-1);
+ }
+
+ public LRUAlgorithmConfig(long timeToLive, long maxAge)
+ {
+ this();
+ this.timeToLive = timeToLive;
+ this.maxAge = maxAge;
+ }
+
+ public LRUAlgorithmConfig(int timeToLive, int maxAge, int maxNodes)
+ {
+ this(timeToLive, maxAge);
+ this.maxNodes = maxNodes;
+ }
+
+ /**
+ * @return the time to live, in milliseconds
+ */
+ public long getTimeToLive()
+ {
+ return timeToLive;
+ }
+
+ /**
+ * Sets the time to live
+ *
+ * @param timeToLive the time to live, in milliseconds
+ */
+ public void setTimeToLive(long timeToLive)
+ {
+ testImmutability("timeToLive");
+ this.timeToLive = timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive, TimeUnit timeUnit)
+ {
+ testImmutability("timeToLive");
+ this.timeToLive = timeUnit.toMillis(timeToLive);
+ }
+
+ /**
+ * @return the max age per element, in milliseconds
+ */
+ public long getMaxAge()
+ {
+ return maxAge;
+ }
+
+ /**
+ * Sets the max age per element
+ *
+ * @param maxAge value in milliseconds
+ */
+ public void setMaxAge(long maxAge)
+ {
+ testImmutability("maxAge");
+ this.maxAge = maxAge;
+ }
+
+ public void setMaxAge(long maxAge, TimeUnit timeUnit)
+ {
+ testImmutability("maxAge");
+ this.maxAge = timeUnit.toMillis(maxAge);
+ }
+
+ /**
+ * Requires a positive timeToLive value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ if (timeToLive < 0)
+ {
+ throw new ConfigurationException("timeToLive must be " +
+ "configured to a value greater than or equal to 0 for " + getEvictionAlgorithmClassName());
+ }
+ }
+
+ public String toString()
+ {
+ return "LRUAlgorithmConfig {" +
+ ", timeToLive=" + timeToLive +
+ ", maxAge=" + maxAge +
+ '}';
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof LRUAlgorithmConfig)) return false;
+ if (!super.equals(o)) return false;
+
+ LRUAlgorithmConfig that = (LRUAlgorithmConfig) o;
+
+ if (maxAge != that.maxAge) return false;
+ if (timeToLive != that.timeToLive) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
+ result = 31 * result + (int) (maxAge ^ (maxAge >>> 32));
+ return result;
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ setTimeToLive(-1);
+ }
+
+ @Override
+ public LRUAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (LRUAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,7 +8,10 @@
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.Dynamic;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import java.util.concurrent.TimeUnit;
+
/**
* Configuration implementation for {@link LRUPolicy}.
* <p/>
@@ -24,7 +27,9 @@
*
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
+ * @deprecated see {@link org.jboss.cache.eviction.LRUAlgorithmConfig}
*/
+@Deprecated
public class LRUConfiguration extends EvictionPolicyConfigBase
{
/**
@@ -33,33 +38,26 @@
private static final long serialVersionUID = -3426716488271559729L;
@Dynamic
- @Deprecated
private int timeToLiveSeconds;
@Dynamic
- @Deprecated
private int maxAgeSeconds;
-
- /** value expressed in millis*/
- @Dynamic
- private long timeToLive;
-
- /** value expressed in millis*/
- @Dynamic
- private long maxAge;
-
public LRUConfiguration()
{
super();
// Force config of ttls
- setTimeToLive(-1);
+ setTimeToLiveSeconds(-1);
}
- public LRUConfiguration(long timeToLive, long maxAge)
+ @Override
+ public EvictionAlgorithmConfig modernize()
{
- super();
- setTimeToLive(timeToLive);
- setMaxAge(maxAge);
+ LRUAlgorithmConfig modernCfg = new LRUAlgorithmConfig();
+ modernCfg.setMaxNodes(getMaxNodes());
+ modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECONDS);
+ modernCfg.setTimeToLive(getTimeToLiveSeconds(), TimeUnit.SECONDS);
+ modernCfg.setMaxAge(getMaxAgeSeconds(), TimeUnit.SECONDS);
+ return modernCfg;
}
@Override
@@ -68,75 +66,26 @@
setEvictionPolicyClass(LRUPolicy.class.getName());
}
- /** value expressed in millis*/
- public long getTimeToLive()
- {
- return timeToLive;
- }
-
- /** value expressed in millis*/
- public void setTimeToLive(long timeToLive)
- {
- testImmutability("timeToLive");
- this.timeToLive = timeToLive;
- this.timeToLiveSeconds = (int)(timeToLive/1000);
- }
-
- /** value expressed in millis*/
- public long getMaxAge()
- {
- return maxAge;
- }
-
- /** value expressed in millis*/
- public void setMaxAge(long maxAge)
- {
- testImmutability("maxAge");
- this.maxAge = maxAge;
- this.maxAgeSeconds = (int) (maxAge/1000);
- }
-
- /**
- * use {@link #getTimeToLive()}
- * @return
- */
- @Deprecated
public int getTimeToLiveSeconds()
{
return timeToLiveSeconds;
}
- /**
- * Use {@link #setTimeToLive(long)}
- */
- @Deprecated
public void setTimeToLiveSeconds(int timeToLiveSeconds)
{
testImmutability("timeToLiveSeconds");
this.timeToLiveSeconds = timeToLiveSeconds;
- timeToLive = timeToLiveSeconds * 1000;
}
- /**
- * Use {@link #getMaxAge()}
- * @deprecated
- */
- @Deprecated
public int getMaxAgeSeconds()
{
return maxAgeSeconds;
}
- /**
- * Use {@link #getMaxAge()}
- * @param maxAgeSeconds
- */
- @Deprecated
public void setMaxAgeSeconds(int maxAgeSeconds)
{
testImmutability("maxAgeSeconds");
this.maxAgeSeconds = maxAgeSeconds;
- this.maxAge = maxAgeSeconds * 1000;
}
/**
@@ -146,7 +95,7 @@
@Override
public void validate() throws ConfigurationException
{
- if (timeToLive < 0)
+ if (timeToLiveSeconds < 0)
{
throw new ConfigurationException("timeToLive must be " +
"configured to a value greater than or equal to 0 for " + getEvictionPolicyClass());
@@ -158,8 +107,8 @@
{
return "LRUConfiguration{" +
"timeToLiveSeconds=" + timeToLiveSeconds +
- ", timeToLive=" + timeToLive +
- ", maxAge=" + maxAge +
+ ", timeToLiveSeconds=" + timeToLiveSeconds +
+ ", maxAgeSeconds=" + maxAgeSeconds +
'}';
}
@@ -171,10 +120,10 @@
LRUConfiguration that = (LRUConfiguration) o;
- if (maxAge != that.maxAge) return false;
if (maxAgeSeconds != that.maxAgeSeconds) return false;
- if (timeToLive != that.timeToLive) return false;
+ if (maxAgeSeconds != that.maxAgeSeconds) return false;
if (timeToLiveSeconds != that.timeToLiveSeconds) return false;
+ if (timeToLiveSeconds != that.timeToLiveSeconds) return false;
return true;
}
@@ -184,8 +133,8 @@
int result = super.hashCode();
result = 31 * result + timeToLiveSeconds;
result = 31 * result + maxAgeSeconds;
- result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
- result = 31 * result + (int) (maxAge ^ (maxAge >>> 32));
+ result = 31 * result + (timeToLiveSeconds ^ (timeToLiveSeconds >>> 7));
+ result = 31 * result + (maxAgeSeconds ^ (maxAgeSeconds >>> 7));
return result;
}
@@ -193,7 +142,7 @@
public void reset()
{
super.reset();
- setTimeToLive(-1);
+ setTimeToLiveSeconds(-1);
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -17,7 +17,9 @@
* @author Ben Wang 02-2004
* @author Daniel Huang - dhuang(a)jboss.org
* @version $Revision$
+ * @deprecated see LRUAlgorithm
*/
+@Deprecated
public class LRUPolicy extends BaseEvictionPolicy
{
protected RegionManager regionManager_;
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,7 +6,7 @@
*/
package org.jboss.cache.eviction;
-import org.jboss.cache.Region;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
/**
* Most Recently Used Algorithm.
@@ -22,7 +22,7 @@
public class MRUAlgorithm extends BaseEvictionAlgorithm
{
@Override
- protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ protected EvictionQueue setupEvictionQueue() throws EvictionException
{
return new MRUQueue();
}
@@ -34,14 +34,19 @@
// ensure that, if configured, nodes are kept alive for at least a minimum period of time.
if (isYoungerThanMinimumTimeToLive(ne)) return false;
- MRUConfiguration config = (MRUConfiguration) region.getEvictionPolicyConfig();
+ MRUAlgorithmConfig config = (MRUAlgorithmConfig) evictionAlgorithmConfig;
return evictionQueue.getNumberOfNodes() > config.getMaxNodes();
}
@Override
- protected void processVisitedNodes(EvictedEventNode evictedEventNode) throws EvictionException
+ protected void processVisitedNodes(EvictionEvent evictedEventNode) throws EvictionException
{
super.processVisitedNodes(evictedEventNode);
((MRUQueue) evictionQueue).moveToTopOfStack(evictedEventNode.getFqn());
}
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return MRUAlgorithmConfig.class;
+ }
}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java (from rev 6552, core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.ConfigurationException;
+
+/**
+ * Configuration for {@link MRUAlgorithm}.
+ * <p/>
+ * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class MRUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -8734577898966155218L;
+
+ public MRUAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = MRUAlgorithm.class.getName();
+ // We require that maxNodes is set
+ setMaxNodes(-1);
+ }
+
+ public MRUAlgorithmConfig(int maxNodes)
+ {
+ evictionAlgorithmClassName = MRUAlgorithm.class.getName();
+ setMaxNodes(maxNodes);
+ }
+
+ /**
+ * Requires a positive maxNodes value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ if (getMaxNodes() < 0)
+ throw new ConfigurationException("maxNodes not configured");
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder str = new StringBuilder();
+ str.append("MRUAlgorithmConfig: ").
+ append(" maxNodes =").append(getMaxNodes());
+ return str.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return (obj instanceof MRUAlgorithmConfig && super.equals(obj));
+ }
+
+ @Override
+ public void reset()
+ {
+ setMaxNodes(-1);
+ }
+
+ @Override
+ public MRUAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (MRUAlgorithmConfig) super.clone();
+ }
+
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -7,7 +7,10 @@
package org.jboss.cache.eviction;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import java.util.concurrent.TimeUnit;
+
/**
* Configuration for {@link MRUPolicy}.
* <p/>
@@ -23,7 +26,9 @@
*
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
+ * @deprecated see {@link org.jboss.cache.eviction.MRUAlgorithmConfig}
*/
+@Deprecated
public class MRUConfiguration extends EvictionPolicyConfigBase
{
/**
@@ -44,7 +49,16 @@
setEvictionPolicyClass(MRUPolicy.class.getName());
}
+ @Override
+ public EvictionAlgorithmConfig modernize()
+ {
+ MRUAlgorithmConfig modernCfg = new MRUAlgorithmConfig();
+ modernCfg.setMaxNodes(getMaxNodes());
+ modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECONDS);
+ return modernCfg;
+ }
+
/**
* Requires a positive maxNodes value or ConfigurationException
* is thrown.
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -13,7 +13,9 @@
*
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
+ * @deprecated see MRUAlgorithm
*/
+@Deprecated
public class MRUPolicy extends BaseEvictionPolicy
{
private MRUAlgorithm algorithm;
Added: core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,17 @@
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+
+/**
+ * Attached to deprecated eviction configuration elements that know how to map to modern counterparts. This interface
+ * is itself deprecated and is only used to bridge deprecated configurations.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ * @deprecated
+ */
+@Deprecated
+public interface Modernizable
+{
+ EvictionAlgorithmConfig modernize();
+}
Deleted: core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,40 +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.cache.eviction;
-
-/**
- * Enumeration of the valid event types used to create an
- * {@link org.jboss.cache.eviction.EvictedEventNode}.
- *
- * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public enum NodeEventType
-{
- ADD_NODE_EVENT,
- REMOVE_NODE_EVENT,
- VISIT_NODE_EVENT,
- ADD_ELEMENT_EVENT,
- REMOVE_ELEMENT_EVENT,
- MARK_IN_USE_EVENT,
- UNMARK_USE_EVENT
-}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,27 +1,40 @@
/**
- *
+ *
*/
package org.jboss.cache.eviction;
-import org.jboss.cache.Region;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.eviction.EvictionEvent.Type;
+import java.util.concurrent.BlockingQueue;
+
/**
- * Algorithm for {@link NullEvictionPolicy}.
- *
+ * An eviction algorithm that does nothing - a no-op for everything.
+ *
* @author Brian Stansberry
*/
public class NullEvictionAlgorithm implements EvictionAlgorithm
{
- /** Singleton instance of this class. */
- public static final NullEvictionAlgorithm INSTANCE = new NullEvictionAlgorithm();
-
/**
+ * Singleton instance of this class.
+ */
+ private static final NullEvictionAlgorithm INSTANCE = new NullEvictionAlgorithm();
+
+ /**
* Constructs a new NullEvictionAlgorithm.
*/
private NullEvictionAlgorithm()
{
}
+ public static NullEvictionAlgorithm getInstance()
+ {
+ return INSTANCE;
+ }
+
/**
* Returns {@link NullEvictionQueue#INSTANCE}.
*/
@@ -30,16 +43,38 @@
return NullEvictionQueue.INSTANCE;
}
- /** No-op */
- public void process(Region region) throws EvictionException
+ public void setEvictionActionPolicy(EvictionActionPolicy evictionActionPolicy)
{
// no-op
}
- /** No-op */
- public void resetEvictionQueue(Region region)
+ public void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
{
// no-op
}
+ public void process(BlockingQueue<EvictionEvent> queue) throws EvictionException
+ {
+ // no-op
+ }
+
+ public void resetEvictionQueue()
+ {
+ // no-op
+ }
+
+ public boolean canIgnoreEvent(Type eventType)
+ {
+ return true; // always ignore everything!
+ }
+
+ public void initialize()
+ {
+ // no-op
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return NullEvictionAlgorithmConfig.class;
+ }
}
Copied: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithmConfig.java (from rev 6552, core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithmConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithmConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,45 @@
+/**
+ *
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.ConfigurationComponent;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+
+/**
+ * Configuration class for {@link NullEvictionAlgorithm}.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class NullEvictionAlgorithmConfig extends ConfigurationComponent implements EvictionAlgorithmConfig
+{
+ private static final long serialVersionUID = -6591180473728241737L;
+
+ /**
+ * No-op
+ */
+ public void reset()
+ {
+ // no-op
+ }
+
+ public String getEvictionAlgorithmClassName()
+ {
+ return NullEvictionAlgorithm.class.getName();
+ }
+
+ /**
+ * No-op
+ */
+ public void validate() throws ConfigurationException
+ {
+ // no-op
+ }
+
+ public NullEvictionAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (NullEvictionAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithmConfig.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -18,7 +18,9 @@
* want eviction.
*
* @author Brian Stansberry
+ * @deprecated see NullEvictionAlgorithm
*/
+@Deprecated
public class NullEvictionPolicy implements EvictionPolicy
{
private static final Log log = LogFactory.getLog(NullEvictionPolicy.class);
@@ -28,7 +30,7 @@
/**
* Returns <code>true</code>
*/
- public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
+ public boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType)
{
return true;
}
@@ -46,7 +48,7 @@
*/
public EvictionAlgorithm getEvictionAlgorithm()
{
- return NullEvictionAlgorithm.INSTANCE;
+ return NullEvictionAlgorithm.getInstance();
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -5,16 +5,19 @@
import org.jboss.cache.config.ConfigurationComponent;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
import org.jboss.cache.config.EvictionPolicyConfig;
/**
* Configuration class for {@link NullEvictionPolicy}.
*
* @author Brian Stansberry
+ * @deprecated see {@link NullEvictionAlgorithmConfig}
*/
+@Deprecated
public class NullEvictionPolicyConfig
extends ConfigurationComponent
- implements EvictionPolicyConfig
+ implements EvictionPolicyConfig, Modernizable
{
private static final long serialVersionUID = -6591180473728241737L;
@@ -27,6 +30,11 @@
return NullEvictionPolicy.class.getName();
}
+ public EvictionAlgorithmConfig modernize()
+ {
+ return new NullEvictionAlgorithmConfig();
+ }
+
/**
* No-op
*/
@@ -42,5 +50,4 @@
{
// no-op
}
-
}
Added: core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -0,0 +1,36 @@
+package org.jboss.cache.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+
+/**
+ * An eviction action policy that calls {@link org.jboss.cache.Cache#removeNode(org.jboss.cache.Fqn)} to evict a node.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class RemoveOnEvictActionPolicy implements EvictionActionPolicy
+{
+ Cache<?, ?> cache;
+ private static final Log log = LogFactory.getLog(DefaultEvictionActionPolicy.class);
+
+ public void setCache(Cache<?, ?> cache)
+ {
+ this.cache = cache;
+ }
+
+ public boolean evict(Fqn fqn)
+ {
+ try
+ {
+ return cache.removeNode(fqn);
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e);
+ return false;
+ }
+ }
+}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -2,9 +2,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.eviction.NodeEventType;
+import org.jboss.cache.factories.annotations.Inject;
/**
* A subclass of EvictionInterceptor that is aware of and able to deal with buddy regions.
@@ -23,9 +22,9 @@
}
@Override
- protected Region getRegion(Fqn fqn, NodeEventType type)
+ protected Region getRegion(Fqn fqn)
{
- Region r = super.getRegion(fqn, type);
+ Region r = super.getRegion(fqn);
if (r != null)
return r;
else if (buddyFqnTransformer.isBackupFqn(fqn))
@@ -41,7 +40,7 @@
//create a new region for this backup
Region newRegion = regionManager.getRegion(Fqn.fromRelativeFqn(backupRoot, actualRegion.getFqn()), Region.Type.EVICTION, true);
- newRegion.setEvictionPolicy(actualRegion.getEvictionPolicyConfig());
+ newRegion.setEvictionRegionConfig(actualRegion.getEvictionRegionConfig());
return newRegion;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -21,8 +21,8 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.eviction.EvictedEventNode;
-import org.jboss.cache.eviction.NodeEventType;
+import org.jboss.cache.eviction.EvictionEvent;
+import static org.jboss.cache.eviction.EvictionEvent.Type.*;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.InvocationContext;
@@ -71,9 +71,9 @@
if (!complete)
{
Region r;
- if (fqn != null && (r = getRegion(fqn, NodeEventType.ADD_NODE_EVENT)) != null)
+ if (fqn != null && (r = getRegion(fqn)) != null)
{
- registerEvictionEventToRegionManager(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT, 0), r);
+ registerEvictionEventToRegionManager(fqn, ADD_NODE_EVENT, 0, r);
}
}
return retVal;
@@ -90,9 +90,9 @@
{
Object retVal = invokeNextInterceptor(ctx, command);
Region r;
- if (command.getFqn() != null && command.getKey() != null && (r = getRegion(command.getFqn(), NodeEventType.ADD_ELEMENT_EVENT)) != null)
+ if (command.getFqn() != null && command.getKey() != null && (r = getRegion(command.getFqn())) != null)
{
- registerEvictionEventToRegionManager(new EvictedEventNode(command.getFqn(), NodeEventType.ADD_ELEMENT_EVENT, 1), r);
+ registerEvictionEventToRegionManager(command.getFqn(), ADD_ELEMENT_EVENT, 1, r);
}
return retVal;
}
@@ -103,7 +103,7 @@
Object retVal = invokeNextInterceptor(ctx, command);
Fqn fqn = command.getFqn();
Region r;
- if (fqn != null && (r = getRegion(fqn, NodeEventType.ADD_NODE_EVENT)) != null)
+ if (fqn != null && (r = getRegion(fqn)) != null)
{
if (command.getData() == null)
{
@@ -119,8 +119,7 @@
{
size = command.getData().size();
}
- EvictedEventNode event = new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT, size);
- registerEvictionEventToRegionManager(event, r);
+ registerEvictionEventToRegionManager(fqn, ADD_NODE_EVENT, size, r);
}
}
return retVal;
@@ -142,9 +141,9 @@
{
Fqn fqn = command.getFqn();
Region r;
- if (fqn != null && command.getKey() != null && (r = getRegion(fqn, NodeEventType.REMOVE_ELEMENT_EVENT)) != null)
+ if (fqn != null && command.getKey() != null && (r = getRegion(fqn)) != null)
{
- registerEvictionEventToRegionManager(new EvictedEventNode(fqn, NodeEventType.REMOVE_ELEMENT_EVENT, 1), r);
+ registerEvictionEventToRegionManager(fqn, REMOVE_ELEMENT_EVENT, 1, r);
}
}
return retVal;
@@ -169,9 +168,9 @@
else
{
Region r;
- if (fqn != null && (r = getRegion(fqn, NodeEventType.VISIT_NODE_EVENT)) != null)
+ if (fqn != null && (r = getRegion(fqn)) != null)
{
- registerEvictionEventToRegionManager(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT), r);
+ registerEvictionEventToRegionManager(fqn, VISIT_NODE_EVENT, 0, r);
}
}
return retVal;
@@ -197,9 +196,9 @@
log.trace("No event added. Element does not exist");
}
}
- else if (fqn != null && command.getKey() != null && (r = getRegion(fqn, NodeEventType.VISIT_NODE_EVENT)) != null)
+ else if (fqn != null && command.getKey() != null && (r = getRegion(fqn)) != null)
{
- registerEvictionEventToRegionManager(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT), r);
+ registerEvictionEventToRegionManager(fqn, VISIT_NODE_EVENT, 0, r);
}
return retVal;
}
@@ -209,9 +208,9 @@
{
Object retVal = invokeNextInterceptor(ctx, command);
Region r;
- if (command.getFqn() != null && (r = getRegion(command.getFqn(), NodeEventType.REMOVE_NODE_EVENT)) != null)
+ if (command.getFqn() != null && (r = getRegion(command.getFqn())) != null)
{
- registerEvictionEventToRegionManager(new EvictedEventNode(command.getFqn(), NodeEventType.REMOVE_NODE_EVENT), r);
+ registerEvictionEventToRegionManager(command.getFqn(), REMOVE_NODE_EVENT, 0, r);
}
return retVal;
}
@@ -221,41 +220,25 @@
{
Object retVal = invokeNextInterceptor(ctx, command);
Region r;
- if (command.getFqn() != null && (r = getRegion(command.getFqn(), NodeEventType.REMOVE_NODE_EVENT)) != null)
+ if (command.getFqn() != null && (r = getRegion(command.getFqn())) != null)
{
- registerEvictionEventToRegionManager(new EvictedEventNode(command.getFqn(), NodeEventType.REMOVE_NODE_EVENT), r);
+ registerEvictionEventToRegionManager(command.getFqn(), REMOVE_NODE_EVENT, 0, r);
}
return retVal;
}
- private void registerEvictionEventToRegionManager(EvictedEventNode event, Region region)
+ private void registerEvictionEventToRegionManager(Fqn fqn, EvictionEvent.Type type, int elementDifference, Region region)
{
- if (event == null)
- {
- // no node modifications.
- return;
- }
-
//we do not trigger eviction events for resident nodes
- if (dataContainer.isResident(event.getFqn())) return;
+ if (dataContainer.isResident(fqn)) return;
- region.putNodeEvent(event);
+ region.registerEvictionEvent(fqn, type, elementDifference);
- if (trace)
- {
- log.trace("Adding event " + event + " to region at " + region.getFqn());
- }
-
- if (trace)
- {
- log.trace("Finished updating node");
- }
+ if (trace) log.trace("Registering event " + type + " on node " + fqn);
}
- protected Region getRegion(Fqn fqn, NodeEventType type)
+ protected Region getRegion(Fqn fqn)
{
- Region r = regionManager.getRegion(fqn, Region.Type.EVICTION, false);
- if (r != null && r.getEvictionPolicy().canIgnoreEvent(fqn, type)) return null;
- return r;
+ return regionManager.getRegion(fqn, Region.Type.EVICTION, false);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -17,8 +17,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.eviction.EvictedEventNode;
-import org.jboss.cache.eviction.NodeEventType;
+import org.jboss.cache.eviction.EvictionEvent;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.invocation.InvocationContext;
@@ -307,10 +306,9 @@
parent.addChild(fqn.getLastElement(), target);
// JBCACHE-913
Region region = cache.getRegion(fqn, false);
- if (region != null && region.getEvictionPolicy() != null)
+ if (region != null && region.getEvictionRegionConfig() != null)
{
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT,
- attrs == null ? 0 : attrs.size()));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT, attrs == null ? 0 : attrs.size());
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/util/Util.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/Util.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/main/java/org/jboss/cache/util/Util.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -21,6 +21,7 @@
*/
package org.jboss.cache.util;
+import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -52,6 +53,32 @@
return cl.loadClass(classname);
}
+ @SuppressWarnings("unchecked")
+ public static <T> T getInstance(Class<T> clazz) throws Exception
+ {
+ // first look for a getInstance() constructor
+ T instance;
+ try
+ {
+ Method factoryMethod = clazz.getMethod("getInstance", new Class[]{});
+ instance = (T) factoryMethod.invoke(null);
+ }
+ catch (Exception e)
+ {
+ // no factory method or factory method failed. Try a constructor.
+ instance = clazz.newInstance();
+ }
+ return instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Object getInstance(String classname) throws Exception
+ {
+ if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
+ Class clazz = loadClass(classname);
+ return getInstance(clazz);
+ }
+
/**
* Prevent instantiation
*/
@@ -158,5 +185,4 @@
return "Added Entries " + addedEntries + " Removeed Entries " + removedEntries + " Modified Entries " + modifiedEntries;
}
}
-
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -7,7 +7,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.internals.EvictionController;
import static org.testng.Assert.*;
@@ -53,12 +53,12 @@
EvictionRegionConfig evRegConfig = new EvictionRegionConfig();
evRegConfig.setRegionFqn(Fqn.fromString("/" + TEST_NODES_ROOT));
evRegConfig.setEventQueueSize(100);
- LRUConfiguration lruConfig = new LRUConfiguration();
+ LRUAlgorithmConfig lruConfig = new LRUAlgorithmConfig();
lruConfig.setMaxAge(100000000);
lruConfig.setTimeToLive(100000000);
lruConfig.setMaxNodes(3);
- evRegConfig.setEvictionPolicyConfig(lruConfig);
- evConfig.getEvictionRegionConfigs().add(evRegConfig);
+ evRegConfig.setEvictionAlgorithmConfig(lruConfig);
+ evConfig.addEvictionRegionConfig(evRegConfig);
//end setting up region stuff
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -13,7 +13,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.util.TestingUtil;
import static org.jboss.cache.util.TestingUtil.dumpCacheContents;
@@ -345,15 +345,13 @@
EvictionConfig ec = new EvictionConfig();
ec.setWakeupInterval(1000);
EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionName("/_default_");
- LRUConfiguration epc = new LRUConfiguration();
- epc.setMaxAge(2000);
- epc.setTimeToLive(1000);
- epc.setMaxNodes(1);
- erc.setEvictionPolicyConfig(epc);
- List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
- ercs.add(erc);
- ec.setEvictionRegionConfigs(ercs);
+ erc.setRegionFqn(Fqn.ROOT);
+ LRUAlgorithmConfig lruAlgorithmConfig = new LRUAlgorithmConfig();
+ lruAlgorithmConfig.setMaxAge(2000);
+ lruAlgorithmConfig.setTimeToLive(1000);
+ lruAlgorithmConfig.setMaxNodes(1);
+ erc.setEvictionAlgorithmConfig(lruAlgorithmConfig);
+ ec.setDefaultEvictionRegionConfig(erc);
cfg.setEvictionConfig(ec);
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -5,15 +5,13 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.NullEvictionPolicy;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+import org.jboss.cache.eviction.NullEvictionAlgorithmConfig;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-import java.util.Collections;
-
/**
* Tests the eviction of buddy backup regions
*
@@ -47,13 +45,13 @@
private EvictionConfig getEvictionConfig()
{
EvictionConfig c = new EvictionConfig();
- c.setDefaultEvictionPolicyClass(NullEvictionPolicy.class.getName());
+ EvictionRegionConfig defaultRegion = new EvictionRegionConfig(Fqn.ROOT, new NullEvictionAlgorithmConfig());
+ c.setDefaultEvictionRegionConfig(defaultRegion);
c.setWakeupInterval(1000);
- LRUConfiguration epc = new LRUConfiguration();
- epc.setMaxAge(1000);
- epc.setTimeToLive(1000);
- EvictionRegionConfig erc = new EvictionRegionConfig(fqn, epc);
- c.setEvictionRegionConfigs(Collections.singletonList(erc));
+
+ LRUAlgorithmConfig lru = new LRUAlgorithmConfig(1000, 1000);
+ EvictionRegionConfig subregion = new EvictionRegionConfig(fqn, lru);
+ c.addEvictionRegionConfig(subregion);
return c;
}
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -24,42 +24,45 @@
/**
* Tests the ability to clone Configuration elements and end up with
* independently modifiable configurations.
- *
+ *
* @author Brian Stansberry
*/
@Test(groups = {"functional"})
public class ConfigurationCloningTest
{
- /** A file that includes every configuration element I could think of */
+ /**
+ * A file that includes every configuration element I could think of
+ */
public static final String DEFAULT_CONFIGURATION_FILE = "configs/clonable-config.xml";
-
+
private static final Log log = LogFactory.getLog(ConfigurationCloningTest.class);
-
+
public void testClone() throws Exception
{
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = parser.parseFile(DEFAULT_CONFIGURATION_FILE);
-
- try {
- Configuration clone = c.clone();
-
+
+ try
+ {
+ Configuration clone = c.clone();
+
// Test a few simple properties
- assertEquals(NodeLockingScheme.OPTIMISTIC, clone.getNodeLockingScheme());
+ assertEquals(NodeLockingScheme.OPTIMISTIC, clone.getNodeLockingScheme());
assertEquals(CacheMode.REPL_SYNC, clone.getCacheMode());
- assertEquals("CloneCluster", clone.getClusterName());
- assertEquals(c.getClusterConfig(), clone.getClusterConfig());
+ assertEquals("CloneCluster", clone.getClusterName());
+ assertEquals(c.getClusterConfig(), clone.getClusterConfig());
assertEquals(3, clone.getStateRetrievalTimeout());
-
+
// Eviction
EvictionConfig ec1 = c.getEvictionConfig();
EvictionConfig ec2 = clone.getEvictionConfig();
-
+
assertFalse(ec1 == ec2);
-
- assertEquals(4, ec2.getDefaultEventQueueSize());
+
+ assertEquals(4, ec2.getDefaultEvictionRegionConfig().getEventQueueSize());
assertEquals(45000, ec2.getWakeupInterval());
assertEquals(LRUPolicy.class.getName(), ec2.getDefaultEvictionPolicyClass());
-
+
List<EvictionRegionConfig> ercs1 = ec1.getEvictionRegionConfigs();
List<EvictionRegionConfig> ercs2 = ec2.getEvictionRegionConfigs();
assertEquals(ercs1.size(), ercs2.size());
@@ -67,16 +70,16 @@
{
compareEvictionRegionConfigs(ercs1.get(i), ercs2.get(i));
}
-
+
// Cache loading
CacheLoaderConfig clc1 = c.getCacheLoaderConfig();
CacheLoaderConfig clc2 = clone.getCacheLoaderConfig();
-
+
assertFalse(clc1 == clc2);
-
+
assertFalse(clc2.isPassivation());
assertTrue(clc2.isShared());
-
+
List<IndividualCacheLoaderConfig> clcs1 = clc1.getIndividualCacheLoaderConfigs();
List<IndividualCacheLoaderConfig> clcs2 = clc2.getIndividualCacheLoaderConfigs();
assertEquals(clcs1.size(), clcs2.size());
@@ -84,12 +87,12 @@
{
compareCacheLoaderConfigs(clcs1.get(i), clcs2.get(i));
}
-
+
RuntimeConfig rc1 = c.getRuntimeConfig();
RuntimeConfig rc2 = clone.getRuntimeConfig();
assertFalse(rc1 == rc2);
assertEquals(rc1, rc2);
-
+
}
catch (CloneNotSupportedException e)
{
@@ -99,31 +102,31 @@
}
private void compareEvictionRegionConfigs(EvictionRegionConfig erc1,
- EvictionRegionConfig erc2)
+ EvictionRegionConfig erc2)
{
assertEquals(erc1.getRegionName(), erc2.getRegionName());
assertEquals(erc1.getRegionFqn(), erc2.getRegionFqn());
assertEquals(erc1.getEventQueueSize(), erc2.getEventQueueSize());
-
+
EvictionPolicyConfig epc1 = erc1.getEvictionPolicyConfig();
EvictionPolicyConfig epc2 = erc2.getEvictionPolicyConfig();
-
+
assertFalse(epc1 == epc2);
assertEquals(epc1, epc2);
}
private void compareCacheLoaderConfigs(IndividualCacheLoaderConfig clc1,
- IndividualCacheLoaderConfig clc2)
+ IndividualCacheLoaderConfig clc2)
{
assertFalse(clc1 == clc2);
assertEquals(clc1, clc2);
-
- Properties p1 = clc1.getProperties();
+
+ Properties p1 = clc1.getProperties();
Properties p2 = clc2.getProperties();
assertFalse(p1 == p2);
assertEquals(p1, p2);
-
- SingletonStoreConfig ssc1 = clc1.getSingletonStoreConfig();
+
+ SingletonStoreConfig ssc1 = clc1.getSingletonStoreConfig();
SingletonStoreConfig ssc2 = clc2.getSingletonStoreConfig();
assertFalse(ssc1 == ssc2);
assertEquals(ssc1, ssc2);
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-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,14 +1,18 @@
package org.jboss.cache.config.parsing;
import org.jboss.cache.Fqn;
-import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.config.MissingPolicyException;
import org.jboss.cache.config.parsing.element.EvictionElementParser;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.MRUConfiguration;
+import org.jboss.cache.eviction.DefaultEvictionActionPolicy;
+import org.jboss.cache.eviction.LFUAlgorithmConfig;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+import org.jboss.cache.eviction.MRUAlgorithmConfig;
+import org.jboss.cache.eviction.NullEvictionAlgorithm;
+import org.jboss.cache.eviction.NullEvictionAlgorithmConfig;
+import org.jboss.cache.eviction.RemoveOnEvictActionPolicy;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -30,20 +34,21 @@
{
String xml =
" <eviction wakeUpInterval=\"5\">\n" +
- " <defaults policyClass=\"org.jboss.cache.eviction.MRUPolicy\"/>\n" +
- " <region name=\"/org/jboss/xyz\" policyClass=\"org.jboss.cache.eviction.MRUPolicy\" eventQueueSize=\"21\">\n" +
+ " <default algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\"/>\n" +
+ " <region name=\"/org/jboss/xyz\" eventQueueSize=\"21\">\n" +
" <attribute name=\"maxNodes\">2103</attribute>\n" +
" <attribute name=\"minTimeToLive\">22</attribute>\n" +
" </region>\n" +
" </eviction>";
EvictionConfig evictionConfig = getEvictionConfig(xml);
- assert evictionConfig.getDefaultEventQueueSize() == EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+ assert evictionConfig.getDefaultEvictionRegionConfig().getEventQueueSize() == EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+ assert evictionConfig.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
}
/**
- * test an happy flow.
+ * test unnecessary attributes
*/
- public void testNormalConfig()
+ public void testUnnecessaryAttributes()
{
String xml =
" <eviction wakeUpInterval=\"5\" defaultPolicyClass=\"org.jboss.cache.eviction.MRUPolicy\" defaultEventQueueSize=\"123456\">\n" +
@@ -51,11 +56,35 @@
" <attribute name=\"maxNodes\">6</attribute>\n" +
" <attribute name=\"minTimeToLive\">7</attribute>\n" +
" </default>\n" +
+ " </eviction>";
+ try
+ {
+ EvictionConfig config = getEvictionConfig(xml);
+ assert false : "Should throw ConfigurationException!";
+ }
+ catch (ConfigurationException good)
+ {
+ // expected
+ }
+ }
+
+
+ /**
+ * test an happy flow.
+ */
+ public void testNormalConfig()
+ {
+ String xml =
+ " <eviction wakeUpInterval=\"5\">\n" +
+ " <default algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\" eventQueueSize=\"123456\">\n" +
+ " <attribute name=\"maxNodes\">6</attribute>\n" +
+ " <attribute name=\"minTimeToLive\">7</attribute>\n" +
+ " </default>\n" +
" <region name=\"/org/jboss/data\">\n" +
" <attribute name=\"minTimeToLive\">1002</attribute>\n" +
" <attribute name=\"maxNodes\">2021</attribute>\n" +
" </region>\n" +
- " <region name=\"/org/jboss/xyz\" policyClass=\"org.jboss.cache.eviction.LRUPolicy\" eventQueueSize=\"21\">\n" +
+ " <region name=\"/org/jboss/xyz\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\" eventQueueSize=\"21\">\n" +
" <attribute name=\"maxNodes\">2103</attribute>\n" +
" <attribute name=\"timeToLive\">22</attribute>\n" +
" </region>\n" +
@@ -63,39 +92,41 @@
EvictionConfig config = getEvictionConfig(xml);
//tests the defaults
assert config.getWakeupInterval() == 5;
- assert config.getDefaultEvictionPolicyClass().equals("org.jboss.cache.eviction.MRUPolicy");
- assert config.getDefaultEventQueueSize() == 123456;
- assert config.getEvictionRegionConfigs().size() == 3;
+ assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig;
+ assert config.getDefaultEvictionRegionConfig().getEventQueueSize() == 123456;
+ assert config.getEvictionRegionConfigs().size() == 2;
//test first region config
- EvictionRegionConfig erConfig1 = config.getEvictionRegionConfigs().get(0);
+ EvictionRegionConfig erConfig1 = config.getDefaultEvictionRegionConfig();
erConfig1.getRegionFqn().equals(Fqn.ROOT);
- MRUConfiguration defaultPolicyonfig = (MRUConfiguration) erConfig1.getEvictionPolicyConfig();
- assert defaultPolicyonfig.getMaxNodes() == 6;
- assert defaultPolicyonfig.getMinTimeToLive() == 7;
+ MRUAlgorithmConfig defaultPolicyConfig = (MRUAlgorithmConfig) erConfig1.getEvictionAlgorithmConfig();
+ assert defaultPolicyConfig.getMaxNodes() == 6;
+ assert defaultPolicyConfig.getMinTimeToLive() == 7;
//test second region config
- EvictionRegionConfig erConfig2 = config.getEvictionRegionConfigs().get(1);
- assert erConfig2.getEventQueueSize() == 123456;
+ EvictionRegionConfig erConfig2 = config.getEvictionRegionConfigs().get(0);
+ assert erConfig2.getEventQueueSize() == 123456 : "Got " + erConfig2.getEventQueueSize();
assert erConfig2.getRegionFqn().equals(Fqn.fromString("/org/jboss/data"));
- MRUConfiguration mruConfiguration = (MRUConfiguration) erConfig2.getEvictionPolicyConfig();
+ MRUAlgorithmConfig mruConfiguration = (MRUAlgorithmConfig) erConfig2.getEvictionAlgorithmConfig();
assert mruConfiguration.getMinTimeToLive() == 1002;
assert mruConfiguration.getMaxNodes() == 2021;
//test 3rd region config
- EvictionRegionConfig erConfig3 = config.getEvictionRegionConfigs().get(2);
+ EvictionRegionConfig erConfig3 = config.getEvictionRegionConfigs().get(1);
assert erConfig3.getEventQueueSize() == 21;
assert erConfig3.getRegionFqn().equals(Fqn.fromString("/org/jboss/xyz"));
- LRUConfiguration lruConfiguration = (LRUConfiguration) erConfig3.getEvictionPolicyConfig();
+ LRUAlgorithmConfig lruConfiguration = (LRUAlgorithmConfig) erConfig3.getEvictionAlgorithmConfig();
assert lruConfiguration.getTimeToLive() == 22;
assert lruConfiguration.getMaxNodes() == 2103;
+
+ assert config.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
}
public void testLruConfig()
{
String xml =
- " <eviction wakeUpInterval=\"45000\" defaultPolicyClass=\"org.jboss.cache.eviction.LRUPolicy\" defaultEventQueueSize=\"4\">\n" +
- " <default>\n" +
+ " <eviction wakeUpInterval=\"45000\">\n" +
+ " <default algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\" eventQueueSize=\"4\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLive\">1000000</attribute>\n" +
" <attribute name=\"maxAge\">15000</attribute>\n" +
@@ -114,10 +145,11 @@
" </region>\n" +
" </eviction>";
EvictionConfig evConfig = getEvictionConfig(xml);
- EvictionRegionConfig evictionRegionConfig = evConfig.getEvictionRegionConfigs().get(0);
- assert evictionRegionConfig.getRegionName().equals(RegionManagerImpl.DEFAULT_REGION.toString());
- assert evictionRegionConfig.getRegionName().equals(RegionManagerImpl.DEFAULT_REGION.toString());
- assert ((LRUConfiguration) evictionRegionConfig.getEvictionPolicyConfig()).getTimeToLive() == 1000000;
+ EvictionRegionConfig evictionRegionConfig = evConfig.getDefaultEvictionRegionConfig();
+ assert evictionRegionConfig.getRegionName().equals(Fqn.ROOT.toString()) : "Was " + evictionRegionConfig.getRegionName();
+ assert ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive() == 1000000;
+
+ assert evConfig.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
}
/**
@@ -126,8 +158,8 @@
public void testMissingWakeUpInterval() throws Exception
{
String xml =
- " <eviction defaultPolicyClass=\"org.jboss.cache.eviction.LRUPolicy\" defaultEventQueueSize=\"200000\">\n" +
- " <default>\n" +
+ " <eviction>\n" +
+ " <default algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\" eventQueueSize=\"200000\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLive\">1000</attribute>\n" +
" </default>\n" +
@@ -153,8 +185,8 @@
public void testMissingPolicyOnRegion()
{
String xml =
- " <eviction defaultEventQueueSize=\"200000\" wakeUpInterval=\"5000\">\n" +
- " <region name=\"/org/jboss/data\">\n" +
+ " <eviction wakeUpInterval=\"5000\">\n" +
+ " <region name=\"/org/jboss/data\" eventQueueSize=\"5\">\n" +
" <attribute name=\"timeToLive\">1002</attribute>\n" +
" </region>\n" +
" </eviction>";
@@ -169,6 +201,22 @@
}
}
+ /**
+ * Same as above, except no queue size is specified. SHould NOT fail.
+ */
+ public void testMissingQueueSizeOnRegion()
+ {
+ String xml =
+ " <eviction wakeUpInterval=\"5000\">\n" +
+ " <region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\">\n" +
+ " <attribute name=\"timeToLive\">1002</attribute>\n" +
+ " </region>\n" +
+ " </eviction>";
+ EvictionConfig ec = getEvictionConfig(xml);
+ assert ec.getEvictionRegionConfigs().get(0).getEventQueueSize() == EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+ }
+
+
private EvictionConfig getEvictionConfig(String xml)
{
Element el;
@@ -191,7 +239,7 @@
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLive\">1000</attribute>\n" +
" </default>\n" +
- " <region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.LFUPolicy\">\n" +
+ " <region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.LFUAlgorithm\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"minNodes\">1000</attribute>\n" +
" </region>\n" +
@@ -199,11 +247,49 @@
try
{
getEvictionConfig(xml);
- assert false : " excewption expectecd as root does not have a eviction policy defined";
+ assert false : " exception expected as default element does not have a eviction policy defined";
}
catch (MissingPolicyException e)
{
//expected
}
}
+
+ public void testDifferentEvictionActionPolicyClasses() throws Exception
+ {
+ String xml =
+ " <eviction wakeUpInterval=\"5000\">\n" +
+ " <default algorithmClass=\"" + NullEvictionAlgorithm.class.getName() + "\" actionPolicyClass=\"" + RemoveOnEvictActionPolicy.class.getName() + "\">\n" +
+ " </default>\n" +
+ " <region name=\"/one\" algorithmClass=\"org.jboss.cache.eviction.LFUAlgorithm\">\n" +
+ " <attribute name=\"maxNodes\">5000</attribute>\n" +
+ " <attribute name=\"minNodes\">1000</attribute>\n" +
+ " </region>\n" +
+ " <region name=\"/two\" actionPolicyClass=\"" + DefaultEvictionActionPolicy.class.getName() + "\">\n" +
+ " </region>\n" +
+ " </eviction>";
+ EvictionConfig config = getEvictionConfig(xml);
+
+ // default region
+ assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig() instanceof NullEvictionAlgorithmConfig;
+ assert config.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(RemoveOnEvictActionPolicy.class.getName());
+
+ // region /one
+ assert findRegionConfig(config, "/one").getEvictionAlgorithmConfig() instanceof LFUAlgorithmConfig;
+ assert findRegionConfig(config, "/one").getEvictionActionPolicyClassName().equals(RemoveOnEvictActionPolicy.class.getName());
+
+ // region /two
+ assert findRegionConfig(config, "/two").getEvictionAlgorithmConfig() instanceof NullEvictionAlgorithmConfig;
+ assert findRegionConfig(config, "/two").getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
+ }
+
+ private EvictionRegionConfig findRegionConfig(EvictionConfig evictionConfig, String fqn)
+ {
+ for (EvictionRegionConfig erc : evictionConfig.getEvictionRegionConfigs())
+ {
+ if (erc.getRegionFqn().equals(Fqn.fromString(fqn))) return erc;
+ }
+
+ return null;
+ }
}
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-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -9,8 +9,8 @@
import org.jboss.cache.config.OldFileFormatException;
import org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor;
import org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.MRUConfiguration;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+import org.jboss.cache.eviction.MRUAlgorithmConfig;
import org.jboss.cache.lock.IsolationLevel;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -202,7 +202,7 @@
{
EvictionConfig evictionConfig = config.getEvictionConfig();
assert "org.jboss.cache.eviction.LRUPolicy".equals(evictionConfig.getDefaultEvictionPolicyClass());
- assert 200000 == evictionConfig.getDefaultEventQueueSize();
+ assert 200000 == evictionConfig.getDefaultEvictionRegionConfig().getEventQueueSize();
assert 5 == evictionConfig.getWakeupInterval();
List<EvictionRegionConfig> regionConfigs = evictionConfig.getEvictionRegionConfigs();
@@ -210,20 +210,20 @@
EvictionRegionConfig first = regionConfigs.get(0);
assert first.getRegionName().equals("/_default_");
- assert first.getEvictionPolicyConfig() instanceof LRUConfiguration;
- LRUConfiguration firstConfiguration = (LRUConfiguration) first.getEvictionPolicyConfig();
+ assert first.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig;
+ LRUAlgorithmConfig firstConfiguration = (LRUAlgorithmConfig) first.getEvictionAlgorithmConfig();
assert firstConfiguration.getMaxAge() <= 0;
assert firstConfiguration.getTimeToLive() == 1000;
assert firstConfiguration.getMaxNodes() == 5000;
EvictionRegionConfig second = regionConfigs.get(1);
- LRUConfiguration secondConfiguration = (LRUConfiguration) second.getEvictionPolicyConfig();
+ LRUAlgorithmConfig secondConfiguration = (LRUAlgorithmConfig) second.getEvictionAlgorithmConfig();
assert secondConfiguration.getMaxAge() == 0;
assert secondConfiguration.getTimeToLive() == 1002;
assert secondConfiguration.getMaxNodes() == 0;
EvictionRegionConfig third = regionConfigs.get(2);
- MRUConfiguration thirdConfiguration = (MRUConfiguration) third.getEvictionPolicyConfig();
+ MRUAlgorithmConfig thirdConfiguration = (MRUAlgorithmConfig) third.getEvictionAlgorithmConfig();
assert thirdConfiguration.getMaxNodes() == 2103;
assert thirdConfiguration.getMinTimeToLive() == 22;
assert third.getEventQueueSize() == 21;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -23,14 +23,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import static org.testng.AssertJUnit.fail;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -59,7 +61,7 @@
public void setUp() throws Exception
{
RegionManagerImpl rmi = new RegionManagerImpl();
- rmi.injectDependencies(null, null, null, null, null, new RegionRegistry());
+ rmi.injectDependencies(null, new Configuration(), null, null, null, new RegionRegistry());
regionManager = rmi;
}
@@ -71,16 +73,16 @@
BaseEvictionAlgorithm algorithm = new MockEvictionAlgorithm(recycleQueueCapacity);
Region region = regionManager.getRegion("/a/b/c", true);
- region.setEvictionPolicy(new MockEvictionPolicyConfig());
+ region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFqn(), new MockEvictionAlgorithmConfig()));
for (int i = 0; i < (recycleQueueCapacity + 1); i++)
{
Fqn fqn = Fqn.fromString("/a/b/c/" + Integer.toString(i + 1));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
}
ExecutorService executor = Executors.newSingleThreadExecutor();
- Future<Void> future = executor.submit(new ProcessEvictionRegion(region, algorithm));
+ Future<Void> future = executor.submit(new ProcessEvictionRegion((RegionImpl) region, algorithm));
try
{
@@ -103,13 +105,21 @@
public static class MockEvictionAlgorithm extends BaseEvictionAlgorithm
{
- public MockEvictionAlgorithm(int recycleQueueCapacity)
+ private static MockEvictionAlgorithm singleton;
+
+ private MockEvictionAlgorithm(int recycleQueueCapacity)
{
recycleQueue = new LinkedBlockingQueue<Fqn>(recycleQueueCapacity);
+ singleton = this;
}
+ public static MockEvictionAlgorithm getInstance()
+ {
+ return singleton;
+ }
+
@Override
- protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ protected EvictionQueue setupEvictionQueue() throws EvictionException
{
return new LRUQueue();
}
@@ -121,60 +131,42 @@
return true;
}
- }
-
- public static class MockEvictionPolicy extends BaseEvictionPolicy
- {
-
- @Override
- public void evict(Fqn fqn) throws Exception
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
{
- throw new Exception("Unable to evict");
- }
-
- @Override
- public void setCache(CacheSPI cache)
- {
- /* no op */
- }
-
- public EvictionAlgorithm getEvictionAlgorithm()
- {
return null;
}
-
- public Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass()
- {
- return MockEvictionPolicyConfig.class;
- }
}
- public static class MockEvictionPolicyConfig implements EvictionPolicyConfig
+ public static class MockEvictionAlgorithmConfig implements EvictionAlgorithmConfig
{
-
- public String getEvictionPolicyClass()
+ public void reset()
{
- return MockEvictionPolicy.class.getName();
+ /* no op */
}
- public void reset()
+ public String getEvictionAlgorithmClassName()
{
- /* no op */
+ return MockEvictionAlgorithm.class.getName();
}
public void validate() throws ConfigurationException
{
/* no op */
}
+
+ public EvictionAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (EvictionAlgorithmConfig) super.clone();
+ }
}
public class ProcessEvictionRegion implements Callable<Void>
{
- private Region region;
+ private RegionImpl region;
private EvictionAlgorithm algorithm;
- public ProcessEvictionRegion(Region region, EvictionAlgorithm algorithm)
+ public ProcessEvictionRegion(RegionImpl region, EvictionAlgorithm algorithm)
{
this.region = region;
this.algorithm = algorithm;
@@ -184,7 +176,7 @@
{
try
{
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
}
catch (EvictionException e)
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -16,6 +16,7 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.fail;
@@ -24,8 +25,6 @@
import org.testng.annotations.Test;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Properties;
/**
@@ -37,8 +36,8 @@
@Test(groups = {"functional"})
public class ConcurrentEvictionTest
{
- private Cache<Integer, String> cache_;
- private long wakeupIntervalMillis_ = 0;
+ private Cache<Integer, String> cache;
+ private long wakeupIntervalMillis = 0;
private String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
private String cacheLoaderDir = "/JBossCacheFileCacheLoader";
@@ -46,10 +45,10 @@
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupInterval();
- if (wakeupIntervalMillis_ < 0)
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
+ if (wakeupIntervalMillis < 0)
{
- fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
+ fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
}
}
@@ -61,8 +60,8 @@
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
conf.setEvictionConfig(buildEvictionConfig());
conf.setCacheLoaderConfig(buildCacheLoaderConfig());
- conf.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache_ = factory.createCache(conf, true);// read in generic local xml
+ conf.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache = factory.createCache(conf, true);// read in generic local xml
}
private CacheLoaderConfig buildCacheLoaderConfig()
@@ -86,23 +85,19 @@
private EvictionConfig buildEvictionConfig()
{
- EvictionConfig ec = new EvictionConfig("org.jboss.cache.eviction.LRUPolicy");
- ec.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy");
- ec.setWakeupInterval(5000);
-
- EvictionRegionConfig erc = UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("_default_", 5000, 1000000);
- List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
- erConfigs.add(erc);
- ec.setEvictionRegionConfigs(erConfigs);
- return ec;
+ return new EvictionConfig(
+ new EvictionRegionConfig(
+ Fqn.ROOT,
+ new LRUAlgorithmConfig(1000000, 5000)
+ ),
+ 5000);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
TestingUtil.recursiveFileRemove(tmpDir + cacheLoaderDir);
- cache_.stop();
- cache_ = null;
+ TestingUtil.killCaches(cache);
}
public void testConcurrentEviction() throws Exception
@@ -113,11 +108,11 @@
// region's maxNodes so we know eviction will kick in
for (int i = 0; i < 1000; i++)
{
- cache_.put(Fqn.fromRelativeElements(base, i / 100), i, "value");
+ cache.put(Fqn.fromRelativeElements(base, i / 100), i, "value");
}
// Loop for long enough to have 5 runs of the eviction thread
- long loopDone = System.currentTimeMillis() + (5 * wakeupIntervalMillis_);
+ long loopDone = System.currentTimeMillis() + (5 * wakeupIntervalMillis);
while (System.currentTimeMillis() < loopDone)
{
// If any get returns null, that's a failure
@@ -126,7 +121,7 @@
Fqn fqn = Fqn.fromRelativeElements(base, i / 100);
Integer key = i;
assertNotNull("found value under Fqn " + fqn + " and key " + key,
- cache_.get(fqn, key));
+ cache.get(fqn, key));
}
}
}
Deleted: core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionConfiguration.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionConfiguration.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionConfiguration.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,41 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.eviction;
-
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionPolicyConfig;
-
-
-/**
- * @author Daniel Huang (dhuang(a)jboss.org)
- * @version $Revision$
- */
-public class DummyEvictionConfiguration implements EvictionPolicyConfig, Cloneable
-{
- public String getEvictionPolicyClass()
- {
- return DummyEvictionPolicy.class.getName();
- }
-
- public void validate() throws ConfigurationException
- {
- // no-op
- }
-
- public void reset()
- {
- // no-op
- }
-
- @Override
- public DummyEvictionConfiguration clone() throws CloneNotSupportedException
- {
- return (DummyEvictionConfiguration) super.clone();
- }
-
-
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPolicy.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPolicy.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPolicy.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,40 +0,0 @@
-package org.jboss.cache.eviction;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.EvictionPolicyConfig;
-
-/**
- * @author Ben Feb 13, 2004
- */
-public class DummyEvictionPolicy extends BaseEvictionPolicy
-{
- public void evict(Fqn fqn) throws Exception
- {
- // no-op
-// throw new RuntimeException("Testing only");
- }
-
- public int getWakeupIntervalSeconds()
- {
- return 0; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setCache(CacheSPI cache)
- {
- // no op
- }
-
- public EvictionAlgorithm getEvictionAlgorithm()
- {
- // no op
- return null;
- }
-
- public Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass()
- {
- return null;
- }
-
-
-}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,16 +1,12 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
package org.jboss.cache.eviction;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
+import org.jboss.cache.config.EvictionRegionConfig;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -33,34 +29,35 @@
algo = new ElementSizeAlgorithm();
regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
- ElementSizeConfiguration config = new ElementSizeConfiguration();
+ ElementSizeAlgorithmConfig config = new ElementSizeAlgorithmConfig();
// We have to setCache maxElementsPerNode!!
config.setMaxElementsPerNode(0);
- config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
- regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
+// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
+ Region r = regionManager.getRegion("/a/b", true);
+ r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), config));
}
public void testMaxElements() throws Exception
{
- Region region = regionManager.getRegion("/a/b", true);
- ElementSizeConfiguration config = (ElementSizeConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ ElementSizeAlgorithmConfig config = (ElementSizeAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(10);
config.setMaxElementsPerNode(6);
for (int i = 0; i < 10; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
if (i % 2 == 0)
{
for (int k = 0; k < i; k++)
{
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_ELEMENT_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_ELEMENT_EVENT);
}
}
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
ElementSizeQueue queue = (ElementSizeQueue) algo.evictionQueue;
assertEquals(9, algo.getEvictionQueue().getNumberOfNodes());
@@ -86,34 +83,34 @@
for (int i = 0; i < 7; i++)
{
- region.putNodeEvent(new EvictedEventNode(Fqn.fromString("/a/b/9"), NodeEventType.ADD_ELEMENT_EVENT));
- region.putNodeEvent(new EvictedEventNode(Fqn.fromString("/a/b/7"), NodeEventType.ADD_ELEMENT_EVENT));
+ region.registerEvictionEvent(Fqn.fromString("/a/b/9"), EvictionEvent.Type.ADD_ELEMENT_EVENT);
+ region.registerEvictionEvent(Fqn.fromString("/a/b/7"), EvictionEvent.Type.ADD_ELEMENT_EVENT);
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
assertEquals(7, queue.getNumberOfNodes());
}
public void testMaxNodesAndMaxElements() throws Exception
{
- Region region = regionManager.getRegion("/a/b", true);
- ElementSizeConfiguration config = (ElementSizeConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ ElementSizeAlgorithmConfig config = (ElementSizeAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(10);
config.setMaxElementsPerNode(100);
for (int i = 0; i < 20; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
for (int k = 0; k < i; k++)
{
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_ELEMENT_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_ELEMENT_EVENT);
}
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
ElementSizeQueue queue = (ElementSizeQueue) algo.evictionQueue;
assertEquals(10, algo.getEvictionQueue().getNumberOfNodes());
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,32 +6,30 @@
*/
package org.jboss.cache.eviction;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
-
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
+
/**
* @author Daniel Huang
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = "unit", sequential = false)
public class ElementSizeConfigurationTest
{
public void testXMLParse1() throws Exception
{
- ElementSizeConfiguration config = new ElementSizeConfiguration();
+ ElementSizeAlgorithmConfig config = new ElementSizeAlgorithmConfig();
String xml = "<region name=\"abc\">" +
- "<attribute name=\"maxNodes\">1000</attribute>" +
- "<attribute name=\"maxElementsPerNode\">100</attribute>" +
- "</region>";
+ "<attribute name=\"maxNodes\">1000</attribute>" +
+ "<attribute name=\"maxElementsPerNode\">100</attribute>" +
+ "</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(100, config.getMaxElementsPerNode());
assertEquals(1000, config.getMaxNodes());
@@ -40,15 +38,15 @@
public void testXMLParse2() throws Exception
{
- ElementSizeConfiguration config = new ElementSizeConfiguration();
+ ElementSizeAlgorithmConfig config = new ElementSizeAlgorithmConfig();
String xml = "<region name=\"abc\">" +
- "<attribute name=\"maxNodes\">1000</attribute>" +
- "</region>";
+ "<attribute name=\"maxNodes\">1000</attribute>" +
+ "</region>";
Element element = XmlConfigHelper.stringToElement(xml);
try
{
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
}
catch (ConfigurationException ce)
{
@@ -62,14 +60,14 @@
public void testXMLParse3() throws Exception
{
- ElementSizeConfiguration config = new ElementSizeConfiguration();
+ ElementSizeAlgorithmConfig config = new ElementSizeAlgorithmConfig();
String xml = "<region name=\"abc\">" +
- "<attribute name=\"maxElementsPerNode\">100</attribute>" +
- "</region>";
+ "<attribute name=\"maxElementsPerNode\">100</attribute>" +
+ "</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(100, config.getMaxElementsPerNode());
assertEquals(0, config.getMaxNodes());
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -16,14 +16,12 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Daniel Huang
* @version $Revison: $
@@ -56,36 +54,18 @@
void initCaches() throws Exception
{
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
- EvictionConfig evConfig = conf.getEvictionConfig();
- evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.ElementSizePolicy");
- evConfig.setWakeupInterval(3000);
+ EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new ElementSizeAlgorithmConfig(5000, 100)), 3000);
evConfig.setDefaultEventQueueSize(200000);
-
- List<EvictionRegionConfig> regionConfigs = new ArrayList<EvictionRegionConfig>();
- regionConfigs.add(createEvictionRegionConfig("_default_", 5000, 100));
- regionConfigs.add(createEvictionRegionConfig("/org/jboss/data", 10, 20));
- regionConfigs.add(createEvictionRegionConfig("/org/jboss/test/data", -1, 5));
- regionConfigs.add(createEvictionRegionConfig("/test/", 5000, 1));
-
- evConfig.setEvictionRegionConfigs(regionConfigs);
-
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/data"), new ElementSizeAlgorithmConfig(10, 20)));
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new ElementSizeAlgorithmConfig(-1, 5)));
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/test/"), new ElementSizeAlgorithmConfig(5000, 1)));
+ conf.setEvictionConfig(evConfig);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf, false);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.start();
}
- private EvictionRegionConfig createEvictionRegionConfig(String regionName, int maxNodes, int maxElementsPerNode)
- {
- EvictionRegionConfig ercDefault = new EvictionRegionConfig();
- ercDefault.setRegionName(regionName);
- ElementSizeConfiguration esConfig = new ElementSizeConfiguration();
- if (maxNodes >= 0) esConfig.setMaxNodes(maxNodes);
- if (maxElementsPerNode >= 0) esConfig.setMaxElementsPerNode(maxElementsPerNode);
- ercDefault.setEvictionPolicyConfig(esConfig);
- return ercDefault;
- }
-
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -11,8 +11,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.Test;
@@ -23,166 +24,163 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = "unit", sequential = false)
public class EvictionConfigurationTest
{
- CacheSPI<Object, Object> cache;
- RegionManager regionManager;
-
public void testPolicyPerRegion() throws Exception
{
- this.setupCache("configs/policyPerRegion-eviction.xml");
- assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
+ CacheSPI<Object, Object> cache = null;
+ RegionManager regionManager = null;
+ try
+ {
+ cache = setupCache("configs/policyPerRegion-eviction.xml");
+ regionManager = cache.getRegionManager();
+ assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
- Region region = regionManager.getRegion("/org/jboss/data", true);
- EvictionPolicy policy = region.getEvictionPolicy();
- EvictionPolicyConfig configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/org/jboss/data"), region.getFqn());
- assertTrue(policy instanceof LFUPolicy);
- assertTrue(configuration instanceof LFUConfiguration);
- assertEquals(5000, ((LFUConfiguration) configuration).getMaxNodes());
- assertEquals(1000, ((LFUConfiguration) configuration).getMinNodes());
+ Region region = regionManager.getRegion("/org/jboss/data", true);
+ EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/org/jboss/data"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LFUAlgorithmConfig);
+ assertEquals(5000, ((LFUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(1000, ((LFUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMinNodes());
- region = regionManager.getRegion("/org/jboss/test/data", true);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/org/jboss/test/data"), region.getFqn());
- assertTrue(policy instanceof FIFOPolicy);
- assertTrue(configuration instanceof FIFOConfiguration);
- assertEquals(5, ((FIFOConfiguration) configuration).getMaxNodes());
+ region = regionManager.getRegion("/org/jboss/test/data", true);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/org/jboss/test/data"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmConfig);
+ assertEquals(5, ((FIFOAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
- region = regionManager.getRegion("/test", true);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/test"), region.getFqn());
- assertTrue(policy instanceof MRUPolicy);
- assertTrue(configuration instanceof MRUConfiguration);
- assertEquals(10000, ((MRUConfiguration) configuration).getMaxNodes());
+ region = regionManager.getRegion("/test", true);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/test"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig);
+ assertEquals(10000, ((MRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
- region = regionManager.getRegion("/maxAgeTest", true);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/maxAgeTest"), region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive());
- assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge());
+ region = regionManager.getRegion("/maxAgeTest", true);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/maxAgeTest"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
+ assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
- // test the default region. use a region name that isn't defined explicitly in conf file.
- region = regionManager.getRegion("/a/b/c", false);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.ROOT, region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
- assertEquals(0, ((LRUConfiguration) configuration).getMaxAge());
+ // test the default region. use a region name that isn't defined explicitly in conf file.
+ region = regionManager.getRegion("/a/b/c", false);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.ROOT, region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
+ assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
- cache.stop();
+ }
+ finally
+ {
+ TestingUtil.killCaches(cache);
+ }
}
public void testMixedPolicies() throws Exception
{
- this.setupCache("configs/mixedPolicy-eviction.xml");
- assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
+ CacheSPI<Object, Object> cache = null;
+ RegionManager regionManager = null;
- Region region = regionManager.getRegion("/org/jboss/data", true);
- EvictionPolicy policy = region.getEvictionPolicy();
- EvictionPolicyConfig configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
- assertTrue(policy instanceof FIFOPolicy);
- assertTrue(configuration instanceof FIFOConfiguration);
- assertEquals(5000, ((FIFOConfiguration) configuration).getMaxNodes());
+ try
+ {
+ cache = setupCache("configs/mixedPolicy-eviction.xml");
+ regionManager = cache.getRegionManager();
+ assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
- region = regionManager.getRegion("/test", true);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/test/"), region.getFqn());
- assertTrue(policy instanceof MRUPolicy);
- assertTrue(configuration instanceof MRUConfiguration);
- assertEquals(10000, ((MRUConfiguration) configuration).getMaxNodes());
+ Region region = regionManager.getRegion("/org/jboss/data", true);
+ EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmConfig);
+ assertEquals(5000, ((FIFOAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
- // test the default region. use a region name that isn't defined explicitly in conf file.
- region = regionManager.getRegion("/a/b/c", false);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.ROOT, region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
- assertEquals(0, ((LRUConfiguration) configuration).getMaxAge());
+ region = regionManager.getRegion("/test", true);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/test/"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig);
+ assertEquals(10000, ((MRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
- region = regionManager.getRegion("/maxAgeTest", false);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive());
- assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge());
+ // test the default region. use a region name that isn't defined explicitly in conf file.
+ region = regionManager.getRegion("/a/b/c", false);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.ROOT, region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
+ assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
- cache.stop();
+ region = regionManager.getRegion("/maxAgeTest", false);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
+ assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
+
+ }
+ finally
+ {
+ TestingUtil.killCaches(cache);
+ }
}
public void testLegacyPolicyConfiguration() throws Exception
{
- this.setupCache("configs/local-lru-eviction.xml");
- assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
+ CacheSPI<Object, Object> cache = null;
+ RegionManager regionManager = null;
- Region region = regionManager.getRegion("/org/jboss/data", false);
- EvictionPolicy policy = region.getEvictionPolicy();
- EvictionPolicyConfig configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
+ try
+ {
+ cache = setupCache("configs/local-lru-eviction.xml");
+ regionManager = cache.getRegionManager();
+ assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
- region = regionManager.getRegion("/org/jboss/test/data", false);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/org/jboss/test/data/"), region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(5, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(4000, ((LRUConfiguration) configuration).getTimeToLive());
+ Region region = regionManager.getRegion("/org/jboss/data", false);
+ EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
- region = regionManager.getRegion("/test", true);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/test/"), region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(4000, ((LRUConfiguration) configuration).getTimeToLive());
+ region = regionManager.getRegion("/org/jboss/test/data", false);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/org/jboss/test/data/"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(5, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
- region = regionManager.getRegion("/maxAgeTest", true);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive());
- assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge());
+ region = regionManager.getRegion("/test", true);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/test/"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
- // test the default region. use a region name that isn't defined explicitly in conf file.
- region = regionManager.getRegion("/a/b/c", false);
- policy = region.getEvictionPolicy();
- configuration = region.getEvictionPolicyConfig();
- assertEquals(Fqn.ROOT, region.getFqn());
- assertTrue(policy instanceof LRUPolicy);
- assertTrue(configuration instanceof LRUConfiguration);
- assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
- assertEquals(0, ((LRUConfiguration) configuration).getMaxAge());
+ region = regionManager.getRegion("/maxAgeTest", true);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
+ assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
- cache.stop();
+ // test the default region. use a region name that isn't defined explicitly in conf file.
+ region = regionManager.getRegion("/a/b/c", false);
+ evictionRegionConfig = region.getEvictionRegionConfig();
+ assertEquals(Fqn.ROOT, region.getFqn());
+ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
+ assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
+ assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
+ assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
+ }
+ finally
+ {
+ TestingUtil.killCaches(cache);
+ }
}
public void testTwoCacheInstanceConfiguration() throws Exception
@@ -193,17 +191,27 @@
public void testNoEviction() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
- regionManager = cache.getRegionManager();
- assertEquals(0, regionManager.getAllRegions(Region.Type.ANY).size());
+ CacheSPI<Object, Object> cache = null;
+ RegionManager regionManager = null;
+
+ try
+ {
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ regionManager = cache.getRegionManager();
+ assertEquals(0, regionManager.getAllRegions(Region.Type.ANY).size());
+ }
+ finally
+ {
+ TestingUtil.killCaches(cache);
+ }
}
- private void setupCache(String configurationName)
+ private CacheSPI<Object, Object> setupCache(String configurationName)
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(configurationName, false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(configurationName, false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.start();
- regionManager = cache.getRegionManager();
+ return cache;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -14,7 +14,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -22,7 +22,7 @@
import org.testng.annotations.Test;
/**
- * Unit tests for {@link ExpirationPolicy}.
+ * Unit tests for {@link org.jboss.cache.eviction.ExpirationAlgorithm}.
*
* @author Elias Ross
* @version $Revision$
@@ -46,7 +46,9 @@
public void setUp() throws Exception
{
Configuration conf = new Configuration();
- EvictionConfig econf = new EvictionConfig(ExpirationPolicy.class.getName());
+ ExpirationAlgorithmConfig eAC = new ExpirationAlgorithmConfig();
+ EvictionRegionConfig eRC = new EvictionRegionConfig(Fqn.ROOT, eAC);
+ EvictionConfig econf = new EvictionConfig(eRC);
econf.setWakeupInterval(1000);
conf.setEvictionConfig(econf);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf, false);
@@ -64,9 +66,9 @@
public void testEviction() throws Exception
{
- cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
- cache.put(fqn2, ExpirationConfiguration.EXPIRATION_KEY, past);
- cache.put(fqn3, ExpirationConfiguration.EXPIRATION_KEY, future);
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ cache.put(fqn2, ExpirationAlgorithmConfig.EXPIRATION_KEY, past);
+ cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
cache.put(fqn4, "foo", "bar");
TestingUtil.sleepThread(2000);
assertNotNull(cache.getNode(fqn1));
@@ -83,10 +85,10 @@
public void testUpdate() throws Exception
{
log.info("update 1 from future to past");
- cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
assertNotNull(cache.getNode(fqn1));
TestingUtil.sleepThread(1500);
- cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, past);
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, past);
TestingUtil.sleepThread(1500);
assertNull(cache.getNode(fqn1));
cache.removeNode(Fqn.ROOT);
@@ -97,10 +99,10 @@
{
log.info("update 1 from future to past");
Long future2 = future + 2000;
- cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
TestingUtil.sleepThread(2000);
assertNotNull(cache.getNode(fqn1));
- cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future2);
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future2);
TestingUtil.sleepThread(3000);
assertNotNull(cache.getNode(fqn1));
TestingUtil.sleepThread(3000);
@@ -111,14 +113,14 @@
public void testMaxNodes() throws Exception
{
log.info("set max nodes to 2, expire soonest to expire first");
- EvictionPolicyConfig epc = cache.getRegionManager().getAllRegions(Region.Type.EVICTION).get(0).getEvictionPolicyConfig();
- ExpirationConfiguration ec = (ExpirationConfiguration) epc;
+ EvictionRegionConfig regionConfig = cache.getRegionManager().getAllRegions(Region.Type.EVICTION).get(0).getEvictionRegionConfig();
+ ExpirationAlgorithmConfig ec = (ExpirationAlgorithmConfig) regionConfig.getEvictionAlgorithmConfig();
ec.setMaxNodes(2);
Long future2 = future + 500;
- cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future2);
- cache.put(fqn2, ExpirationConfiguration.EXPIRATION_KEY, future2);
- cache.put(fqn3, ExpirationConfiguration.EXPIRATION_KEY, future);
- cache.put(fqn4, ExpirationConfiguration.EXPIRATION_KEY, past);
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future2);
+ cache.put(fqn2, ExpirationAlgorithmConfig.EXPIRATION_KEY, future2);
+ cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ cache.put(fqn4, ExpirationAlgorithmConfig.EXPIRATION_KEY, past);
assertEquals(5, cache.getNumberOfNodes());
Thread.sleep(2000);
assertNotNull(cache.getNode(fqn1));
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,9 +8,11 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
+import org.jboss.cache.config.EvictionRegionConfig;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.BeforeMethod;
@@ -35,28 +37,29 @@
public void setUp() throws Exception
{
algo = new FIFOAlgorithm();
- FIFOConfiguration config = new FIFOConfiguration();
+ FIFOAlgorithmConfig config = new FIFOAlgorithmConfig();
// We have to setCache maxNodes!!
config.setMaxNodes(0);
regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
- config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
- regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
+// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
+ Region r = regionManager.getRegion("/a/b", true);
+ r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), config));
}
public void testMaxNodes1() throws Exception
{
- Region region = regionManager.getRegion("/a/b", true);
- FIFOConfiguration config = (FIFOConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ FIFOAlgorithmConfig config = (FIFOAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(5);
for (int i = 0; i < 8; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
FIFOQueue queue = (FIFOQueue) algo.evictionQueue;
assertEquals(5, algo.getEvictionQueue().getNumberOfNodes());
@@ -75,15 +78,15 @@
for (int i = 3; i < 8; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.VISIT_NODE_EVENT);
}
for (int i = 3; i < 5; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.VISIT_NODE_EVENT);
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
assertEquals(5, algo.getEvictionQueue().getNumberOfNodes());
@@ -100,17 +103,17 @@
public void testMaxNodes2() throws Exception
{
- Region region = regionManager.getRegion("/a/b", true);
- FIFOConfiguration config = (FIFOConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ FIFOAlgorithmConfig config = (FIFOAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(50000);
for (int i = 0; i < 50000; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
FIFOQueue queue = (FIFOQueue) algo.evictionQueue;
assertEquals(50000, algo.getEvictionQueue().getNumberOfNodes());
@@ -126,10 +129,10 @@
for (int i = 50000; i < 60000; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
it = queue.iterate();
index = 10000;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,13 +6,10 @@
*/
package org.jboss.cache.eviction;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
-
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -22,20 +19,19 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = "unit", sequential = false)
public class FIFOConfigurationTest
{
-
public void testXMLParse() throws Exception
{
- FIFOConfiguration config = new FIFOConfiguration();
+ FIFOAlgorithmConfig config = new FIFOAlgorithmConfig();
String xml = "<region name=\"abc\">" +
"<attribute name=\"maxNodes\">1000</attribute>" +
"</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(1000, config.getMaxNodes());
@@ -43,7 +39,7 @@
public void testXMLParse2() throws Exception
{
- FIFOConfiguration config = new FIFOConfiguration();
+ FIFOAlgorithmConfig config = new FIFOAlgorithmConfig();
String xml = "<region name=\"abc\">" +
"</region>";
@@ -51,7 +47,7 @@
try
{
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
}
catch (ConfigurationException ce)
{
@@ -63,7 +59,7 @@
public void testXMLParse3() throws Exception
{
- FIFOConfiguration config = new FIFOConfiguration();
+ FIFOAlgorithmConfig config = new FIFOAlgorithmConfig();
String xml = "<region>" +
"<attribute name=\"maxNodes\">1000</attribute>" +
"</region>";
@@ -72,7 +68,7 @@
try
{
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
}
catch (ConfigurationException ce)
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -14,6 +14,7 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.internals.EvictionController;
import static org.testng.AssertJUnit.*;
@@ -21,9 +22,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Unit tests for FIFOPolicy.
*
@@ -58,31 +56,15 @@
void initCaches() throws Exception
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
- EvictionConfig evConfig = config.getEvictionConfig();
- evConfig.setWakeupInterval(3000);
+ EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new FIFOAlgorithmConfig(5000)), 3000);
evConfig.setDefaultEventQueueSize(20000);
- evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.FIFOPolicy");
- List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
- erConfigs.add(createEvictionRegionConfig("/_default_", 5000));
- erConfigs.add(createEvictionRegionConfig("/org/jboss/test/data", 5));
- evConfig.setEvictionRegionConfigs(erConfigs);
- config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new FIFOAlgorithmConfig(5)));
+ config.setEvictionConfig(evConfig);
+ config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config, true);// read in generic local xml
}
-
- private EvictionRegionConfig createEvictionRegionConfig(String regionName, int maxNodes)
- {
- EvictionRegionConfig ercDefault = new EvictionRegionConfig();
- ercDefault.setRegionName(regionName);
- FIFOConfiguration esConfig = new FIFOConfiguration();
- if (maxNodes >= 0) esConfig.setMaxNodes(maxNodes);
- ercDefault.setEvictionPolicyConfig(esConfig);
- return ercDefault;
- }
-
-
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -7,10 +7,12 @@
package org.jboss.cache.eviction;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
+import org.jboss.cache.config.EvictionRegionConfig;
+import static org.jboss.cache.eviction.EvictionEvent.Type.*;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -33,11 +35,10 @@
public void setUp() throws Exception
{
algo = new LFUAlgorithm();
- LFUConfiguration config = new LFUConfiguration();
+ LFUAlgorithmConfig config = new LFUAlgorithmConfig();
regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
- config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
- regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
+ regionManager.getRegion("/a/b", true).setEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/a/b"), config));
// doesn't this need a cache?!?? :-/
}
@@ -45,16 +46,16 @@
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
- Region region = regionManager.getRegion("/a/b", true);
- LFUConfiguration config = new LFUConfiguration();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LFUAlgorithmConfig config = new LFUAlgorithmConfig();
config.setMaxNodes(0);
config.setMinNodes(20);
- region.setEvictionPolicy(config);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFqn(), config));
+ region.registerEvictionEvent(fqn1, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, ADD_NODE_EVENT);
try
{
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
}
catch (EvictionException e)
{
@@ -70,17 +71,17 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LFUConfiguration config = new LFUConfiguration();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LFUAlgorithmConfig config = new LFUAlgorithmConfig();
config.setMaxNodes(1);
config.setMinNodes(20);
- region.setEvictionPolicy(config);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFqn(), config));
+ region.registerEvictionEvent(fqn1, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, ADD_NODE_EVENT);
try
{
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
}
catch (EvictionException e)
{
@@ -89,13 +90,13 @@
}
assertEquals("Queue size should be ", 1, algo.getEvictionQueue().getNumberOfNodes());
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn2, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, ADD_NODE_EVENT);
try
{
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
}
catch (EvictionException e)
{
@@ -105,35 +106,6 @@
assertEquals("Queue size should be ", 1, algo.getEvictionQueue().getNumberOfNodes());
}
- // What's this doing here? This should be a stress test, not a functional test. There are no assertions, for
- // example. :S - Manik, Nov 06
-
- // public void testMaxNode3() throws Exception
- // {
- // Region region = regionManager.getRegion("/a/b", true);
- // LFUConfiguration config = new LFUConfiguration();
- //
- // config.setMaxNodes(15000);
- // config.setMinNodes(15000);
- //
- // region.setEvictionPolicy(config);
- // for (int i = 0; i < 20000; i++)
- // {
- // Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- // region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
- //
- // if ((i % 2) == 0)
- // {
- // region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT));
- // }
- // }
- //
- // algo.invokeRemote(region);
- //// LFUQueue queue = (LFUQueue) algo.evictionQueue;
- //// Iterator it = queue.iterate();
- //
- // }
-
public void testMinNode1() throws Exception
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
@@ -141,18 +113,18 @@
Fqn fqn3 = Fqn.fromString("/a/b/c/d/e");
Fqn fqn4 = Fqn.fromString("/a/b/c/d/e/f");
- Region region = regionManager.getRegion("/a/b", true);
- LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LFUAlgorithmConfig config = (LFUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setMinNodes(2);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn4, ADD_NODE_EVENT);
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 2, algo.getEvictionQueue().getNumberOfNodes());
}
@@ -162,16 +134,16 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
- Region region = regionManager.getRegion("/a/b", true);
- LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LFUAlgorithmConfig config = (LFUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setMinNodes(0);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, ADD_NODE_EVENT);
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 0, algo.getEvictionQueue().getNumberOfNodes());
}
@@ -190,23 +162,23 @@
Fqn fqn10 = Fqn.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m");
- Region region = regionManager.getRegion("/a/b", true);
- LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LFUAlgorithmConfig config = (LFUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setMinNodes(100);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn5, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn6, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn7, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn8, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn9, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn4, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn5, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn6, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn7, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn8, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn9, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn10, ADD_NODE_EVENT);
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
LFUQueue queue = (LFUQueue) algo.evictionQueue;
assertEquals(10, algo.getEvictionQueue().getNumberOfNodes());
Iterator it = queue.iterate();
@@ -219,31 +191,31 @@
}
// fqn1 visited 4 additional times.
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT);
// fqn2 visited 3 additional times.
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn2, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, VISIT_NODE_EVENT);
// fqn3 visited 1 additional time.
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn3, VISIT_NODE_EVENT);
// fqn4 visited 2 additional times.
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn4, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn4, VISIT_NODE_EVENT);
// fqn9 visited 1 additional time.
- region.putNodeEvent(new EvictedEventNode(fqn9, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn9, VISIT_NODE_EVENT);
// fqn10 visited 2 additional times.
- region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn10, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn10, VISIT_NODE_EVENT);
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
System.out.println();
System.out.println();
@@ -282,10 +254,10 @@
Fqn fqn11 = Fqn.fromString("/a");
Fqn fqn12 = Fqn.fromString("/a/b");
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn12, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn11, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn12, ADD_NODE_EVENT);
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
System.out.println();
System.out.println();
@@ -320,12 +292,12 @@
assertEquals(12, algo.getEvictionQueue().getNumberOfNodes());
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.REMOVE_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.REMOVE_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn12, NodeEventType.REMOVE_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.REMOVE_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, REMOVE_NODE_EVENT);
+ region.registerEvictionEvent(fqn11, REMOVE_NODE_EVENT);
+ region.registerEvictionEvent(fqn12, REMOVE_NODE_EVENT);
+ region.registerEvictionEvent(fqn10, REMOVE_NODE_EVENT);
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
System.out.println();
System.out.println();
@@ -357,22 +329,22 @@
assertEquals(8, algo.getEvictionQueue().getNumberOfNodes());
//test add/visit/remove combination
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn11, ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn4, VISIT_NODE_EVENT);
// purposefully revisit a node that has been removed. assert that it is readded.
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT);
+ region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT);
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.REMOVE_NODE_EVENT));
+ region.registerEvictionEvent(fqn3, REMOVE_NODE_EVENT);
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
System.out.println();
System.out.println();
@@ -405,18 +377,18 @@
public void testEvictionQueueSortOrder2() throws Exception
{
- Region region = regionManager.getRegion("/a/b", true);
- LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ EvictionRegionConfig config = region.getEvictionRegionConfig();
- config.setMaxNodes(0);
- config.setMinNodes(10000);
+ ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMaxNodes(0);
+ ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMinNodes(10000);
for (int i = 0; i < 10000; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, ADD_NODE_EVENT);
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
LFUQueue queue = (LFUQueue) algo.evictionQueue;
Iterator it = queue.iterate();
@@ -433,11 +405,11 @@
if ((i % 2) == 0)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn, VISIT_NODE_EVENT);
}
}
- algo.process(region);
+ algo.process(region.getEvictionEventQueue());
it = queue.iterate();
int count = 0;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,10 +6,9 @@
*/
package org.jboss.cache.eviction;
-import static org.testng.AssertJUnit.assertEquals;
-
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -19,22 +18,22 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = "unit", sequential = false)
public class LFUConfigurationTest
{
public void testXMLParsing() throws Exception
{
- LFUConfiguration config = new LFUConfiguration();
+ LFUAlgorithmConfig config = new LFUAlgorithmConfig();
String xml =
"<region name=\"abc\">" +
- "<attribute name=\"minNodes\">10</attribute>" +
- "<attribute name=\"maxNodes\">20</attribute>" +
- "</region>";
+ "<attribute name=\"minNodes\">10</attribute>" +
+ "<attribute name=\"maxNodes\">20</attribute>" +
+ "</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(10, config.getMinNodes());
assertEquals(20, config.getMaxNodes());
@@ -42,14 +41,14 @@
public void testXMLParsing2() throws Exception
{
- LFUConfiguration config = new LFUConfiguration();
+ LFUAlgorithmConfig config = new LFUAlgorithmConfig();
String xml =
"<region name=\"abc\">" +
- "<attribute name=\"minNodes\">10</attribute>" +
- "</region>";
+ "<attribute name=\"minNodes\">10</attribute>" +
+ "</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(10, config.getMinNodes());
assertEquals(0, config.getMaxNodes());
@@ -57,14 +56,14 @@
public void testXMLParsing3() throws Exception
{
- LFUConfiguration config = new LFUConfiguration();
+ LFUAlgorithmConfig config = new LFUAlgorithmConfig();
String xml =
"<region name=\"abc\">" +
- "<attribute name=\"maxNodes\">20</attribute>" +
- "</region>";
+ "<attribute name=\"maxNodes\">20</attribute>" +
+ "</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(0, config.getMinNodes());
assertEquals(20, config.getMaxNodes());
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -20,9 +20,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Unit tests for LFU Policy.
*
@@ -57,31 +54,16 @@
void initCaches() throws Exception
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
- EvictionConfig evConfig = config.getEvictionConfig();
- evConfig.setWakeupInterval(3000);
+ EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new LFUAlgorithmConfig(500, 10)), 3000);
evConfig.setDefaultEventQueueSize(200000);
- List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
- erConfigs.add(createEvictionRegionConfig("/_default_", 500, 10));
- erConfigs.add(createEvictionRegionConfig("/org/jboss/data", 5000, 4000));
- erConfigs.add(createEvictionRegionConfig("/org/jboss/test/data", -1, 5));
- evConfig.setEvictionRegionConfigs(erConfigs);
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/data"), new LFUAlgorithmConfig(5000, 4000)));
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new LFUAlgorithmConfig(-1, 5)));
+ config.setEvictionConfig(evConfig);
config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config, true);
}
- private EvictionRegionConfig createEvictionRegionConfig(String regionName, int maxNodes, int minNodes)
- {
- EvictionRegionConfig ercDefault = new EvictionRegionConfig();
- ercDefault.setRegionName(regionName);
- LFUConfiguration esConfig = new LFUConfiguration();
- if (maxNodes >= 0) esConfig.setMaxNodes(maxNodes);
- if (minNodes >= 0) esConfig.setMinNodes(minNodes);
- ercDefault.setEvictionPolicyConfig(esConfig);
- esConfig.setEvictionPolicyClassName();
- return ercDefault;
- }
-
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -4,9 +4,11 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
+import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
@@ -24,21 +26,22 @@
{
RegionManager regionManager;
LRUAlgorithm algorithm;
- LRUConfiguration config;
+ LRUAlgorithmConfig config;
Log log = LogFactory.getLog(LRUAlgorithm.class);
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
algorithm = new LRUAlgorithm();
- config = new LRUConfiguration();
- config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
+ config = new LRUAlgorithmConfig();
+// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
// We have to setCache timeToLiveSeconds!!
config.setTimeToLive(0);
regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
- regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
+ Region r = regionManager.getRegion("/a/b", true);
+ r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), config));
}
/**
@@ -49,20 +52,20 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(1);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -75,13 +78,13 @@
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 2, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -94,21 +97,21 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(1);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -120,16 +123,16 @@
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setTimeToLive(0);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
TestingUtil.sleepThread(500);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size should be ", 2, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -142,20 +145,20 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setTimeToLive(1000);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
TestingUtil.sleepThread(1100);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #2: ", 0, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -168,21 +171,21 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setTimeToLive(1000);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
TestingUtil.sleepThread(1100);
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.VISIT_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #2: ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -196,19 +199,19 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setTimeToLive(0);
config.setMaxAge(1000);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
TestingUtil.sleepThread(1100);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #2: ", 0, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -222,23 +225,23 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(0);
config.setTimeToLive(0);
config.setMaxAge(1000);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
TestingUtil.sleepThread(500);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #2: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
TestingUtil.sleepThread(600);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals("Queue size #3: ", 0, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -251,18 +254,18 @@
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
Fqn fqn4 = Fqn.fromString("/a/b/f");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
// Should have a maximum of 2 nodes.
config.setMaxNodes(2);
config.setTimeToLive(1000);
config.setMaxAge(3000);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
EvictionQueue eq = algorithm.getEvictionQueue();
int numNodesInQueue = eq.getNumberOfNodes();
@@ -271,9 +274,9 @@
// make sure all nodes now expire
TestingUtil.sleepThread(1100);
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
numNodesInQueue = eq.getNumberOfNodes();
assert 1 == numNodesInQueue : "Queue size #2: expected 1 but was " + numNodesInQueue;
@@ -281,9 +284,9 @@
TestingUtil.sleepThread(3100);
// visit the node now to prevent the idle time from doing the pruning - node still gets pruned but by
// max age.
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
numNodesInQueue = eq.getNumberOfNodes();
assert 0 == numNodesInQueue : "Queue size #3: expected 0 but was " + numNodesInQueue;
@@ -297,17 +300,17 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(2);
config.setTimeToLive(1000);
config.setMaxAge(3000);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.REMOVE_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.REMOVE_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
EvictionQueue eq = algorithm.getEvictionQueue();
int numNodesInQueue = eq.getNumberOfNodes();
@@ -315,17 +318,17 @@
// make sure existing events all time out
TestingUtil.sleepThread(1100);
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
numNodesInQueue = eq.getNumberOfNodes();
assert 1 == numNodesInQueue : "Queue size #2: expected 1 but was " + numNodesInQueue;
TestingUtil.sleepThread(3100);
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
numNodesInQueue = eq.getNumberOfNodes();
assert 0 == numNodesInQueue : "Queue size #3: expected 0 but was " + numNodesInQueue;
@@ -333,8 +336,8 @@
public void testEvictionSortOrder() throws EvictionException
{
- Region region = regionManager.getRegion("/a/b", true);
- LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxAge(1000000);
config.setMaxNodes(0);
@@ -343,21 +346,21 @@
for (int i = 0; i < 100; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
}
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
for (int i = 0; i < 100; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
if (i % 2 == 0)
{
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.VISIT_NODE_EVENT);
}
}
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
LRUQueue queue = (LRUQueue) algorithm.getEvictionQueue();
@@ -380,10 +383,10 @@
for (int i = 0; i < 100; i++)
{
Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
}
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
long lastCreateTimestamp = 0;
while ((ne = queue.getFirstMaxAgeNodeEntry()) != null)
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,12 +6,11 @@
*/
package org.jboss.cache.eviction;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -21,13 +20,13 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = "unit", sequential = false)
public class LRUConfigurationTest
{
public void testXMLParsing() throws Exception
{
- LRUConfiguration config = new LRUConfiguration();
+ LRUAlgorithmConfig config = new LRUAlgorithmConfig();
String xml =
"<region name=\"/org/jboss/data\">\n" +
"<attribute name=\"maxNodes\">5000</attribute>\n" +
@@ -36,7 +35,7 @@
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(5000, config.getMaxNodes());
assertEquals(1000000, config.getTimeToLive());
@@ -44,7 +43,7 @@
public void testXMLParsing2() throws Exception
{
- LRUConfiguration config = new LRUConfiguration();
+ LRUAlgorithmConfig config = new LRUAlgorithmConfig();
String xml = "<region name=\"/maxAgeTest/\">\n" +
"<attribute name=\"maxNodes\">10000</attribute>\n" +
"<attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
@@ -52,7 +51,7 @@
"</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(10000, config.getMaxNodes());
assertEquals(8000, config.getTimeToLive());
@@ -61,7 +60,7 @@
public void testXMLParsing3() throws Exception
{
- LRUConfiguration config = new LRUConfiguration();
+ LRUAlgorithmConfig config = new LRUAlgorithmConfig();
String xml = "<region name=\"/maxAgeTest/\">\n" +
"<attribute name=\"maxNodes\">10000</attribute>\n" +
"<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
@@ -70,7 +69,7 @@
boolean caught = false;
try
{
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
}
catch (ConfigurationException ce)
{
@@ -85,7 +84,7 @@
element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(0, config.getMaxNodes());
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -47,8 +47,8 @@
EvictionConfig evConfig = conf.getEvictionConfig();
evConfig.setWakeupInterval(1000);
List<EvictionRegionConfig> regionConfigs = new ArrayList<EvictionRegionConfig>();
- regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/org/jboss/test/data", 5, dataRegionTTLMillis));
- regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/test", 10000, testRegionTTLMillis));
+ regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new LRUAlgorithmConfig(dataRegionTTLMillis, 5)));
+ regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/test"), new LRUAlgorithmConfig(testRegionTTLMillis, 10000)));
evConfig.setEvictionRegionConfigs(regionConfigs);
conf.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
conf.setIsolationLevel(IsolationLevel.SERIALIZABLE);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,9 +8,11 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
+import org.jboss.cache.config.EvictionRegionConfig;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -31,13 +33,14 @@
public void setUp() throws Exception
{
algorithm = new MRUAlgorithm();
- MRUConfiguration config = new MRUConfiguration();
- // We have to setCache maxNodes!!
+ MRUAlgorithmConfig config = new MRUAlgorithmConfig();
+ // We have to set maxNodes explicitly!!
config.setMaxNodes(0);
- config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
+// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
- regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
+ Region r = regionManager.getRegion("/a/b", true);
+ r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), config));
}
public void testMaxNodes() throws Exception
@@ -45,13 +48,13 @@
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager.getRegion("/a/b", true);
- MRUConfiguration config = (MRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ MRUAlgorithmConfig config = (MRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(1);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
- algorithm.process(region);
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals(1, algorithm.getEvictionQueue().getNumberOfNodes());
@@ -59,10 +62,10 @@
for (int i = 0; i < 150; i++)
{
Fqn fqn = Fqn.fromString("/a/b/c/" + Integer.toString(i));
- region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
}
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals(100, algorithm.getEvictionQueue().getNumberOfNodes());
}
@@ -79,32 +82,32 @@
Fqn fqn8 = Fqn.fromString("/a/b/j");
Fqn fqn9 = Fqn.fromString("/a/b/k");
Fqn fqn10 = Fqn.fromString("/a/b/l");
- Region region = regionManager.getRegion("/a/b", true);
- MRUConfiguration config = (MRUConfiguration) region.getEvictionPolicyConfig();
+ RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
+ MRUAlgorithmConfig config = (MRUAlgorithmConfig) region.getEvictionRegionConfig().getEvictionAlgorithmConfig();
config.setMaxNodes(8);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn5, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn6, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn7, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn8, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn5, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn6, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn7, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn8, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals(8, algorithm.getEvictionQueue().getNumberOfNodes());
- region.putNodeEvent(new EvictedEventNode(fqn9, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn9, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn10, EvictionEvent.Type.ADD_NODE_EVENT);
Thread.sleep(5000);
assertEquals(8, algorithm.getEvictionQueue().getNumberOfNodes());
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT);
- algorithm.process(region);
+ algorithm.process(region.getEvictionEventQueue());
assertEquals(8, algorithm.getEvictionQueue().getNumberOfNodes());
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -6,12 +6,11 @@
*/
package org.jboss.cache.eviction;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -22,15 +21,15 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = "unit", sequential = false)
public class MRUConfigurationTest
{
- MRUConfiguration config = null;
+ MRUAlgorithmConfig config = null;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- config = new MRUConfiguration();
+ config = new MRUAlgorithmConfig();
}
public void testXMLParsing() throws Exception
@@ -41,7 +40,7 @@
"</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(5000, config.getMaxNodes());
}
@@ -53,7 +52,7 @@
"</region>";
Element element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(10000, config.getMaxNodes());
}
@@ -66,7 +65,7 @@
boolean caught = false;
try
{
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
}
catch (ConfigurationException ce)
{
@@ -80,7 +79,7 @@
element = XmlConfigHelper.stringToElement(xml);
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
assertEquals(10000, config.getMaxNodes());
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,20 +8,19 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Unit tests for MRUPolicy.
*
@@ -65,27 +64,17 @@
EvictionConfig evConfig = config.getEvictionConfig();
evConfig.setWakeupInterval(3000);
evConfig.setDefaultEventQueueSize(200000);
- evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.MRUPolicy");
- List<EvictionRegionConfig> evictionRegionConfigs = new ArrayList<EvictionRegionConfig>();
- evictionRegionConfigs.add(buildEvictionRegionConfig("_default_", 100));
- evictionRegionConfigs.add(buildEvictionRegionConfig("/org/jboss/test/data", 6));
- evConfig.setEvictionRegionConfigs(evictionRegionConfigs);
+ // root ERC
+ evConfig.setDefaultEvictionRegionConfig(new EvictionRegionConfig(Fqn.ROOT, new MRUAlgorithmConfig(100)));
+ // new region ERC
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new MRUAlgorithmConfig(6)));
- config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+
+ config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(config);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config);
}
- private EvictionRegionConfig buildEvictionRegionConfig(String regionName, int maxNodes)
- {
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionName(regionName);
- MRUConfiguration mruConfiguration = new MRUConfiguration();
- mruConfiguration.setMaxNodes(maxNodes);
- erc.setEvictionPolicyConfig(mruConfiguration);
- return erc;
- }
-
public void testEviction() throws Exception
{
cache.put("/org/jboss/test/data/a", "/org/jboss/test/data/a", "/org/jboss/test/data/a");
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,7 +8,6 @@
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.element.EvictionElementParser;
-import static org.testng.AssertJUnit.fail;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -18,7 +17,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision: 4444 $
*/
-@Test(groups = {"functional"})
+@Test(groups = "unit", sequential = false)
public class NullEvictionConfigTest
{
/**
@@ -43,14 +42,7 @@
private void testConfigBlock(String xml) throws Exception
{
Element element = XmlConfigHelper.stringToElement(xml);
- NullEvictionPolicyConfig config = new NullEvictionPolicyConfig();
- try
- {
- EvictionElementParser.parseEvictionPolicyConfig(element, config);
- }
- catch (Exception e)
- {
- fail(e.getMessage());
- }
+ NullEvictionAlgorithmConfig config = new NullEvictionAlgorithmConfig();
+ EvictionElementParser.parseEvictionPolicyConfig(element, config, true);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -9,6 +9,7 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
@@ -16,34 +17,24 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Unit tests for LRU Policy.
- *
- * @author Ben Wang, Feb 11, 2004
- * @author Daniel Huang - dhuang(a)jboss.org
- * @version $Revision: 4880 $
- */
@Test(groups = {"functional"})
public class NullEvictionPolicyTest
{
- CacheSPI<Object, Object> cache_;
+ CacheSPI<Object, Object> cache;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache_ = null;
+ cache = null;
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- if (cache_ != null)
+ if (cache != null)
{
- cache_.stop();
- cache_.destroy();
+ cache.stop();
+ cache.destroy();
}
}
@@ -57,18 +48,14 @@
public void testEviction()
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
- EvictionConfig evConfig = config.getEvictionConfig();
- evConfig.setWakeupInterval(1000);
+ EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new NullEvictionAlgorithmConfig()), 1000);
evConfig.setDefaultEventQueueSize(200000);
- evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.NullEvictionPolicy");
- List<EvictionRegionConfig> regionConfigs = new ArrayList<EvictionRegionConfig>();
- regionConfigs.add(buildEvictionRegionConfig("/_default_"));
- regionConfigs.add(buildEvictionRegionConfig("/test"));
- regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/lru", 10000, 1000));
- evConfig.setEvictionRegionConfigs(regionConfigs);
- config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/test"), new NullEvictionAlgorithmConfig()));
+ evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/lru"), new LRUAlgorithmConfig(1000, 10000)));
+ config.setEvictionConfig(evConfig);
+ config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache_ = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(config);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config);
String dfltRootStr = "/a/";
String testRootStr = "/test/";
@@ -79,9 +66,9 @@
Fqn dflt = Fqn.fromString(dfltRootStr + i);
Fqn test = Fqn.fromString(testRootStr + i);
Fqn lru = Fqn.fromString(lruRootStr + i);
- cache_.put(dflt, "key", "value");
- cache_.put(test, "key", "value");
- cache_.put(lru, "key", "value");
+ cache.put(dflt, "key", "value");
+ cache.put(test, "key", "value");
+ cache.put(lru, "key", "value");
}
TestingUtil.sleepThread(3500);
for (int i = 0; i < 20; i++)
@@ -90,19 +77,9 @@
Fqn test = Fqn.fromString(testRootStr + i);
Fqn lru = Fqn.fromString(lruRootStr + i);
- assertEquals("value", cache_.get(dflt, "key"));
- assertEquals("value", cache_.get(test, "key"));
- assertNull(cache_.get(lru, "key"));
+ assertEquals("value", cache.get(dflt, "key"));
+ assertEquals("value", cache.get(test, "key"));
+ assertNull(cache.get(lru, "key"));
}
}
-
- private EvictionRegionConfig buildEvictionRegionConfig(String regionName)
- {
- EvictionRegionConfig evRegConfig = new EvictionRegionConfig();
- evRegConfig.setRegionName(regionName);
- NullEvictionPolicyConfig nullEvictionPolicyConfig = new NullEvictionPolicyConfig();
- evRegConfig.setEvictionPolicyConfig(nullEvictionPolicyConfig);
- return evRegConfig;
- }
-
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -3,7 +3,6 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
@@ -54,30 +53,9 @@
private EvictionConfig buildEvictionConfig() throws Exception
{
- EvictionConfig result = new EvictionConfig("org.jboss.cache.eviction.LRUPolicy");
- result.setWakeupInterval(1000);
-
- LRUConfiguration lruConfiguration = new LRUConfiguration();
- lruConfiguration.setMaxNodes(10);
- lruConfiguration.setTimeToLive(0);
- lruConfiguration.setMaxAge(0);
- EvictionRegionConfig erConfig1 = new EvictionRegionConfig(RegionManagerImpl.DEFAULT_REGION, lruConfiguration);
-
- LRUConfiguration lruConfiguration2 = new LRUConfiguration();
- lruConfiguration2.setMaxNodes(10);
- lruConfiguration2.setTimeToLive(0);
- lruConfiguration2.setMaxAge(0);
- EvictionRegionConfig erConfig2 = new EvictionRegionConfig(Fqn.fromString("/testingRegion"), lruConfiguration2);
-
- LRUConfiguration lruConfiguration3 = new LRUConfiguration();
- lruConfiguration3.setMaxNodes(10);
- lruConfiguration3.setTimeToLive(1000);
- lruConfiguration3.setMaxAge(1000);
- EvictionRegionConfig erConfig3 = new EvictionRegionConfig(Fqn.fromString("/timeBased"), lruConfiguration3);
-
- result.getEvictionRegionConfigs().add(erConfig1);
- result.getEvictionRegionConfigs().add(erConfig2);
- result.getEvictionRegionConfigs().add(erConfig3);
+ EvictionConfig result = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 1000);
+ result.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/testingRegion"), new LRUAlgorithmConfig(0, 0, 10)));
+ result.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/timeBased"), new LRUAlgorithmConfig(1000, 1000, 10)));
return result;
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -33,6 +33,7 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -69,8 +70,9 @@
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
CacheFactory<Object, Object> instance = new DefaultCacheFactory<Object, Object>();
cache = (CacheSPI<Object, Object>) instance.createCache(conf, false);
- conf.getEvictionConfig().setWakeupInterval(5000);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ EvictionConfig erc = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 5000);
+ conf.setEvictionConfig(erc);
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.create();
@@ -85,16 +87,15 @@
private void addStringBasedRegion() throws Exception
{
- LRUConfiguration lruConfig = new LRUConfiguration();
- lruConfig.setMaxNodes(1000);
- lruConfig.setTimeToLive(4000);
- EvictionRegionConfig regConfig = new EvictionRegionConfig(Fqn.fromString("/dummy"), lruConfig);
+ LRUAlgorithmConfig lru = new LRUAlgorithmConfig(4000, 0, 1000);
+ EvictionRegionConfig regConfig = new EvictionRegionConfig(Fqn.fromString("/dummy"), lru);
RegionManager regionManager = cache.getRegionManager();
EvictionConfig topConfig = cache.getConfiguration().getEvictionConfig();
+ topConfig.addEvictionRegionConfig(regConfig);
regionManager.setEvictionConfig(topConfig);
// Fqn is the region name
- regionManager.getRegion("/programmatic", true).setEvictionPolicy(regConfig.getEvictionPolicyConfig());
+ regionManager.getRegion("/programmatic", true).setEvictionRegionConfig(regConfig);
}
public void testStringBasedFqnEviction() throws Exception
@@ -121,9 +122,14 @@
private void addObjectBasedRegion() throws Exception
{
- LRUConfiguration lruConfig = new LRUConfiguration(4000, 1000);
+ LRUAlgorithmConfig lru = new LRUAlgorithmConfig(4000, 1000);
+ EvictionRegionConfig regConfig = new EvictionRegionConfig(Fqn.fromElements(1), lru);
+
RegionManager regionManager = cache.getRegionManager();
- regionManager.getRegion(Fqn.fromElements(1), true).setEvictionPolicy(lruConfig);
+ EvictionConfig topConfig = cache.getConfiguration().getEvictionConfig();
+ topConfig.addEvictionRegionConfig(regConfig);
+ regionManager.setEvictionConfig(topConfig);
+ regionManager.getRegion(Fqn.fromElements(1), true).setEvictionRegionConfig(regConfig);
}
public void testObjectBasedFqnEviction1() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -5,9 +5,8 @@
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
-import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import static org.testng.AssertJUnit.*;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.List;
@@ -28,26 +27,17 @@
Fqn A_BC = Fqn.fromString("/a/bc");
Fqn AOP = Fqn.fromString("/aop");
+ EvictionRegionConfig config = new EvictionRegionConfig(null, new NullEvictionAlgorithmConfig());
- EvictionPolicy policy;
- EvictionPolicyConfig config;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- policy = new DummyEvictionPolicy();
- config = new DummyEvictionConfiguration();
- }
-
public void testCreateRegion()
{
RegionManager regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
- regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config);
- regionManager.getRegion(A_B_C, true).setEvictionPolicy(config);
- regionManager.getRegion(A_B, true).setEvictionPolicy(config);
- regionManager.getRegion(AOP, true).setEvictionPolicy(config);
+ regionManager.getRegion(DEFAULT_REGION, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(A_B_C, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(A_B, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(AOP, true).setEvictionRegionConfig(config);
List<Region> regions = regionManager.getAllRegions(Region.Type.ANY);
assertEquals("Region size ", 4, regions.size());
@@ -59,9 +49,9 @@
RegionManager regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
- regionManager.getRegion(A_B_C, true).setEvictionPolicy(config);
- regionManager.getRegion(A_B, true).setEvictionPolicy(config);
- regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config);
+ regionManager.getRegion(A_B_C, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(A_B, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(DEFAULT_REGION, true).setEvictionRegionConfig(config);
List<Region> regions = regionManager.getAllRegions(Region.Type.ANY);
assertEquals("Region size ", 3, regions.size());
@@ -85,8 +75,8 @@
RegionManager regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
- regionManager.getRegion(A_B_C, true).setEvictionPolicy(config);
- regionManager.getRegion(A_B, true).setEvictionPolicy(config);
+ regionManager.getRegion(A_B_C, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(A_B, true).setEvictionRegionConfig(config);
regionManager.getRegion(Fqn.fromString("/a"), Region.Type.EVICTION, false);
}
@@ -96,9 +86,9 @@
RegionManager regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
- regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config);
- regionManager.getRegion(A_BC, true).setEvictionPolicy(config);
- regionManager.getRegion(A_B, true).setEvictionPolicy(config);
+ regionManager.getRegion(DEFAULT_REGION, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(A_BC, true).setEvictionRegionConfig(config);
+ regionManager.getRegion(A_B, true).setEvictionRegionConfig(config);
Region region = regionManager.getRegion(A_BC, true);
assertNotSame("Region ", DEFAULT_REGION, region.getFqn());
@@ -112,10 +102,10 @@
RegionManager rm = new RegionManagerImpl();
((RegionManagerImpl) rm).injectDependencies(null, null, null, null, null, new RegionRegistry());
rm.setUsingEvictions(true);
- rm.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config);
- rm.getRegion(A_B_C_D_E, true).setEvictionPolicy(config);
- rm.getRegion(A_B_C_D, true).setEvictionPolicy(config);
- rm.getRegion(A_B_C, true).setEvictionPolicy(config);
+ rm.getRegion(DEFAULT_REGION, true).setEvictionRegionConfig(config);
+ rm.getRegion(A_B_C_D_E, true).setEvictionRegionConfig(config);
+ rm.getRegion(A_B_C_D, true).setEvictionRegionConfig(config);
+ rm.getRegion(A_B_C, true).setEvictionRegionConfig(config);
Region region = rm.getRegion("/a/b/c/d/e/f", false);
Region region2 = rm.getRegion("/e/f/g", false);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -2,15 +2,19 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.RegionRegistry;
import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.concurrent.TimeUnit;
+
/**
* @author Ben Wang, Feb 11, 2004
* @author Daniel Huang (dhuang(a)jboss.org)
@@ -27,48 +31,49 @@
algorithm = new LRUAlgorithm();
regionManager = new RegionManagerImpl();
((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
- regionManager.getRegion("/a/b", true).setEvictionPolicy(new DummyEvictionConfiguration());
+ Region r = regionManager.getRegion("/a/b", true);//.setEvictionPolicy(new DummyEvictionConfiguration());
+ r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), new NullEvictionAlgorithmConfig()));
}
- public void testAddedQueue()
+ public void testAddedQueue() throws InterruptedException
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
Region region = regionManager.getRegion("/a/b", true);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
- assertEquals("AddedNode queue size ", 3, region.nodeEventQueueSize());
- EvictedEventNode node = region.takeLastEventNode();
+ assertEquals("AddedNode queue size ", 3, getQueueSize((RegionImpl) region));
+ EvictionEvent node = takeLastEvent((RegionImpl) region);
Fqn fqn = node.getFqn();
assertEquals("DataNode retrieved should be FILO ", fqn, fqn1);
- assertEquals("AddedNode queue size ", 2, region.nodeEventQueueSize());
- fqn = region.takeLastEventNode().getFqn();
- fqn = region.takeLastEventNode().getFqn();
- node = region.takeLastEventNode();
+ assertEquals("AddedNode queue size ", 2, getQueueSize((RegionImpl) region));
+ fqn = takeLastEvent((RegionImpl) region).getFqn();
+ fqn = takeLastEvent((RegionImpl) region).getFqn();
+ node = takeLastEvent((RegionImpl) region);
assertNull("DataNode should be null", node);
}
- public void testEventQueue()
+ public void testEventQueue() throws InterruptedException
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
Region region = regionManager.getRegion("/a/b", true);
- region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.REMOVE_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
- region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_NODE_EVENT));
+ region.registerEvictionEvent(fqn1, EvictionEvent.Type.REMOVE_NODE_EVENT);
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
+ region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVENT);
- assertEquals("RemovedNode queue size ", 3, region.nodeEventQueueSize());
- NodeEventType event = region.takeLastEventNode().getEventType();
- assertEquals("DataNode retrieved should be: ", NodeEventType.REMOVE_NODE_EVENT, event);
- region.takeLastEventNode();
- region.takeLastEventNode();
- EvictedEventNode node = region.takeLastEventNode();
+ assertEquals("RemovedNode queue size ", 3, getQueueSize((RegionImpl) region));
+ EvictionEvent.Type event = takeLastEvent((RegionImpl) region).getEventType();
+ assertEquals("DataNode retrieved should be: ", EvictionEvent.Type.REMOVE_NODE_EVENT, event);
+ takeLastEvent((RegionImpl) region);
+ takeLastEvent((RegionImpl) region);
+ EvictionEvent node = takeLastEvent((RegionImpl) region);
assertNull("DataNode should be null", node);
}
@@ -80,7 +85,7 @@
// This should succeed, alhtough it will produce warning over the threshold.
for (int i = 0; i < EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT - 1; i++)
{
- region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
+ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
}
}
@@ -90,4 +95,14 @@
System.out.println("-- " + msg);
}
+ EvictionEvent takeLastEvent(RegionImpl r) throws InterruptedException
+ {
+ return r.getEvictionEventQueue().poll(0, TimeUnit.MILLISECONDS);
+ }
+
+ int getQueueSize(RegionImpl r)
+ {
+ return r.getEvictionEventQueue().size();
+ }
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -23,7 +23,7 @@
{
CacheSPI<Object, Object> cache1, cache2, cache3;
long wakeupIntervalMillis = 0;
- EvictionListener listener_ = new EvictionListener();
+ EvictionListener listener = new EvictionListener();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -32,8 +32,8 @@
cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache1.getConfiguration().setUseRegionBasedMarshalling(true);
cache1.start();
- cache1.getNotifier().addCacheListener(listener_);
- listener_.resetCounter();
+ cache1.getNotifier().addCacheListener(listener);
+ listener.resetCounter();
cache3 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache3.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
@@ -66,10 +66,10 @@
TestingUtil.sleepThread(30000);
Object node = cache1.peek(Fqn.fromString(str), false);
assertNull("DataNode should be evicted already ", node);
- assertEquals("Eviction counter ", 1, listener_.getCounter());
+ assertEquals("Eviction counter ", 1, listener.getCounter());
String val = (String) cache3.get(str, str);
assertNotNull("DataNode should not be evicted here ", val);
- assertEquals("Eviction counter ", 1, listener_.getCounter());
+ assertEquals("Eviction counter ", 1, listener.getCounter());
}
public void testEviction() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,9 +1,9 @@
package org.jboss.cache.eviction.minttl;
import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.EvictionAlgorithmConfigBase;
+import org.jboss.cache.eviction.FIFOAlgorithmConfig;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.eviction.EvictionPolicyConfigBase;
-import org.jboss.cache.eviction.FIFOConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -19,10 +19,10 @@
private boolean busyThreadRunning = true;
@Override
- protected EvictionPolicyConfigBase getEvictionPolicyConfig()
+ protected EvictionAlgorithmConfigBase getEvictionPolicyConfig()
{
startBusyThread();
- FIFOConfiguration cfg = new FIFOConfiguration();
+ FIFOAlgorithmConfig cfg = new FIFOAlgorithmConfig();
cfg.setMaxNodes(1);
return cfg;
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,12 +1,10 @@
package org.jboss.cache.eviction.minttl;
+import org.jboss.cache.eviction.EvictionAlgorithmConfigBase;
+import org.jboss.cache.eviction.LFUAlgorithmConfig;
import org.testng.annotations.Test;
-import org.jboss.cache.eviction.EvictionPolicyConfigBase;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.LFUConfiguration;
/**
- *
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
@@ -14,9 +12,8 @@
public class LFUMinTTLTest extends MinTTLTestBase
{
@Override
- protected EvictionPolicyConfigBase getEvictionPolicyConfig()
+ protected EvictionAlgorithmConfigBase getEvictionPolicyConfig()
{
- LFUConfiguration cfg = new LFUConfiguration();
- return cfg;
+ return new LFUAlgorithmConfig();
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,11 +1,10 @@
package org.jboss.cache.eviction.minttl;
+import org.jboss.cache.eviction.EvictionAlgorithmConfigBase;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.testng.annotations.Test;
-import org.jboss.cache.eviction.EvictionPolicyConfigBase;
-import org.jboss.cache.eviction.LRUConfiguration;
/**
- *
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
@@ -13,9 +12,9 @@
public class LRUMinTTLTest extends MinTTLTestBase
{
@Override
- protected EvictionPolicyConfigBase getEvictionPolicyConfig()
+ protected EvictionAlgorithmConfigBase getEvictionPolicyConfig()
{
- LRUConfiguration cfg = new LRUConfiguration();
+ LRUAlgorithmConfig cfg = new LRUAlgorithmConfig();
cfg.setTimeToLive(1000);
return cfg;
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -2,9 +2,9 @@
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.EvictionAlgorithmConfigBase;
+import org.jboss.cache.eviction.MRUAlgorithmConfig;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.eviction.EvictionPolicyConfigBase;
-import org.jboss.cache.eviction.MRUConfiguration;
import org.testng.annotations.Test;
/**
@@ -17,9 +17,9 @@
private Fqn fqn2 = Fqn.fromRelativeElements(region, "b");
@Override
- protected EvictionPolicyConfigBase getEvictionPolicyConfig()
+ protected EvictionAlgorithmConfigBase getEvictionPolicyConfig()
{
- MRUConfiguration cfg = new MRUConfiguration();
+ MRUAlgorithmConfig cfg = new MRUAlgorithmConfig();
cfg.setMaxNodes(1);
startBusyThread();
return cfg;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -5,14 +5,12 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.EvictionPolicyConfigBase;
+import org.jboss.cache.eviction.EvictionAlgorithmConfigBase;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.List;
import java.util.concurrent.CountDownLatch;
/**
@@ -32,7 +30,7 @@
// allows the test methods to notify any support threads in subclasses that data is in the cache and the test is about to begin
protected CountDownLatch cacheInitialisedLatch;
- protected abstract EvictionPolicyConfigBase getEvictionPolicyConfig();
+ protected abstract EvictionAlgorithmConfigBase getEvictionPolicyConfig();
@BeforeMethod
public void setUp()
@@ -40,22 +38,17 @@
cacheInitialisedLatch = new CountDownLatch(1);
// the LRU policy cfg
- EvictionPolicyConfigBase cfg = getEvictionPolicyConfig();
+ EvictionAlgorithmConfigBase cfg = getEvictionPolicyConfig();
// the region configuration
EvictionRegionConfig regionCfg = new EvictionRegionConfig();
regionCfg.setRegionFqn(region);
regionCfg.setRegionName(region.toString());
- regionCfg.setEvictionPolicyConfig(cfg);
-
- // set regions in a list
- List<EvictionRegionConfig> evictionRegionConfigs = new ArrayList<EvictionRegionConfig>();
- evictionRegionConfigs.add(regionCfg);
-
+ regionCfg.setEvictionAlgorithmConfig(cfg);
// cache-wide
EvictionConfig ec = new EvictionConfig();
ec.setWakeupInterval(1000);
- ec.setEvictionRegionConfigs(evictionRegionConfigs);
+ ec.addEvictionRegionConfig(regionCfg);
cache = new DefaultCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setEvictionConfig(ec);
@@ -83,7 +76,7 @@
public void testWithMinimumTTL()
{
- ((EvictionPolicyConfigBase) cache.getConfiguration().getEvictionConfig().getEvictionRegionConfigs().get(0).getEvictionPolicyConfig()).setMinTimeToLive(3000);
+ ((EvictionAlgorithmConfigBase) cache.getConfiguration().getEvictionConfig().getEvictionRegionConfigs().get(0).getEvictionAlgorithmConfig()).setMinTimeToLive(3000);
cache.start();
cache.put(fqn, "k", "v");
Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -11,12 +11,10 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.util.FileLookup;
-import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.util.FileLookup;
import org.jgroups.conf.XmlConfigurator;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -159,19 +157,6 @@
return jgroupsConfigString.substring(0, jgroupsConfigString.indexOf(":")) + delay + jgroupsConfigString.substring(jgroupsConfigString.indexOf(":"));
}
-
- public static EvictionRegionConfig buildLruEvictionRegionConfig(String regionNaame, int maxNodes, long timeToLive)
- {
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionName(regionNaame);
- LRUConfiguration lruConfig = new LRUConfiguration();
- lruConfig.setEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy");
- if (maxNodes >= 0) lruConfig.setMaxNodes(maxNodes);
- if (timeToLive >= 0) lruConfig.setTimeToLive(timeToLive);
- erc.setEvictionPolicyConfig(lruConfig);
- return erc;
- }
-
private static class UnitTestXmlConfigurationParser extends XmlConfigurationParser
{
Deleted: core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -1,538 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.interceptors;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.Region;
-import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.DummyEvictionConfiguration;
-import org.jboss.cache.eviction.EvictedEventNode;
-import org.jboss.cache.eviction.NodeEventType;
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.util.TestingUtil;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Daniel Huang (dhuang(a)jboss.org)
- * @version $Revision: $
- */
-@Test(groups = "functional")
-public class EvictionInterceptorTest
-{
- private static final String fqn1 = "/a/b/c";
- private static final String fqn2 = "/a/b";
- private static final String fqn3 = "/a/b/d";
- private static final String fqn4 = "/d/e/f";
-
- private CacheSPI<Object, Object> cache;
- private InterceptorChain invoker;
- private RegionManager regionManager;
- private CommandsFactory commandsFactory;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache.getConfiguration().setCacheMode("LOCAL");
- EvictionConfig ec = new EvictionConfig();
-
- List<EvictionRegionConfig> ercs = new LinkedList<EvictionRegionConfig>();
- ercs.add(new EvictionRegionConfig(Fqn.ROOT, new DummyEvictionConfiguration()));
- ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b/c"), new DummyEvictionConfiguration()));
- ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b/c/d"), new DummyEvictionConfiguration()));
- ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b"), new DummyEvictionConfiguration()));
- ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e/f"), new DummyEvictionConfiguration()));
- ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e/g"), new DummyEvictionConfiguration()));
- ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e"), new DummyEvictionConfiguration()));
-
- ec.setEvictionRegionConfigs(ercs);
- cache.getConfiguration().setEvictionConfig(ec);
- cache.start();
-
- invoker = TestingUtil.extractComponentRegistry(cache).getComponent(InterceptorChain.class);
- commandsFactory = TestingUtil.extractCommandsFactory(cache);
- regionManager = cache.getRegionManager();
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- TestingUtil.killCaches(cache);
- }
-
- private NodeSPI<Object, Object> cast(Node<Object, Object> node)
- {
- return (NodeSPI<Object, Object>) node;
- }
-
- public void testVisitNode() throws Throwable
- {
- // make sure node that doesn't exist does not result in a node visit event.
-
- VisitableCommand command = commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn1));
- invoker.invoke(command);
- Region regionABC = regionManager.getRegion(fqn1, false);
- assertNull(regionABC.takeLastEventNode());
-
- putQuietly(fqn1, "key", "value");
- NodeSPI<Object, Object> node = cast(cache.peek(Fqn.fromString(fqn1), false, false));
- assertNotNull(node);
- assertEquals("value", node.getDirect("key"));
-
- putQuietly(fqn3, "key", "value");
- node = cast(cache.peek(Fqn.fromString(fqn3), false, false));
- assertNotNull(node);
- assertEquals("value", node.getDirect("key"));
-
-
- command = commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn1));
- invoker.invoke(command);
-
- regionABC = regionManager.getRegion(fqn1, false);
- EvictedEventNode event = regionABC.takeLastEventNode();
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn1, event.getFqn().toString());
- assertNull(regionABC.takeLastEventNode());
-
- command = commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn2));
- invoker.invoke(command);
-
- Region regionAB = regionManager.getRegion(fqn2, false);
- event = regionAB.takeLastEventNode();
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn2, event.getFqn().toString());
- assertNull(regionAB.takeLastEventNode());
-
- command = commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn3));
- invoker.invoke(command);
- Region regionABD = regionManager.getRegion(fqn3, false);
- event = regionABD.takeLastEventNode();
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn3, event.getFqn().toString());
- assertNull(regionABD.takeLastEventNode());
-
- for (int i = 0; i < 10; i++)
- {
- command = commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn3));
- invoker.invoke(command);
- }
-
- for (int i = 0; i < 10; i++)
- {
- Region region = regionManager.getRegion(fqn3, false);
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn3, event.getFqn().toString());
- }
-
- assertNull(regionManager.getRegion(fqn3, false).takeLastEventNode());
-
- // check null handling.
- command = commandsFactory.buildGetDataMapCommand(null);
- invoker.invoke(command);
-
- }
-
- /**
- * Helper to quietly add something into the cache without generating eviction events
- *
- * @param fqn fqn to add
- * @param key key
- * @param value value
- */
- private void putQuietly(String fqn, Object key, Object value)
- {
- putQuietly(Fqn.fromString(fqn), key, value);
- }
-
- /**
- * Helper to quietly add something into the cache without generating eviction events
- *
- * @param fqn fqn to add
- * @param key key
- * @param value value
- */
- private void putQuietly(Fqn fqn, Object key, Object value)
- {
- NodeSPI root = cache.getRoot();
- NodeSPI child = root;
- for (int i = 0; i < fqn.size(); i++)
- {
- child = child.addChildDirect(Fqn.fromElements(fqn.get(i)));
- }
-
- assert child.getFqn().equals(fqn);
-
- child.putDirect(key, value);
- }
-
- public void testVisitElement() throws Throwable
- {
- // make sure a get/visit on an empty node and empty element results in no cache events being added to event queue
- // aka MarshRegion.
- Fqn fqn = Fqn.fromString(fqn4);
- Object key = "key";
- GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- invoker.invoke(command);
- Region region = regionManager.getRegion(fqn.toString(), false);
- assertNull(region.takeLastEventNode());
-
- // add the node but try to get on a null element should result in no cache events being added to Region.
- putQuietly(fqn, "wrongkey", "");
-
- command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- invoker.invoke(command);
- assertNull(region.takeLastEventNode());
-
- // now make sure if we try to get on the node/key we just created in cache, that this DOES add a EvictedEventNode to
- // the MarshRegion.
- command = commandsFactory.buildGetKeyValueCommand(fqn, "wrongkey", false);
- invoker.invoke(command);
- EvictedEventNode event = region.takeLastEventNode();
- assertEquals(fqn, event.getFqn());
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
-
- assertNull(region.takeLastEventNode());
-
- putQuietly(fqn4, key, "value");
-
- // test on element granularity configured node.
- fqn = Fqn.fromString(fqn4);
- command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- invoker.invoke(command);
-
- region = regionManager.getRegion(fqn.toString(), false);
- event = region.takeLastEventNode();
-
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
-
- assertNull(region.takeLastEventNode());
-
- fqn = Fqn.fromString("/d/e/g");
- for (int i = 0; i < 100; i++)
- {
- key = i;
-
- putQuietly("/d/e/g", key, "");
-
- command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- invoker.invoke(command);
- }
-
- region = regionManager.getRegion(fqn.toString(), false);
-
- for (int i = 0; i < 100; i++)
- {
- event = region.takeLastEventNode();
- assertEquals(fqn, event.getFqn());
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- }
-
- putQuietly("/a/b/c", key, "");
- fqn = Fqn.fromString("/a/b/c");
-
- command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- invoker.invoke(command);
-
- region = regionManager.getRegion(fqn.toString(), false);
- event = region.takeLastEventNode();
-
- assertNull(region.takeLastEventNode());
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
-
- for (int i = 0; i < 100; i++)
- {
- key = i;
-
- putQuietly(fqn, key, "");
-
- command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- invoker.invoke(command);
- }
-
- for (int i = 0; i < 100; i++)
- {
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- }
-
- assertNull(region.takeLastEventNode());
- }
-
- public void testCreateNode() throws Throwable
- {
- Map<Object, Object> data = new HashMap<Object, Object>();
- for (int i = 0; i < 100; i++)
- {
- data.put(i, i);
- }
-
- // this region is node granularity
- Fqn fqn = Fqn.fromString("/a/b/c");
-
- PutDataMapCommand putDataMapCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data);
- invoker.invoke(putDataMapCommand);
-
- Region region = regionManager.getRegion(fqn.toString(), false);
- EvictedEventNode event = region.takeLastEventNode();
-
- assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertEquals(100, event.getElementDifference());
-
- NodeSPI<Object, Object> node = cast(cache.peek(fqn, false, false));
- assertNotNull(node);
-
- for (int i = 0; i < 100; i++)
- {
- assertTrue(node.getDataDirect().containsKey(i));
- assertEquals(i, node.getDirect(i));
- }
-
- for (int i = 0; i < 100; i++)
- {
- PutKeyValueCommand pkvCommand = commandsFactory.buildPutKeyValueCommand(null, fqn, i, "value");
- invoker.invoke(pkvCommand);
-
- assertEquals("value", cache.peek(fqn, false, false).getDirect(i));
- }
-
- for (int i = 0; i < 100; i++)
- {
- event = region.takeLastEventNode();
- assertNotNull(event);
- assertEquals(fqn, event.getFqn());
- assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
- }
-
- assertNull(region.takeLastEventNode());
-
- fqn = Fqn.fromString("/a/b");
- PutDataMapCommand putCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data);
- invoker.invoke(putCommand);
- event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
- assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertEquals(100, event.getElementDifference());
- assertNull(regionManager.getRegion(fqn.toString(), false).takeLastEventNode());
- node = cast(cache.peek(fqn, false, false));
- assertEquals(100, node.getDataDirect().size());
-
- assertNotNull(node);
-
- for (int i = 0; i < 100; i++)
- {
- assertTrue(node.getDataDirect().containsKey(i));
- assertEquals(i, node.getDirect(i));
- }
-
- PutDataMapCommand putDataMap = commandsFactory.buildPutDataMapCommand(null, fqn, data);
- invoker.invoke(putDataMap);
- event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
- assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertEquals(100, event.getElementDifference());
- assertNull(regionManager.getRegion(fqn.toString(), false).takeLastEventNode());
-
-
- node = cast(cache.getNode(fqn));
- assertEquals(100, node.getData().size());
- assertNotNull(node);
-
- for (int i = 0; i < 100; i++)
- {
- assertTrue(node.getDataDirect().containsKey(i));
- assertEquals(i, node.getDirect(i));
- }
-
- }
-
- public void testCreateElement() throws Throwable
- {
- Fqn fqn = Fqn.fromString("/d/e/f");
- Region region = regionManager.getRegion(fqn.toString(), false);
- Object key = "key";
- Object value = "value";
-
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, (Fqn) fqn, key, value);
- invoker.invoke(command);
- assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
- EvictedEventNode event = region.takeLastEventNode();
- assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
- assertEquals(1, event.getElementDifference());
- assertEquals(fqn, event.getFqn());
- assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
- assertNull(region.takeLastEventNode());
-
- command = commandsFactory.buildPutKeyValueCommand(null, (Fqn) fqn, key, value);
- invoker.invoke(command);
- assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
- assertEquals(1, event.getElementDifference());
- assertEquals(fqn, event.getFqn());
- assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
- assertNull(region.takeLastEventNode());
-
- }
-
- public void testRemoveNode() throws Throwable
- {
- Fqn fqn = Fqn.fromString("/a/b/c");
- putQuietly(fqn, "a", "b");
- putQuietly(fqn, "b", "c");
-
- ClearDataCommand clearDataCommand = commandsFactory.buildClearDataCommand(null, fqn);
- invoker.invoke(clearDataCommand);
-
- assertEquals(0, cache.peek(fqn, false, false).getDataDirect().size());
- Region region = regionManager.getRegion(fqn.toString(), false);
- EvictedEventNode event = region.takeLastEventNode();
- assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertNull(region.takeLastEventNode());
-
- RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveNodeCommand(null, fqn);
- invoker.invoke(removeNodeCommand);
-
- assertNull(cache.peek(fqn, false, false));
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertNull(region.takeLastEventNode());
- }
-
- public void testRemoveElement() throws Throwable
- {
- Fqn fqn = Fqn.fromString("/a/b/c");
- putQuietly(fqn, "a", "b");
- putQuietly(fqn, "b", "c");
-
- RemoveKeyCommand removeKeyCommand = commandsFactory.buildRemoveKeyCommand(null, fqn, "a");
- invoker.invoke(removeKeyCommand);
-
- assertNull(cache.get(fqn, "a"));
- Region region = regionManager.getRegion(fqn.toString(), false);
- EvictedEventNode event = region.takeLastEventNode();
- assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertEquals(1, event.getElementDifference());
- assertNull(region.takeLastEventNode());
-
- RemoveKeyCommand removeKeyCommand2 = commandsFactory.buildRemoveKeyCommand(null, fqn, "b");
- invoker.invoke(removeKeyCommand2);
-
- assertNull(cache.get(fqn, "b"));
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertEquals(1, event.getElementDifference());
- assertNull(region.takeLastEventNode());
-
- RemoveKeyCommand removeKeyCommand3 = commandsFactory.buildRemoveKeyCommand(null, fqn, "a");
- invoker.invoke(removeKeyCommand3);
-
- event = region.takeLastEventNode();
- assertNull(event);
- }
-
- public void testMixedEvent() throws Throwable
- {
- Map<Object, Object> data = new HashMap<Object, Object>();
- for (int i = 0; i < 100; i++)
- {
- data.put(i, i);
- }
-
- // this region is node granularity
- Fqn fqn = Fqn.fromString("/a/b/c");
-
- PutDataMapCommand putDataCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data);
- invoker.invoke(putDataCommand);
-
- Region region = regionManager.getRegion(fqn.toString(), false);
- EvictedEventNode event = region.takeLastEventNode();
-
- assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertEquals(100, event.getElementDifference());
- assertNull(region.takeLastEventNode());
-
- GetNodeCommand getNodeCommand = commandsFactory.buildGetNodeCommand(fqn);
- invoker.invoke(getNodeCommand);
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertNull(region.takeLastEventNode());
-
- RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveNodeCommand(null, fqn);
- invoker.invoke(removeNodeCommand);
- assertNull(cache.getNode(fqn));
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertNull(region.takeLastEventNode());
-
- Object key = "key";
- Object value = "value";
- PutKeyValueCommand putKeyValueCommand = commandsFactory.buildPutKeyValueCommand(null, fqn, key, value);
- invoker.invoke(putKeyValueCommand);
- assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
- assertEquals(1, event.getElementDifference());
- assertEquals(fqn, event.getFqn());
- assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
- assertNull(region.takeLastEventNode());
-
- GetKeyValueCommand getKeyValueCommand = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- invoker.invoke(getKeyValueCommand);
- region = regionManager.getRegion(fqn.toString(), false);
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertNull(region.takeLastEventNode());
-
- RemoveKeyCommand removeKeyCommand = commandsFactory.buildRemoveKeyCommand(null, fqn, key);
- invoker.invoke(removeKeyCommand);
-
- assertNull(cache.get(fqn, key));
- event = region.takeLastEventNode();
- assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType());
- assertEquals(fqn, event.getFqn());
- assertEquals(1, event.getElementDifference());
- assertNull(region.takeLastEventNode());
- }
-}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,7 +8,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.FIFOConfiguration;
+import org.jboss.cache.eviction.FIFOAlgorithmConfig;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
@@ -39,7 +39,7 @@
c1 = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
// the FIFO policy cfg
- FIFOConfiguration cfg = new FIFOConfiguration();
+ FIFOAlgorithmConfig cfg = new FIFOAlgorithmConfig();
cfg.setMaxNodes(1);
cfg.setMinTimeToLive(0);
@@ -47,7 +47,7 @@
EvictionRegionConfig regionCfg = new EvictionRegionConfig();
regionCfg.setRegionFqn(dummy.getParent());
regionCfg.setRegionName(dummy.getParent().toString());
- regionCfg.setEvictionPolicyConfig(cfg);
+ regionCfg.setEvictionAlgorithmConfig(cfg);
// set regions in a list
List<EvictionRegionConfig> evictionRegionConfigs = new ArrayList<EvictionRegionConfig>();
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -23,8 +23,6 @@
package org.jboss.cache.jmx.deprecated;
import org.jboss.cache.Version;
-import org.jboss.cache.jmx.CacheJmxWrapperMBean;
-import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -42,6 +40,8 @@
import org.jboss.cache.eviction.LRUPolicy;
import org.jboss.cache.eviction.MRUConfiguration;
import org.jboss.cache.eviction.MRUPolicy;
+import org.jboss.cache.jmx.CacheJmxWrapper;
+import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import org.jboss.cache.loader.FileCacheLoader;
import org.jboss.cache.loader.SingletonStoreCacheLoader;
import org.jboss.cache.loader.jdbm.JdbmCacheLoader;
@@ -183,7 +183,7 @@
assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig().toString(), wrapper.getEvictionPolicyConfig().toString());
EvictionConfig ec = c.getEvictionConfig();
- assertEquals("EC queue size", 20000, ec.getDefaultEventQueueSize());
+ assertEquals("EC queue size", 20000, ec.getDefaultEvictionRegionConfig().getEventQueueSize());
assertEquals("EC wakeup", 5000, ec.getWakeupInterval());
assertEquals("EC default pol", LRUPolicy.class.getName(), ec.getDefaultEvictionPolicyClass());
List<EvictionRegionConfig> ercs = ec.getEvictionRegionConfigs();
@@ -193,7 +193,7 @@
LRUConfiguration lru = (LRUConfiguration) erc.getEvictionPolicyConfig();
assertEquals("EPC0 pol", LRUPolicy.class.getName(), lru.getEvictionPolicyClass());
assertEquals("EPC0 maxnodes", 5000, lru.getMaxNodes());
- assertEquals("EPC0 ttl", 1000000, lru.getTimeToLive());
+ assertEquals("EPC0 ttl", 1000, lru.getTimeToLiveSeconds());
erc = ercs.get(1);
assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName());
assertEquals("ERC1 queue size", 20000, erc.getEventQueueSize());
@@ -212,8 +212,8 @@
lru = (LRUConfiguration) erc.getEvictionPolicyConfig();
assertEquals("EPC3 pol", LRUPolicy.class.getName(), lru.getEvictionPolicyClass());
assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes());
- assertEquals("EPC3 maxage", 10000, lru.getMaxAge());
- assertEquals("EPC3 ttl", 8000, lru.getTimeToLive());
+ assertEquals("EPC3 maxage", 10, lru.getMaxAgeSeconds());
+ assertEquals("EPC3 ttl", 8, lru.getTimeToLiveSeconds());
}
@@ -309,15 +309,15 @@
{
String xmlStr =
- " <eviction wakeUpInterval=\"5000\" defaultPolicyClass=\"org.jboss.cache.eviction.LRUPolicy\" defaultEventQueueSize=\"20000\">\n" +
- " <default eventQueueSize=\"1000\">\n" +
+ " <eviction wakeUpInterval=\"5000\">\n" +
+ " <default eventQueueSize=\"1000\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLive\">1000000</attribute>\n" +
" </default>\n" +
- "<region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
+ "<region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.FIFOAlgorithm\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
"</region>\n" +
- "<region name=\"/test/\" policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
+ "<region name=\"/test/\" algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\">\n" +
" <attribute name=\"maxNodes\">10000</attribute>\n" +
"</region>\n" +
"<region name=\"/maxAgeTest/\">\n" +
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -4,23 +4,20 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.LRUPolicy;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.loader.JDBCCacheLoaderConfig;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
import java.util.Properties;
/**
@@ -109,19 +106,15 @@
config.setUseRegionBasedMarshalling(useRegionBased);
config.setInactiveOnStartup(useRegionBased);
- EvictionConfig ec = new EvictionConfig();
- ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
- ec.setWakeupInterval(1000000); // a long time; really disabled
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionFqn(Fqn.ROOT);
- erc.setRegionName("_default_");
- LRUConfiguration epc = new LRUConfiguration();
- epc.setMaxNodes(1000);
- epc.setTimeToLive(1000000);
- erc.setEvictionPolicyConfig(epc);
- List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
- ercs.add(erc);
- ec.setEvictionRegionConfigs(ercs);
+ int wakeupInterval = 1000000; // a long time; really disabled
+ EvictionConfig ec = new EvictionConfig(
+ new EvictionRegionConfig(
+ Fqn.ROOT,
+ new LRUAlgorithmConfig(1000000, 0, 1000)
+ ),
+ wakeupInterval
+ );
+
config.setEvictionConfig(ec);
CacheLoaderConfig clc = new CacheLoaderConfig();
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -10,21 +10,17 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.LRUPolicy;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.loader.FileCacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
-
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
/**
* Tests marshalling/unmarshalling during cache loader operations involving types
@@ -69,38 +65,38 @@
{
cacheLoaderMarshallingTest(true);
}
-
+
public void testLoadNodesAtRootOfRegion() throws Exception
{
String rootRegionName = "/myregion";
String hereFqn = rootRegionName + "/here";
-
+
cache = createCache(true);
cache.start();
Region r = cache.getRegion(Fqn.fromString(rootRegionName), true);
r.registerContextClassLoader(Thread.currentThread().getContextClassLoader());
r.activate();
-
+
cache.put(rootRegionName, "a key", "a value");
cache.put(hereFqn, "another key", "another value");
r.deactivate();
r.unregisterContextClassLoader();
-
+
cache.stop();
-
+
cache.start();
-
+
r = cache.getRegion(Fqn.fromString(rootRegionName), true);
r.registerContextClassLoader(Thread.currentThread().getContextClassLoader());
r.activate();
-
+
Node<Object, Object> rootRegionNode = cache.getNode(rootRegionName);
Node<Object, Object> hereNode = cache.getNode(hereFqn);
assertNotNull(rootRegionNode);
assertNotNull(hereNode);
-
+
assertEquals(hereNode.get("another key"), "another value");
assertEquals(rootRegionNode.get("a key"), "a value");
}
@@ -140,18 +136,14 @@
config.setInactiveOnStartup(useRegionBased);
EvictionConfig ec = new EvictionConfig();
- ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
ec.setWakeupInterval(1000000); // a long time; really disabled
EvictionRegionConfig erc = new EvictionRegionConfig();
erc.setRegionFqn(Fqn.ROOT);
- erc.setRegionName("_default_");
- LRUConfiguration epc = new LRUConfiguration();
- epc.setMaxNodes(1000);
- epc.setTimeToLive(1000000);
- erc.setEvictionPolicyConfig(epc);
- List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
- ercs.add(erc);
- ec.setEvictionRegionConfigs(ercs);
+ LRUAlgorithmConfig lruAlgorithmConfig = new LRUAlgorithmConfig();
+ lruAlgorithmConfig.setMaxNodes(1000);
+ lruAlgorithmConfig.setTimeToLive(1000000);
+ erc.setEvictionAlgorithmConfig(lruAlgorithmConfig);
+ ec.addEvictionRegionConfig(erc);
config.setEvictionConfig(ec);
CacheLoaderConfig clc = new CacheLoaderConfig();
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -13,11 +13,10 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
@@ -29,9 +28,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
/**
@@ -89,26 +86,16 @@
EvictionConfig ec = new EvictionConfig();
ec.setWakeupInterval(1000);
- List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
+ LRUAlgorithmConfig lru = new LRUAlgorithmConfig();
+ lru.setMaxNodes(0);
+ lru.setTimeToLive(5000);
+ ec.setDefaultEvictionRegionConfig(new EvictionRegionConfig(Fqn.ROOT, lru));
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionFqn(RegionManagerImpl.DEFAULT_REGION);
- LRUConfiguration epc = new LRUConfiguration();
- epc.setMaxNodes(0);
- epc.setTimeToLive(5000);
- erc.setEvictionPolicyConfig(epc);
- ercs.add(erc);
+ lru = new LRUAlgorithmConfig();
+ lru.setMaxNodes(0);
+ lru.setTimeToLive(1000);
+ ec.addEvictionRegionConfig(new EvictionRegionConfig(BASE, lru));
- erc = new EvictionRegionConfig();
- erc.setRegionFqn(BASE);
- epc = new LRUConfiguration();
- epc.setMaxNodes(0);
- epc.setTimeToLive(1000);
- erc.setEvictionPolicyConfig(epc);
- ercs.add(erc);
-
- ec.setEvictionRegionConfigs(ercs);
-
cache.getConfiguration().setEvictionConfig(ec);
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -34,8 +34,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.LRUPolicy;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
@@ -51,9 +50,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.LinkedList;
-import java.util.List;
-
@Test(groups = "functional")
public class ReplicatedPassivationIntegrationTest
{
@@ -117,27 +113,23 @@
EvictionConfig cfg = new EvictionConfig();
cfg.setWakeupInterval(1000);
cfg.setDefaultEventQueueSize(200000);
- cfg.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
- List<EvictionRegionConfig> erc = new LinkedList<EvictionRegionConfig>();
- cfg.setEvictionRegionConfigs(erc);
EvictionRegionConfig region1 = new EvictionRegionConfig();
region1.setRegionFqn(Fqn.ROOT);
- LRUConfiguration epc1 = new LRUConfiguration();
+ LRUAlgorithmConfig epc1 = new LRUAlgorithmConfig();
epc1.setMaxNodes(5000);
epc1.setTimeToLive(3000);
- region1.setEvictionPolicyConfig(epc1);
+ region1.setEvictionAlgorithmConfig(epc1);
+ cfg.setDefaultEvictionRegionConfig(region1);
EvictionRegionConfig region2 = new EvictionRegionConfig();
region2.setRegionFqn(base);
- LRUConfiguration epc2 = new LRUConfiguration();
+ LRUAlgorithmConfig epc2 = new LRUAlgorithmConfig();
epc2.setMaxNodes(100);
epc2.setTimeToLive(3000);
- region2.setEvictionPolicyConfig(epc2);
+ region2.setEvictionAlgorithmConfig(epc2);
+ cfg.addEvictionRegionConfig(region2);
- erc.add(region1);
- erc.add(region2);
-
return cfg;
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -14,6 +14,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.Region;
+import org.jboss.cache.RegionImpl;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -482,13 +483,13 @@
cache2.start();
caches.put("evict2", cache2);
- Region region = cache2.getRegion(Fqn.ROOT, false);
+ RegionImpl region = (RegionImpl) cache2.getRegion(Fqn.ROOT, false);
// We expect a VISIT event for / and ADD events for /a, /a/b and /a/b/c
- int nodeEventQueueSize = region.nodeEventQueueSize();
+ int nodeEventQueueSize = region.getEvictionEventQueue().size();
int i = 0;
- while (region.nodeEventQueueSize() > 0)
+ while (nodeEventQueueSize > 0)
{
- System.out.println(++i + ") Queue contains : " + region.takeLastEventNode());
+ System.out.println(++i + ") Queue contains : " + region.getEvictionEventQueue().poll(0, TimeUnit.MILLISECONDS));
}
assertEquals("Saw the expected number of node events", 4, nodeEventQueueSize);
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java 2008-08-15 10:59:40 UTC (rev 6562)
@@ -8,7 +8,7 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.EvictionTimerTask;
-import org.jboss.cache.eviction.LRUConfiguration;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.util.TestingUtil;
import java.lang.reflect.Method;
@@ -69,9 +69,9 @@
throw new IllegalStateException("No such region!");
}
long ttl = 0;
- if (erConfig.getEvictionPolicyConfig() instanceof LRUConfiguration)
+ if (erConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig)
{
- LRUConfiguration configuration = (LRUConfiguration) erConfig.getEvictionPolicyConfig();
+ LRUAlgorithmConfig configuration = (LRUAlgorithmConfig) erConfig.getEvictionAlgorithmConfig();
ttl = configuration.getTimeToLive();
}
else
Modified: core/trunk/src/test/resources/unit-test-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-14 19:16:15 UTC (rev 6561)
+++ core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-15 10:59:40 UTC (rev 6562)
@@ -2,7 +2,7 @@
<jbosscache>
-
+
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<serialization useRegionBasedMarshalling="false"/>
@@ -11,18 +11,18 @@
<replication>
<sync replTimeout="15000"/>
</replication>
- <eviction wakeUpInterval="2000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy">
- <default>
+ <eviction wakeUpInterval="2000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
<attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">1000</attribute>
+ <attribute name="timeToLive">1000</attribute>
</default>
<region name="/org/jboss/data">
<attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">1000</attribute>
+ <attribute name="timeToLive">1000</attribute>
</region>
<region name="/org/jboss/test/data">
<attribute name="maxNodes">5</attribute>
- <attribute name="timeToLiveSeconds">4</attribute>
+ <attribute name="timeToLive">4</attribute>
</region>
</eviction>
<loaders passivation="true" shared="false">
16 years, 4 months
JBoss Cache SVN: r6561 - in pojo/trunk/src: test/java/org/jboss/cache/pojo and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-08-14 15:16:15 -0400 (Thu, 14 Aug 2008)
New Revision: 6561
Modified:
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSetImpl.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
Log:
Rmove SPI use from Set
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSetImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSetImpl.java 2008-08-14 10:54:25 UTC (rev 6560)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSetImpl.java 2008-08-14 19:16:15 UTC (rev 6561)
@@ -116,9 +116,9 @@
return false;
}
- public Iterator iterator()
+ public Iterator<Object> iterator()
{
- Node node = cache.getRoot().getChild(getFqn());
+ Node<Object, Object> node = cache.getRoot().getChild(getFqn());
if (node == null)
{
return Collections.EMPTY_SET.iterator();
@@ -253,16 +253,16 @@
}
}
- private class IteratorImpl implements Iterator
+ private class IteratorImpl implements Iterator<Object>
{
- private Iterator<NodeSPI> iterator;
+ private Iterator<Node<Object, Object>> iterator;
- private Node node;
+ private Node<Object, Object> node;
private Object o;
- private IteratorImpl(Node node)
+ private IteratorImpl(Node<Object, Object> node)
{
- Collection<NodeSPI> children = new HashSet<NodeSPI>(((NodeSPI) node).getChildrenDirect());
+ Collection<Node<Object, Object>> children = new HashSet<Node<Object, Object>>(node.getChildren());
iterator = children.iterator();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-14 10:54:25 UTC (rev 6560)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-14 19:16:15 UTC (rev 6561)
@@ -17,6 +17,9 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.aop.proxy.ClassProxy;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.pojo.impl.PojoReference;
import org.jboss.cache.pojo.test.Address;
import org.jboss.cache.pojo.test.DoubleRef;
@@ -45,8 +48,11 @@
{
log.info("setUp() ....");
String configFile = "configs/local-tx.xml";
+ XmlConfigurationParser parser = new XmlConfigurationParser();
+ Configuration expected = parser.parseFile(configFile);
+ //expected.setNodeLockingScheme(NodeLockingScheme.MVCC);
boolean toStart = false;
- cache_ = PojoCacheFactory.createCache(configFile, toStart);
+ cache_ = PojoCacheFactory.createCache(expected, toStart);
cache_.start();
}
@@ -62,7 +68,7 @@
{
return createPerson(id, name, age, null);
}
-
+
private Person createPerson(String id, String name, int age, Map<String, String> finalMap)
{
Person p = new Person(finalMap);
@@ -196,7 +202,7 @@
{
fail("Final map is not an instance of ClassProxy");
}
-
+
map.put("test1", "testa");
map.put("test2", "testb");
@@ -408,14 +414,14 @@
PojoReference ref = (PojoReference) cache_.getCache().get(fqn, PojoReference.KEY);
assertTrue(cache_.exists(ref.getFqn()));
}
-
+
public void testDoubleRef() throws Exception
{
DoubleRef ref = new DoubleRef();
cache_.attach("/test", ref);
AssertJUnit.assertSame(ref.getOne(), ref.getTwo());
-
+
ref.setOne(null);
ref.setTwo(null);
}
16 years, 4 months
JBoss Cache SVN: r6560 - core/trunk/src/main/resources/config-samples.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-14 06:54:25 -0400 (Thu, 14 Aug 2008)
New Revision: 6560
Modified:
core/trunk/src/main/resources/config-samples/invalidation-async.xml
Log:
enabled bundling for async replication
Modified: core/trunk/src/main/resources/config-samples/invalidation-async.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-08-14 07:40:56 UTC (rev 6559)
+++ core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-08-14 10:54:25 UTC (rev 6560)
@@ -29,7 +29,7 @@
<transport clusterName="JBossCache-Cluster">
<!-- JGroups protocol stack properties. -->
<jgroupsConfig>
- <TCP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="true"
+ <TCP discard_incompatible_packets="true" enable_bundling="true" enable_diagnostics="true"
enable_unicast_bundling="true" loopback="false" max_bundle_size="64000" max_bundle_timeout="30"
oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
oob_thread_pool.min_threads="2" oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="10"
16 years, 4 months
JBoss Cache SVN: r6559 - core/trunk/src/main/java/org/jboss/cache/invocation.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-14 03:40:56 -0400 (Thu, 14 Aug 2008)
New Revision: 6559
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
Log:
Construct looked up nodes lazily.
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-14 02:46:39 UTC (rev 6558)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-14 07:40:56 UTC (rev 6559)
@@ -5,6 +5,7 @@
import org.jboss.cache.transaction.MVCCTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -16,7 +17,7 @@
*/
public class MVCCInvocationContext extends AbstractInvocationContext
{
- private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>(4);
+ private Map<Fqn, NodeSPI> lookedUpNodes = null;
private MVCCTransactionContext mvccTCtx;
@Override
@@ -38,7 +39,7 @@
public NodeSPI lookUpNode(Fqn fqn)
{
if (mvccTCtx != null) return mvccTCtx.lookUpNode(fqn);
- return lookedUpNodes.get(fqn);
+ return lookedUpNodes == null ? null : lookedUpNodes.get(fqn);
}
/**
@@ -55,7 +56,10 @@
if (mvccTCtx != null)
mvccTCtx.putLookedUpNode(f, n);
else
+ {
+ if (lookedUpNodes == null) lookedUpNodes = new HashMap<Fqn, NodeSPI>(4);
lookedUpNodes.put(f, n);
+ }
}
/**
@@ -69,7 +73,8 @@
// if (mvccTCtx != null)
// mvccTCtx.clearLookedUpNodes();
// else
- lookedUpNodes.clear();
+
+ if (lookedUpNodes != null) lookedUpNodes.clear();
}
/**
@@ -80,10 +85,11 @@
*
* @return a map of looked up nodes.
*/
+ @SuppressWarnings("unchecked")
public Map<Fqn, NodeSPI> getLookedUpNodes()
{
if (mvccTCtx != null) return mvccTCtx.getLookedUpNodes();
- return lookedUpNodes;
+ return (Map<Fqn, NodeSPI>) (lookedUpNodes == null ? Collections.emptyMap() : lookedUpNodes);
}
@Override
16 years, 4 months
JBoss Cache SVN: r6558 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-08-13 22:46:39 -0400 (Wed, 13 Aug 2008)
New Revision: 6558
Modified:
core/trunk/pom.xml
Log:
Use a version of commons-logging that is not completely broken
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-08-14 02:46:03 UTC (rev 6557)
+++ core/trunk/pom.xml 2008-08-14 02:46:39 UTC (rev 6558)
@@ -41,7 +41,7 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
16 years, 4 months
JBoss Cache SVN: r6557 - in pojo/trunk: src/main/java/org/jboss/cache/pojo and 17 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-08-13 22:46:03 -0400 (Wed, 13 Aug 2008)
New Revision: 6557
Removed:
pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransfer200AopTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransferAopTestBase.java
Modified:
pojo/trunk/pom.xml
pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/AbstractOptimisticTestCase.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java
Log:
Update to be compatible with core API changes
Update to commons logging 1.1.1
Drop two old out-of-date tests
Modified: pojo/trunk/pom.xml
===================================================================
--- pojo/trunk/pom.xml 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/pom.xml 2008-08-14 02:46:03 UTC (rev 6557)
@@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-pojo-version>2.2.0-SNAPSHOT</jbosscache-pojo-version>
- <jbosscache-core-version>2.2.0.CR6</jbosscache-core-version>
- <jboss.aop.version>2.0.0.CR14</jboss.aop.version>
+ <jbosscache-pojo-version>3.0.0-SNAPSHOT</jbosscache-pojo-version>
+ <jbosscache-core-version>3.0.0.ALPHA2</jbosscache-core-version>
+ <jboss.aop.version>2.0.0.CR15</jboss.aop.version>
</properties>
<parent>
<groupId>org.jboss.cache</groupId>
@@ -40,7 +40,7 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.jcip</groupId>
@@ -115,7 +115,7 @@
</systemProperties>
<groups>functional</groups>
<forkMode>always</forkMode>
- <argLine>-Djboss.aop.path=${basedir}/src/main/resources/META-INF/pojocache-aop.xml -javaagent:${settings.localRepository}/org/jboss/aop/jboss-aop/${jboss.aop.version}/jboss-aop-${jboss.aop.version}.jar</argLine>
+ <argLine>-Djbosscache.config.validate=false -Djboss.aop.path=${basedir}/src/main/resources/META-INF/pojocache-aop.xml -javaagent:${settings.localRepository}/org/jboss/aop/jboss-aop/${jboss.aop.version}/jboss-aop-${jboss.aop.version}.jar</argLine>
<!-- Warning, this does not work right on 2.4-SNAPSHOT, (see SUREFIRE-349) -->
<!-- This seems to fail in some cases on 2.3 as well, disable for now -->
<useSystemClassLoader>true</useSystemClassLoader>
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -83,7 +83,7 @@
* @return Existing POJO or null if there is none.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Object attach(Fqn<?> id, Object pojo) throws PojoCacheException;
+ Object attach(Fqn id, Object pojo) throws PojoCacheException;
/**
* Remove POJO object from the cache.
@@ -102,7 +102,7 @@
* @return Original value object from this node.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Object detach(Fqn<?> id) throws PojoCacheException;
+ Object detach(Fqn id) throws PojoCacheException;
/**
* Return the <code>Fqn</code> of the internal node containing the data of this attached object.
@@ -116,7 +116,7 @@
* @return <code>Fqn</code> of the internal data node. <code>null</code> if the object is
* immediate, serializable, or not in the cache.
*/
- Fqn<?> getInternalFqn(Object object);
+ Fqn getInternalFqn(Object object);
/**
* Return a list of the references from attached objects to this object. For each reference it
@@ -147,7 +147,7 @@
* @param id the location in the cache to examine
* @return true if an attached object exists, false if not
*/
- boolean exists(Fqn<?> id);
+ boolean exists(Fqn id);
/**
* Retrieve POJO from the cache system. Return null if object does not exist in the cache.
@@ -168,7 +168,7 @@
* @return Current content value. Null if does not exist.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Object find(Fqn<?> id) throws PojoCacheException;
+ Object find(Fqn id) throws PojoCacheException;
/**
* Query all managed POJO objects under the id recursively. Note that this will not return
@@ -181,7 +181,7 @@
* @return Map of all POJOs found with (id, POJO) pair. Return size of 0, if not found.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Map<Fqn<?>, Object> findAll(String id) throws PojoCacheException;
+ Map<Fqn, Object> findAll(String id) throws PojoCacheException;
/**
* Query all managed POJO objects under the id recursively. Note that this will not return
@@ -195,7 +195,7 @@
* @return Map of all POJOs found with (id, POJO) pair. Return size of 0, if not found.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Map<Fqn<?>, Object> findAll(Fqn<?> id) throws PojoCacheException;
+ Map<Fqn, Object> findAll(Fqn id) throws PojoCacheException;
/**
* Lifecycle method to start PojoCache.
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -37,7 +37,7 @@
*
* @return <code>Fqn</code> of the referring node.
*/
- public Fqn<?> getFqn();
+ public Fqn getFqn();
/**
* Returns the name of the node key which references the attached object, or null
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -37,18 +37,18 @@
{
private static final String LENGTH = "ARRAY.LENGTH";
protected PojoCacheImpl cache;
- protected Fqn<?> fqn;
+ protected Fqn fqn;
private int length = -1;
private Class<?> type;
- public static CachedArray load(Fqn<?> fqn, PojoCacheImpl cache, Class<?> type)
+ public static CachedArray load(Fqn fqn, PojoCacheImpl cache, Class<?> type)
{
boolean primitive = CachedType.isImmediate(type.getComponentType());
CachedArray array = primitive ? new CachedPrimitiveArray(fqn, type, cache) : new CachedObjectArray(fqn, type, cache);
return array;
}
- public static CachedArray create(Fqn<?> fqn, PojoCacheImpl cache, Object originalArray)
+ public static CachedArray create(Fqn fqn, PojoCacheImpl cache, Object originalArray)
{
Class<?> type = originalArray.getClass();
assert type.isArray();
@@ -67,14 +67,14 @@
return array;
}
- protected CachedArray(Fqn<?> fqn, Class<?> type, PojoCacheImpl cache)
+ protected CachedArray(Fqn fqn, Class<?> type, PojoCacheImpl cache)
{
this.fqn = fqn;
this.type = type;
this.cache = cache;
}
- public Fqn<?> getFqn()
+ public Fqn getFqn()
{
return fqn;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -54,7 +54,7 @@
throw new PojoCacheException("Non-serializable for " + relative.getClass().getName());
}
- return new Fqn(baseFqn, relative);
+ return Fqn.fromRelativeElements(baseFqn, relative);
}
private Fqn getFqn()
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -40,14 +40,14 @@
// so that multi-dimensional arrays can be handled properly
private static ArrayInterceptable arraySource = new ArrayInterceptable() {};
- protected CachedObjectArray(Fqn<?> fqn, Class<?> type, PojoCacheImpl cache)
+ protected CachedObjectArray(Fqn fqn, Class<?> type, PojoCacheImpl cache)
{
super(fqn, type, cache);
}
public void set(int index, Object element)
{
- Fqn<?> fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
+ Fqn fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
cache.attach(fqn, Null.toNullObject(element), null, arraySource);
cache.getCache().put(fqn, InternalConstant.POJOCACHE_OPERATION, "SET");
@@ -55,7 +55,7 @@
public Object get(int index)
{
- Fqn<?> fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
+ Fqn fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
return Null.toNullValue(cache.find(fqn, null, arraySource));
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -34,7 +34,7 @@
{
private static final String ELEMENT = "ARRAY.PELEMENT.";
- protected CachedPrimitiveArray(Fqn<?> fqn, Class<?> type, PojoCacheImpl cache)
+ protected CachedPrimitiveArray(Fqn fqn, Class<?> type, PojoCacheImpl cache)
{
super(fqn, type, cache);
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -34,11 +34,11 @@
protected abstract boolean handles(Class<?> clazz);
- protected abstract Object remove(Fqn<?> fqn, Reference reference, Object result);
+ protected abstract Object remove(Fqn fqn, Reference reference, Object result);
- protected abstract void put(Fqn<?> fqn, Reference reference, Object obj);
+ protected abstract void put(Fqn fqn, Reference reference, Object obj);
- protected abstract Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojoInstance);
+ protected abstract Object get(Fqn fqn, Class<?> clazz, PojoInstance pojoInstance);
- protected abstract Fqn<?> getFqn(Object obj);
+ protected abstract Fqn getFqn(Object obj);
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -64,7 +64,7 @@
}
@Override
- protected Fqn<?> getFqn(Object obj)
+ protected Fqn getFqn(Object obj)
{
if (obj instanceof Advised)
{
@@ -82,7 +82,7 @@
}
@Override
- protected Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
+ protected Object get(Fqn fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
{
CachedType type = pCache_.getCachedType(clazz);
Object obj = Instantiator.newInstance(clazz);
@@ -117,7 +117,7 @@
}
@Override
- protected void put(Fqn<?> fqn, Reference reference, Object obj) throws CacheException
+ protected void put(Fqn fqn, Reference reference, Object obj) throws CacheException
{
CachedType type = pCache_.getCachedType(obj.getClass());
// We have a clean slate then.
@@ -202,7 +202,7 @@
}
@Override
- protected Object remove(Fqn<?> fqn, Reference referencingFqn, Object result) throws CacheException
+ protected Object remove(Fqn fqn, Reference referencingFqn, Object result) throws CacheException
{
CachedType type = pCache_.getCachedType(result.getClass());
InstanceAdvisor advisor = ((Advised) result)._getInstanceAdvisor();
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -41,14 +41,14 @@
this.cache = cache;
}
- protected Fqn<?> getFqn(Object array)
+ protected Fqn getFqn(Object array)
{
CachedArray cached = CachedArrayRegistry.lookup(array);
return cached != null ? cached.getFqn() : null;
}
@Override
- protected void put(Fqn<?> fqn, Reference reference, Object obj)
+ protected void put(Fqn fqn, Reference reference, Object obj)
{
// Always initialize the ref count so that we can mark this as an AopNode.
PojoInstance pojoInstance = InternalHelper.initializeAopInstance(reference);
@@ -61,7 +61,7 @@
}
@Override
- protected Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojo)
+ protected Object get(Fqn fqn, Class<?> clazz, PojoInstance pojo)
{
CachedArray cached = CachedArray.load(fqn, cache, clazz);
Object array = cached.toArray();
@@ -71,7 +71,7 @@
}
@Override
- protected Object remove(Fqn<?> fqn, Reference referencingFqn, Object obj)
+ protected Object remove(Fqn fqn, Reference referencingFqn, Object obj)
{
CachedArray cached = CachedArrayRegistry.lookup(obj);
if (cached != null) {
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -42,7 +42,7 @@
internal_ = internal;
}
- protected Fqn<?> getFqn(Object collection)
+ protected Fqn getFqn(Object collection)
{
if (! (collection instanceof ClassProxy))
return null;
@@ -266,7 +266,7 @@
}
@Override
- protected Object remove(Fqn<?> fqn, Reference referencingFqn, Object obj) throws CacheException
+ protected Object remove(Fqn fqn, Reference referencingFqn, Object obj) throws CacheException
{
if (!(obj instanceof ClassProxy))
{
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -21,9 +21,9 @@
public static final String SERIALIZED = "__SERIALIZED__";
public static final String JBOSS_INTERNAL_STRING = "__JBossInternal__";
public static final String JBOSS_INTERNAL_ID_SEP_STRING = "_ID_";
- public static final Fqn<String> JBOSS_INTERNAL = new Fqn<String>(JBOSS_INTERNAL_STRING);
- public static final Fqn<String> JBOSS_INTERNAL_ID_SEP = new Fqn<String>(JBOSS_INTERNAL_ID_SEP_STRING);
- public static final Fqn<String> JBOSS_INTERNAL_MAP = new Fqn<String>(InternalConstant.JBOSS_INTERNAL, "__RefMap__");
+ public static final Fqn JBOSS_INTERNAL = Fqn.fromString(JBOSS_INTERNAL_STRING);
+ public static final Fqn JBOSS_INTERNAL_ID_SEP = Fqn.fromString(JBOSS_INTERNAL_ID_SEP_STRING);
+ public static final Fqn JBOSS_INTERNAL_MAP = Fqn.fromRelativeElements(InternalConstant.JBOSS_INTERNAL, "__RefMap__");
public static final String JBOSS_INTERNAL_STATIC = "__jboss:static__";
public static final String POJOCACHE_KEY_PREFIX = "POJOCache.";
public static final String POJOCACHE_STATUS = POJOCACHE_KEY_PREFIX + "Status";
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -279,7 +279,7 @@
throw new IllegalStateException("InternalDelegate.getInternalFqn(). fqn is either null or empty!");
String indirectFqn = getIndirectFqn(fqn);
- return new Fqn(InternalConstant.JBOSS_INTERNAL_MAP, indirectFqn);
+ return Fqn.fromRelativeElements(InternalConstant.JBOSS_INTERNAL_MAP, indirectFqn);
// return JBOSS_INTERNAL_MAP;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -33,7 +33,7 @@
internal_ = internal;
}
- protected Fqn<?> getFqn(Object obj)
+ protected Fqn getFqn(Object obj)
{
return null;
}
@@ -44,7 +44,7 @@
}
@Override
- protected Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
+ protected Object get(Fqn fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
{
// Note this is actually the aliasFqn, not the real fqn!
Object obj;
@@ -58,12 +58,12 @@
}
@Override
- protected void put(Fqn<?> fqn, Reference reference, Object obj) throws CacheException
+ protected void put(Fqn fqn, Reference reference, Object obj) throws CacheException
{
setupRefCounting(fqn, reference);
}
- boolean isMultipleReferenced(Fqn<?> internalFqn)
+ boolean isMultipleReferenced(Fqn internalFqn)
{
// Note this is actually the aliasFqn, not the real fqn!
PojoInstance pojoInstance = null;
@@ -81,7 +81,7 @@
}
@Override
- protected Object remove(Fqn<?> fqn, Reference reference, Object pojo)
+ protected Object remove(Fqn fqn, Reference reference, Object pojo)
throws CacheException
{
if (log.isDebugEnabled())
@@ -97,7 +97,7 @@
/**
* Remove the object from the the reference fqn, meaning just decrement the ref counter.
*/
- private void removeFromReference(Fqn<?> originalFqn, Reference reference) throws CacheException
+ private void removeFromReference(Fqn originalFqn, Reference reference) throws CacheException
{
if (decrementRefCount(originalFqn, reference) == PojoInstance.INITIAL_COUNTER_VALUE)
{
@@ -114,18 +114,18 @@
* @param fqn The original fqn node
* @param refFqn The new internal fqn node
*/
- private void setupRefCounting(Fqn<?> fqn, Reference reference) throws CacheException
+ private void setupRefCounting(Fqn fqn, Reference reference) throws CacheException
{
// increment the reference counting
incrementRefCount(fqn, reference);
}
- private int incrementRefCount(Fqn<?> originalFqn, Reference reference) throws CacheException
+ private int incrementRefCount(Fqn originalFqn, Reference reference) throws CacheException
{
return internal_.incrementRefCount(originalFqn, reference);
}
- private int decrementRefCount(Fqn<?> originalFqn, Reference reference) throws CacheException
+ private int decrementRefCount(Fqn originalFqn, Reference reference) throws CacheException
{
return internal_.decrementRefCount(originalFqn, reference);
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -120,7 +120,7 @@
return oldValue;// we are done
AbstractHandler handler = getHandler(obj.getClass(), allowArray);
- Fqn<?> internalFqn = handler.getFqn(obj);
+ Fqn internalFqn = handler.getFqn(obj);
Reference reference = new ReferenceImpl(fqn, field);
if (internalFqn != null)
@@ -232,7 +232,7 @@
return null;
}
- Fqn<?> internalFqn = pojoReference.getFqn();
+ Fqn internalFqn = pojoReference.getFqn();
@@ -285,9 +285,9 @@
return map;
}
- private Object getObjectInternal(Fqn<?> fqn, String field, Object source) throws CacheException
+ private Object getObjectInternal(Fqn fqn, String field, Object source) throws CacheException
{
- Fqn<?> internalFqn = fqn;
+ Fqn internalFqn = fqn;
PojoReference pojoReference = internal_.getPojoReference(fqn, field);
if (pojoReference != null)
{
@@ -347,21 +347,21 @@
}
}
- public boolean exists(Fqn<?> id)
+ public boolean exists(Fqn id)
{
return internal_.getPojoReference(id, null) != null || internal_.getPojoInstance(id) != null;
}
- public Fqn<?> getInternalFqn(Object object)
+ public Fqn getInternalFqn(Object object)
{
AbstractHandler handler = getHandler(object.getClass(), true);
- Fqn<?> internalFqn = handler.getFqn(object);
+ Fqn internalFqn = handler.getFqn(object);
return internalFqn;
}
public Collection<Reference> getReferences(Object object)
{
- Fqn<?> fqn = getInternalFqn(object);
+ Fqn fqn = getInternalFqn(object);
if (fqn == null)
return Collections.emptyList();
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -8,7 +8,6 @@
package org.jboss.cache.pojo.impl;
import java.util.Collection;
-import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.regex.Pattern;
@@ -26,7 +25,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Version;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.OldFileFormatException;
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.pojo.PojoCache;
import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.PojoCacheThreadContext;
@@ -64,6 +65,12 @@
init(expected, toStart);
}
+ catch (OldFileFormatException e)
+ {
+ log_.warn("Detected legacy configuration file format when parsing [" + configStr + "]. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
+ XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
+ init(oldParser.parseFile(configStr), toStart);
+ }
catch (Exception e)
{
throw new PojoCacheException("Failed to start " + configStr, e);
@@ -79,7 +86,7 @@
{
try
{
- cache = (CacheSPI<Object, Object>) DefaultCacheFactory.getInstance().createCache(config, toStart);
+ cache = (CacheSPI<Object, Object>) (new DefaultCacheFactory()).createCache(config, toStart);
}
catch (Exception e)
{
@@ -99,12 +106,12 @@
return attach(Fqn.fromString(id), pojo);
}
- public Object attach(Fqn<?> id, Object pojo) throws PojoCacheException
+ public Object attach(Fqn id, Object pojo) throws PojoCacheException
{
return attach(id, pojo, null, null);
}
- public Object attach(Fqn<?> id, Object pojo, String field, Object source) throws PojoCacheException
+ public Object attach(Fqn id, Object pojo, String field, Object source) throws PojoCacheException
{
TransactionManager tm = getTransactionManager();
boolean createdTransaction = setupTransaction(tm);
@@ -125,7 +132,7 @@
}
}
- public Object detach(Fqn<?> id, String field, Object source) throws PojoCacheException
+ public Object detach(Fqn id, String field, Object source) throws PojoCacheException
{
TransactionManager tm = getTransactionManager();
boolean createdTransaction = setupTransaction(tm);
@@ -146,7 +153,7 @@
}
}
- private void endTransaction(TransactionManager tm, Fqn<?> id)
+ private void endTransaction(TransactionManager tm, Fqn id)
{
try
{
@@ -222,12 +229,12 @@
- public Object detach(Fqn<?> id) throws PojoCacheException
+ public Object detach(Fqn id) throws PojoCacheException
{
return detach(id, null, null);
}
- public Fqn<?> getInternalFqn(Object object)
+ public Fqn getInternalFqn(Object object)
{
return delegate_.getInternalFqn(object);
}
@@ -237,7 +244,7 @@
return delegate_.getReferences(object);
}
- public boolean exists(Fqn<?> id)
+ public boolean exists(Fqn id)
{
return delegate_.exists(id);
}
@@ -247,7 +254,7 @@
return find(Fqn.fromString(id));
}
- public Object find(Fqn<?> id) throws PojoCacheException
+ public Object find(Fqn id) throws PojoCacheException
{
try
{
@@ -259,18 +266,18 @@
}
}
- public Object find(Fqn<?> id, String field, Object source) throws CacheException
+ public Object find(Fqn id, String field, Object source) throws CacheException
{
return delegate_.getObject(id, field, source);
}
- public Map<Fqn<?>, Object> findAll(String id) throws PojoCacheException
+ public Map<Fqn, Object> findAll(String id) throws PojoCacheException
{
return findAll(Fqn.fromString(id));
}
- public Map<Fqn<?>, Object> findAll(Fqn<?> id) throws PojoCacheException
+ public Map<Fqn, Object> findAll(Fqn id) throws PojoCacheException
{
// Should produce "/"
if (id == null) id = Fqn.ROOT;
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -40,10 +40,10 @@
{
private static final long serialVersionUID = 2647262858847953704L;
- private Fqn<?> fqn;
+ private Fqn fqn;
private String key;
- public ReferenceImpl(Fqn<?> fqn)
+ public ReferenceImpl(Fqn fqn)
{
this(fqn, null);
}
@@ -52,7 +52,7 @@
* @param fqn <code>Fqn</code> of the referring node. Cannot be <code>null</code>.
* @param key Name of the field, index in the field or key in the collection that is containing the reference.
*/
- public ReferenceImpl(Fqn<?> fqn, String key)
+ public ReferenceImpl(Fqn fqn, String key)
{
if (fqn == null)
throw new IllegalArgumentException("Fqn can not be null!!");
@@ -66,7 +66,7 @@
return key;
}
- public Fqn<?> getFqn()
+ public Fqn getFqn()
{
return fqn;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -38,7 +38,7 @@
internal_ = internal;
}
- protected Fqn<?> getFqn(Object obj)
+ protected Fqn getFqn(Object obj)
{
// Not supported
return null;
@@ -59,7 +59,7 @@
@Override
- protected void put(Fqn<?> fqn, Reference reference, Object obj) throws CacheException
+ protected void put(Fqn fqn, Reference reference, Object obj) throws CacheException
{
// Note that JBoss Serialization can serialize any type now.
if (log_.isDebugEnabled())
@@ -87,7 +87,7 @@
}
@Override
- protected Object remove(Fqn<?> fqn, Reference reference, Object result) throws CacheException
+ protected Object remove(Fqn fqn, Reference reference, Object result) throws CacheException
{
cache.removeNode(fqn);
return result;
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -12,7 +12,7 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.InvocationContext;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
/**
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -21,6 +21,22 @@
*/
package org.jboss.cache.pojo.jmx;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.AttributeChangeNotification;
+import javax.management.JMException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.transaction.TransactionManager;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
@@ -31,7 +47,10 @@
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.RuntimeConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.JGroupsStackParser;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.jmx.CacheNotificationListener;
import org.jboss.cache.pojo.PojoCache;
@@ -44,21 +63,9 @@
import org.jgroups.jmx.JChannelFactoryMBean;
import org.w3c.dom.Element;
-import javax.management.AttributeChangeNotification;
-import javax.management.JMException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.transaction.TransactionManager;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
+
+
public class PojoCacheJmxWrapper
implements PojoCacheJmxWrapperMBean, MBeanRegistration, NotificationEmitter
{
@@ -85,6 +92,11 @@
private Element clusterConfig;
private JChannelFactoryMBean multiplexerService;
+ private BuddyElementParser buddyElementParser = new BuddyElementParser();
+ private LoadersElementParser loadersElementParser = new LoadersElementParser();
+ private EvictionElementParser evictionElementParser = new EvictionElementParser();
+ private JGroupsStackParser stackParser = new JGroupsStackParser();
+
/**
* Default constructor.
*/
@@ -477,7 +489,7 @@
BuddyReplicationConfig brc = null;
if (config != null)
{
- brc = XmlConfigurationParser.parseBuddyReplicationConfig(config);
+ brc = buddyElementParser.parseBuddyElement(config);
}
getConfiguration().setBuddyReplicationConfig(brc);
this.buddyReplConfig = config;
@@ -488,7 +500,7 @@
CacheLoaderConfig clc = null;
if (cache_loader_config != null)
{
- clc = XmlConfigurationParser.parseCacheLoaderConfig(cache_loader_config);
+ clc = loadersElementParser.parseLoadersElement(cache_loader_config);
}
getConfiguration().setCacheLoaderConfig(clc);
this.cacheLoaderConfig = cache_loader_config;
@@ -511,7 +523,7 @@
String props = null;
if (config != null)
{
- props = XmlConfigurationParser.parseClusterConfigXml(config);
+ props = stackParser.parseClusterConfigXml(config);
}
getConfiguration().setClusterConfig(props);
this.clusterConfig = config;
@@ -538,7 +550,7 @@
EvictionConfig ec = null;
if (config != null)
{
- ec = XmlConfigurationParser.parseEvictionConfig(config);
+ ec = evictionElementParser.parseEvictionElement(config);
}
getConfiguration().setEvictionConfig(ec);
this.evictionConfig = config;
@@ -719,7 +731,7 @@
registered = false;
}
- // ---------------------------------------------------- NotificationEmitter
+ // ---------------------------------------------------- NotificationEmitter
public void removeNotificationListener(NotificationListener listener,
NotificationFilter filter,
@@ -849,7 +861,7 @@
CacheJmxWrapper plainCache = new CacheJmxWrapper();
plainCache.setRegisterInterceptors(getRegisterInterceptors());
plainCache.setCache(pojoCache.getCache());
- // It shouldn't send out lifecycle state change notifications for itself;
+ // It shouldn't send out lifecycle state change notifications for itself;
// we do it
plainCache.setDisableStateChangeNotifications(true);
@@ -939,7 +951,7 @@
if (plainCacheWrapper != null)
{
long now = System.currentTimeMillis();
-
+
AttributeChangeNotification stateChangeNotification = new AttributeChangeNotification(
this,
plainCacheWrapper.getNextNotificationSequenceNumber(), now, msg,
@@ -947,7 +959,7 @@
new Integer(oldState), new Integer(newState)
);
stateChangeNotification.setUserData(t);
-
+
plainCacheWrapper.sendNotification(stateChangeNotification);
}
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -134,7 +134,7 @@
// TODO Don't know why. But this will fail the CachedSetAopTest clear() method since look up is always
// Null at the last index. But why?
// TODO also see JBCACHE-282
- return new Fqn(baseFqn, relative.toString());
+ return Fqn.fromRelativeElements(baseFqn, relative.toString());
// String tmp = baseFqn.toString() +"/" + relative.toString();
// return Fqn.fromString(tmp);
@@ -154,7 +154,7 @@
Fqn trueId = null;
if (fqn.hasElement(InternalConstant.JBOSS_INTERNAL_ID_SEP_STRING))
{
- List list = new ArrayList();
+ List<Object> list = new ArrayList<Object>();
for (int i = 0; i < fqn.size(); i++)
{
if (fqn.get(i).equals(InternalConstant.JBOSS_INTERNAL_STRING))
@@ -168,7 +168,7 @@
}
list.add(fqn.get(i));
}
- trueId = new Fqn(list);
+ trueId = Fqn.fromList(list);
}
else
{
@@ -183,9 +183,9 @@
if (region == null || region.getFqn().equals(Fqn.ROOT))
{
// Move id under JBInternal to promote concurrency
- Fqn f0 = new Fqn(InternalConstant.JBOSS_INTERNAL, trueId);
- Fqn f = new Fqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
- return new Fqn(f, Fqn.fromString(guid.toString()));
+ Fqn f0 = Fqn.fromRelativeFqn(InternalConstant.JBOSS_INTERNAL, trueId);
+ Fqn f = Fqn.fromRelativeFqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
+ return Fqn.fromRelativeElements(f, guid.toString());
}
else
{
@@ -193,10 +193,10 @@
Fqn rf = region.getFqn();
// Extract rest of fqn id
Fqn childf = trueId.getSubFqn(rf.size(), trueId.size());
- Fqn f0 = new Fqn(InternalConstant.JBOSS_INTERNAL, childf);
- Fqn f = new Fqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
- Fqn f1 = new Fqn(rf, f);
- return new Fqn(f1, Fqn.fromString(guid.toString()));
+ Fqn f0 = Fqn.fromRelativeFqn(InternalConstant.JBOSS_INTERNAL, childf);
+ Fqn f = Fqn.fromRelativeFqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
+ Fqn f1 = Fqn.fromRelativeFqn(rf, f);
+ return Fqn.fromRelativeElements(f1, guid.toString());
}
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -56,7 +56,7 @@
cache1.start();
cache2 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- //cache2.getCache().addCacheListener(new MyCacheListener(false));
+ cache2.getCache().addCacheListener(new MyCacheListener(false));
cache2.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -40,7 +40,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -28,7 +28,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
@@ -82,7 +82,7 @@
log.info("testNoReferences() ....");
Person joe = createPerson("/person/joe", "Joe Black", 32, null);
- Fqn<?> joesInternalFqn = cache_.getInternalFqn(joe);
+ Fqn joesInternalFqn = cache_.getInternalFqn(joe);
assertTrue("Internal Fqn not null", joesInternalFqn != null);
Collection<Reference> addressReferences = cache_.getReferences(joe);
@@ -97,7 +97,7 @@
Address address = createAddress();
Person joe = createPerson("/person/joe", "Joe Black", 32, address);
- Fqn<?> joesInternalFqn = cache_.getInternalFqn(joe);
+ Fqn joesInternalFqn = cache_.getInternalFqn(joe);
Collection<Reference> addressReferences = cache_.getReferences(address);
assertEquals("Size", 1, addressReferences.size());
@@ -112,8 +112,8 @@
Person joe = createPerson("/person/joe", "Joe Black", 32, address);
Person jane = createPerson("/person/jane", "Jane Black", 32, address);
- Fqn<?> joesInternalFqn = cache_.getInternalFqn(joe);
- Fqn<?> janesInternalFqn = cache_.getInternalFqn(jane);
+ Fqn joesInternalFqn = cache_.getInternalFqn(joe);
+ Fqn janesInternalFqn = cache_.getInternalFqn(jane);
HashSet<Reference> expectedReferences = new HashSet<Reference>(Arrays.<Reference> asList(
new ReferenceImpl(joesInternalFqn, "address"), new ReferenceImpl(janesInternalFqn, "address")));
@@ -129,7 +129,7 @@
DoubleRef doubleRef = new DoubleRef();
cache_.attach("/doubleref", doubleRef);
- Fqn<?> sourceFqn = cache_.getInternalFqn(doubleRef);
+ Fqn sourceFqn = cache_.getInternalFqn(doubleRef);
HashSet<Reference> expectedReferences = new HashSet<Reference>(Arrays.<Reference> asList(
new ReferenceImpl(sourceFqn, "one"), new ReferenceImpl(sourceFqn, "two")));
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -89,7 +89,7 @@
{
cachingMode_ = caching_mode;
boolean toStart = false;
- cache_ = PojoCacheFactory.createCache("META-INF/local-service.xml", toStart);
+ cache_ = PojoCacheFactory.createCache("configs/local-tx.xml", toStart);
cache_.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -44,7 +44,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
@@ -400,7 +400,7 @@
public void testExists() throws Exception
{
- Fqn<String> fqn = Fqn.fromString("/person/test1");
+ Fqn fqn = Fqn.fromString("/person/test1");
createPerson(fqn.toString(), "Joe Black", 32);
assertTrue(cache_.exists(fqn));
assertFalse(cache_.exists(Fqn.fromString("/blah")));
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -51,7 +51,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -38,7 +38,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -177,7 +177,7 @@
addr.addResidents("Ben");
addr.addResidents("Joe");
// Test serialization first
- Fqn<String> fqn = Fqn.fromString("/plain");
+ Fqn fqn = Fqn.fromString("/plain");
cache_.getCache().put(fqn, "test", addr);
cache_.getCache().remove(fqn, "test");
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -28,7 +28,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -27,7 +27,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -13,7 +13,7 @@
@Test(groups = {"functional"})
public class RecursiveRefTest
{
- private static final String CONFIG_FILENAME = "META-INF/local-service.xml";
+ private static final String CONFIG_FILENAME = "configs/local-tx.xml";
private PojoCache cache;
Log log = LogFactory.getLog(RecursiveRefTest.class);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -47,7 +47,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -42,7 +42,7 @@
public void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -40,7 +40,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -48,7 +48,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -50,7 +50,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -34,7 +34,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -39,7 +39,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -595,9 +595,9 @@
private Node getNode(Object[] path)
{
- Fqn<String> fqnToPath;
+ Fqn fqnToPath;
if (path.length == 0) fqnToPath = Fqn.ROOT;
- List<String> elements = convertMyNodeArrayToStringArray(path);
+ List<Object> elements = convertMyNodeArrayToStringArray(path);
fqnToPath = Fqn.fromList(elements);
if (root.hasChild(fqnToPath))
{
@@ -610,9 +610,9 @@
}
}
- private List<String> convertMyNodeArrayToStringArray(Object[] path)
+ private List<Object> convertMyNodeArrayToStringArray(Object[] path)
{
- List<String> list = new LinkedList<String>();
+ List<Object> list = new LinkedList<Object>();
for (Object o : path)
{
JBossCacheGUI.DisplayNode n = (JBossCacheGUI.DisplayNode) o;
@@ -741,7 +741,7 @@
}
}
- private void load(Fqn<String> fqn)
+ private void load(Fqn fqn)
{
try
{
@@ -1153,19 +1153,19 @@
* Adds a new node to the view. Intermediary nodes will be created if they don't yet exist.
* Returns the first node that was created or null if node already existed
*/
- public JBossCacheGUI.DisplayNode add(Fqn<String> fqn)
+ public JBossCacheGUI.DisplayNode add(Fqn fqn)
{
JBossCacheGUI.DisplayNode curr, n, ret = null;
if (fqn == null) return null;
curr = this;
- for (String child_name : fqn.peekElements())
+ for (Object child_name : fqn.peekElements())
{
- n = curr.findChild(child_name);
+ n = curr.findChild(child_name.toString());
if (n == null)
{
- n = new JBossCacheGUI.DisplayNode(child_name);
+ n = new JBossCacheGUI.DisplayNode(child_name.toString());
if (ret == null) ret = n;
curr.add(n);
}
@@ -1184,16 +1184,16 @@
}
- private JBossCacheGUI.DisplayNode findNode(Fqn<String> fqn)
+ private JBossCacheGUI.DisplayNode findNode(Fqn fqn)
{
JBossCacheGUI.DisplayNode curr, n;
if (fqn == null) return null;
curr = this;
- for (String child_name : fqn.peekElements())
+ for (Object child_name : fqn.peekElements())
{
- n = curr.findChild(child_name);
+ n = curr.findChild(child_name.toString());
if (n == null)
{
return null;
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -45,6 +45,7 @@
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.eviction.FIFOConfiguration;
import org.jboss.cache.eviction.FIFOPolicy;
import org.jboss.cache.eviction.LRUConfiguration;
@@ -56,7 +57,6 @@
import org.jboss.cache.loader.jdbm.JdbmCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.transaction.BatchModeTransactionManagerLookup;
-import org.jboss.cache.xml.XmlHelper;
import org.jgroups.ChannelFactory;
import org.jgroups.JChannelFactory;
import org.testng.annotations.Test;
@@ -239,134 +239,120 @@
protected static Element getBuddyReplicationConfig() throws Exception
{
- String xmlString = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n" +
- " <buddyCommunicationTimeout>600000</buddyCommunicationTimeout>\n" +
- " <buddyLocatorClass>org.jboss.cache.buddyreplication.TestBuddyLocator</buddyLocatorClass>\n" +
- " <buddyLocatorProperties>numBuddies = 2</buddyLocatorProperties>\n" +
- " <buddyPoolName>testpool</buddyPoolName>" +
- " <autoDataGravitation>false</autoDataGravitation>\n" +
- " <dataGravitationRemoveOnFind>false</dataGravitationRemoveOnFind>\n" +
- " <dataGravitationSearchBackupTrees>false</dataGravitationSearchBackupTrees>" +
- "</config>";
- return XmlHelper.stringToElement(xmlString);
+ String xmlStr =
+ " <buddy enabled=\"true\" poolName=\"testpool\" communicationTimeout=\"600000\">\n" +
+ " <dataGravitation auto=\"false\" removeOnFind=\"false\" searchBackupTrees=\"false\"/>\n" +
+ " <locator class=\"org.jboss.cache.buddyreplication.TestBuddyLocator\">\n" +
+ " <properties>\n" +
+ " numBuddies = 2\n" +
+ " </properties>\n" +
+ " </locator>\n" +
+ " </buddy>";
+ return XmlConfigHelper.stringToElement(xmlStr);
}
protected static Element getCacheLoaderConfig() throws Exception
{
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload>/foo</preload>\n" +
- "<shared>true</shared>\n" +
- "<cacheloader>\n" +
- "<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- "<properties>" +
- " location=/tmp\n" +
- "</properties>\n" +
- "<async>false</async>\n" +
- "<fetchPersistentState>true</fetchPersistentState>\n" +
- "<ignoreModifications>true</ignoreModifications>\n" +
- "<purgeOnStartup>true</purgeOnStartup>\n" +
- "<singletonStore>" +
- "<enabled>true</enabled>" +
- "</singletonStore>" +
- "</cacheloader>\n" +
- "<cacheloader>\n" +
- "<class>org.jboss.cache.loader.jdbm.JdbmCacheLoader</class>\n" +
- "<properties>" +
- " location=/home/bstansberry\n" +
- "</properties>\n" +
- "<async>true</async>\n" +
- "<fetchPersistentState>false</fetchPersistentState>\n" +
- "<ignoreModifications>false</ignoreModifications>\n" +
- "<purgeOnStartup>false</purgeOnStartup>\n" +
- "<singletonStore>" +
- "<enabled>false</enabled>" +
- "</singletonStore>" +
- "</cacheloader>\n" +
- "</config>";
- return XmlHelper.stringToElement(xml);
+ String xmlStr =
+ " <loaders passivation=\"false\" shared=\"true\">\n" +
+ " <preload>\n" +
+ " <node fqn=\"/foo\"/>\n" +
+ " </preload>\n" +
+ " <loader class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\" fetchPersistentState=\"true\"\n" +
+ " ignoreModifications=\"true\" purgeOnStartup=\"true\">\n" +
+ " <properties>\n" +
+ " location=/tmp\n " +
+ " </properties>\n" +
+ " <singletonStore enabled=\"true\" /> \n" +
+ " </loader>\n" +
+ " <loader class=\"org.jboss.cache.loader.jdbm.JdbmCacheLoader\" async=\"true\" fetchPersistentState=\"false\"\n" +
+ " ignoreModifications=\"false\" purgeOnStartup=\"false\">\n" +
+ " <properties>\n" +
+ " location=/home/bstansberry\n" +
+ " </properties>\n" +
+ " <singletonStore enabled=\"false\" /> \n" +
+ " </loader>\n" +
+ " </loaders>";
+ return XmlConfigHelper.stringToElement(xmlStr);
}
protected static Element getEvictionPolicyConfig() throws Exception
{
- String xml = "<config>\n" +
- "<attribute name=\"wakeUpIntervalSeconds\">5</attribute>\n" +
- "<attribute name=\"eventQueueSize\">20000</attribute>\n" +
- "<attribute name=\"policyClass\">org.jboss.cache.eviction.LRUPolicy</attribute>\n" +
- "<region name=\"/_default_\" eventQueueSize=\"1000\">\n" +
- " <attribute name=\"maxNodes\">5000</attribute>\n" +
- " <attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
- "</region>\n" +
- "<region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
- " <attribute name=\"maxNodes\">5000</attribute>\n" +
- "</region>\n" +
- "<region name=\"/test/\" policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
- " <attribute name=\"maxNodes\">10000</attribute>\n" +
- "</region>\n" +
- "<region name=\"/maxAgeTest/\">\n" +
- " <attribute name=\"maxNodes\">10000</attribute>\n" +
- " <attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
- " <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
- "</region>\n" +
- " </config>\n";
- return XmlHelper.stringToElement(xml);
+ String xmlStr =
+ " <eviction wakeUpInterval=\"5000\" defaultPolicyClass=\"org.jboss.cache.eviction.LRUPolicy\" defaultEventQueueSize=\"20000\">\n" +
+ " <default eventQueueSize=\"1000\">\n" +
+ " <attribute name=\"maxNodes\">5000</attribute>\n" +
+ " <attribute name=\"timeToLive\">1000000</attribute>\n" +
+ " </default>\n" +
+ "<region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
+ " <attribute name=\"maxNodes\">5000</attribute>\n" +
+ "</region>\n" +
+ "<region name=\"/test/\" policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
+ " <attribute name=\"maxNodes\">10000</attribute>\n" +
+ "</region>\n" +
+ "<region name=\"/maxAgeTest/\">\n" +
+ " <attribute name=\"maxNodes\">10000</attribute>\n" +
+ " <attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
+ " <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
+ "</region>\n" +
+ " </eviction>";
+ return XmlConfigHelper.stringToElement(xmlStr);
}
protected static Element getClusterConfig() throws Exception
- {
- String xml =
- "<config>\n" +
- " <UDP mcast_addr=\"228.10.10.10\"\n" +
- " mcast_port=\"45588\"\n" +
- " tos=\"8\"\n" +
- " ucast_recv_buf_size=\"20000000\"\n" +
- " ucast_send_buf_size=\"640000\"\n" +
- " mcast_recv_buf_size=\"25000000\"\n" +
- " mcast_send_buf_size=\"640000\"\n" +
- " loopback=\"false\"\n" +
- " discard_incompatible_packets=\"true\"\n" +
- " max_bundle_size=\"64000\"\n" +
- " max_bundle_timeout=\"30\"\n" +
- " use_incoming_packet_handler=\"true\"\n" +
- " ip_ttl=\"2\"\n" +
- " enable_bundling=\"false\"\n" +
- " enable_diagnostics=\"true\"\n" +
- " use_concurrent_stack=\"true\"\n" +
- " thread_naming_pattern=\"pl\"\n" +
- " thread_pool.enabled=\"true\"\n" +
- " thread_pool.min_threads=\"1\"\n" +
- " thread_pool.max_threads=\"25\"\n" +
- " thread_pool.keep_alive_time=\"30000\"\n" +
- " thread_pool.queue_enabled=\"true\"\n" +
- " thread_pool.queue_max_size=\"10\"\n" +
- " thread_pool.rejection_policy=\"Run\"\n" +
- " oob_thread_pool.enabled=\"true\"\n" +
- " oob_thread_pool.min_threads=\"1\"\n" +
- " oob_thread_pool.max_threads=\"4\"\n" +
- " oob_thread_pool.keep_alive_time=\"10000\"\n" +
- " oob_thread_pool.queue_enabled=\"true\"\n" +
- " oob_thread_pool.queue_max_size=\"10\"\n" +
- " oob_thread_pool.rejection_policy=\"Run\"/>\n" +
- " <PING timeout=\"2000\" num_initial_members=\"3\"/>\n" +
- " <MERGE2 max_interval=\"30000\" min_interval=\"10000\"/>\n" +
- " <FD_SOCK/>\n" +
- " <FD timeout=\"10000\" max_tries=\"5\" shun=\"true\"/>\n" +
- " <VERIFY_SUSPECT timeout=\"1500\"/>\n" +
- " <pbcast.NAKACK max_xmit_size=\"60000\"\n" +
- " use_mcast_xmit=\"false\" gc_lag=\"0\"\n" +
- " retransmit_timeout=\"300,600,1200,2400,4800\"\n" +
- " discard_delivered_msgs=\"true\"/>\n" +
- " <UNICAST timeout=\"300,600,1200,2400,3600\"/>\n" +
- " <pbcast.STABLE stability_delay=\"1000\" desired_avg_gossip=\"50000\"\n" +
- " max_bytes=\"400000\"/>\n" +
- " <pbcast.GMS print_local_addr=\"true\" join_timeout=\"5000\"\n" +
- " join_retry_timeout=\"2000\" shun=\"false\"\n" +
- " view_bundling=\"true\" view_ack_collection_timeout=\"5000\"/>\n" +
- " <FRAG2 frag_size=\"60000\"/>\n" +
- " <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
- " <pbcast.FLUSH timeout=\"0\"/>\n" +
- "</config>";
- return XmlHelper.stringToElement(xml);
+ {String xml =
+ "<jgroupsConfig>\n" +
+ "<UDP mcast_addr=\"228.10.10.10\"\n" +
+ " mcast_port=\"45588\"\n" +
+ " tos=\"8\"\n" +
+ " ucast_recv_buf_size=\"20000000\"\n" +
+ " ucast_send_buf_size=\"640000\"\n" +
+ " mcast_recv_buf_size=\"25000000\"\n" +
+ " mcast_send_buf_size=\"640000\"\n" +
+ " loopback=\"false\"\n" +
+ " discard_incompatible_packets=\"true\"\n" +
+ " max_bundle_size=\"64000\"\n" +
+ " max_bundle_timeout=\"30\"\n" +
+ " use_incoming_packet_handler=\"true\"\n" +
+ " ip_ttl=\"2\"\n" +
+ " enable_bundling=\"false\"\n" +
+ " enable_diagnostics=\"true\"\n" +
+ " use_concurrent_stack=\"true\"\n" +
+ " thread_naming_pattern=\"pl\"\n" +
+ " thread_pool.enabled=\"true\"\n" +
+ " thread_pool.min_threads=\"1\"\n" +
+ " thread_pool.max_threads=\"25\"\n" +
+ " thread_pool.keep_alive_time=\"30000\"\n" +
+ " thread_pool.queue_enabled=\"true\"\n" +
+ " thread_pool.queue_max_size=\"10\"\n" +
+ " thread_pool.rejection_policy=\"Run\"\n" +
+ " oob_thread_pool.enabled=\"true\"\n" +
+ " oob_thread_pool.min_threads=\"1\"\n" +
+ " oob_thread_pool.max_threads=\"4\"\n" +
+ " oob_thread_pool.keep_alive_time=\"10000\"\n" +
+ " oob_thread_pool.queue_enabled=\"true\"\n" +
+ " oob_thread_pool.queue_max_size=\"10\"\n" +
+ " oob_thread_pool.rejection_policy=\"Run\"/>\n" +
+ " <PING timeout=\"2000\" num_initial_members=\"3\"/>\n" +
+ " <MERGE2 max_interval=\"30000\" min_interval=\"10000\"/>\n" +
+ " <FD_SOCK/>\n" +
+ " <FD timeout=\"10000\" max_tries=\"5\" shun=\"true\"/>\n" +
+ " <VERIFY_SUSPECT timeout=\"1500\"/>\n" +
+ " <pbcast.NAKACK max_xmit_size=\"60000\"\n" +
+ " use_mcast_xmit=\"false\" gc_lag=\"0\"\n" +
+ " retransmit_timeout=\"300,600,1200,2400,4800\"\n" +
+ " discard_delivered_msgs=\"true\"/>\n" +
+ " <UNICAST timeout=\"300,600,1200,2400,3600\"/>\n" +
+ " <pbcast.STABLE stability_delay=\"1000\" desired_avg_gossip=\"50000\"\n" +
+ " max_bytes=\"400000\"/>\n" +
+ " <pbcast.GMS print_local_addr=\"true\" join_timeout=\"5000\"\n" +
+ " join_retry_timeout=\"2000\" shun=\"false\"\n" +
+ " view_bundling=\"true\" view_ack_collection_timeout=\"5000\"/>\n" +
+ " <FRAG2 frag_size=\"60000\"/>\n" +
+ " <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
+ " <pbcast.FLUSH timeout=\"0\"/>\n" +
+ "</jgroupsConfig>";
+return XmlConfigHelper.stringToElement(xml);
}
class MockInvocationHandler implements InvocationHandler
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -72,13 +72,13 @@
ClassLoader cla = getClassLoader();
WeakReference<ClassLoader> refa = new WeakReference<ClassLoader>(cla);
- cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(cla);
+ cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(cla);
ClassLoader clb = getClassLoader();
WeakReference<ClassLoader> refb = new WeakReference<ClassLoader>(clb);
- cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clb);
+ cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clb);
- Fqn<String> fqn = new Fqn<String>("/aop");
- cache_.getCache().put(new Fqn<String>("/aop"), "add", add);
+ Fqn fqn = Fqn.fromString("/aop");
+ cache_.getCache().put(Fqn.fromString("/aop"), "add", add);
TestingUtil.sleepThread(100);
try
@@ -97,8 +97,8 @@
ClassLoader clc = getClassLoader();
cla = null;
clb = null;
- cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
- cache1_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
+ cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
+ cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
System.gc(); // force gc
Thread.sleep(1000);
assertNull("Classloader should be gced ", refa.get());
@@ -140,9 +140,9 @@
ClassLoader cla = getClassLoader();
WeakReference<ClassLoader> refa = new WeakReference<ClassLoader>(cla);
- cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(cla);
+ cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(cla);
ClassLoader clb = getClassLoader();
- cache1_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clb);
+ cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clb);
WeakReference<ClassLoader> refb = new WeakReference<ClassLoader>(clb);
cache_.attach("/aop", p);
@@ -161,8 +161,8 @@
cache_.detach("/aop");
ClassLoader clc = getClassLoader();
- cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
- cache1_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
+ cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
+ cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
cla = null;
clb = null;
forceOutOfMemoryError();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -55,7 +55,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -31,7 +31,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -54,7 +54,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -40,7 +40,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -55,7 +55,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -58,7 +58,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/AbstractOptimisticTestCase.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/AbstractOptimisticTestCase.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -31,11 +31,14 @@
import javax.transaction.TransactionManager;
import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.VersionedDataCommand;
+import org.jboss.cache.commands.legacy.ReversibleCommand;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.optimistic.DefaultDataVersion;
@@ -44,7 +47,6 @@
import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.xml.XmlHelper;
import org.testng.annotations.AfterMethod;
import org.w3c.dom.Element;
@@ -56,7 +58,7 @@
private int instanceNumber;
// some test data shared among all the test cases
- protected Fqn<String> fqn = Fqn.fromString("/blah");
+ protected Fqn fqn = Fqn.fromString("/blah");
protected String key = "myKey", value = "myValue";
protected String getTempDir()
@@ -119,30 +121,17 @@
return createCacheWithLoader(false);
}
- protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, String filename, boolean passivation) throws Exception
+ protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, boolean passivation) throws Exception
{
- String xml = " <config>\n" +
- " <passivation>" + passivation + "</passivation>\n" +
- " <preload></preload>\n" +
- " <shared>" + shared + "</shared>\n" +
- " <cacheloader>\n" +
- " <class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- " <properties>\n" +
- " </properties>\n" +
- " <async>false</async>\n" +
- " <fetchPersistentState>" + (!shared) + "</fetchPersistentState>\n" +
- " <ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " </config>";
- Element element = XmlHelper.stringToElement(xml);
- return XmlConfigurationParser.parseCacheLoaderConfig(element);
+ String cacheLoaderClass = shared ? DummySharedInMemoryCacheLoader.class.getName() : DummyInMemoryCacheLoader.class.getName();
+ return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(passivation, null, cacheLoaderClass, "", false, (!shared), shared, false, false);
}
protected PojoCache createCacheWithLoader(boolean passivationEnabled) throws Exception
{
PojoCache cache = createCacheUnstarted();
Configuration c = cache.getCache().getConfiguration();
- c.setCacheLoaderConfig(getCacheLoaderConfig(true, getTempDir(), passivationEnabled));
+ c.setCacheLoaderConfig(getCacheLoaderConfig(true, passivationEnabled));
cache.create();
cache.start();
return cache;
@@ -270,7 +259,7 @@
c.setSyncRollbackPhase(true);
c.setNodeLockingScheme("OPTIMISTIC");
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- c.setCacheLoaderConfig(getCacheLoaderConfig(shared, shared ? getTempDir(name + "-shared") : getTempDir(name + instanceNumber++), false));
+ c.setCacheLoaderConfig(getCacheLoaderConfig(shared, false));
PojoCache cache = PojoCacheFactory.createCache(c, false);
cache.create();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -142,7 +142,7 @@
{
log.info("testFailure1() ....");
UserTransaction tx = getTransaction();
- Fqn<String> f = Fqn.fromString("/person/test2");
+ Fqn f = Fqn.fromString("/person/test2");
tx.begin();
cache.getCache().put(f, "test", "test");
tx.commit();
@@ -155,9 +155,9 @@
public void testFailure2() throws Exception
{
- Fqn<String> f0 = Fqn.fromString("/person/test");
- Fqn<String> f1 = new Fqn<String>(f0, "1");
- Fqn<String> f2 = new Fqn<String>(f0, "2");
+ Fqn f0 = Fqn.fromString("/person/test");
+ Fqn f1 = Fqn.fromRelativeElements(f0, "1");
+ Fqn f2 = Fqn.fromRelativeElements(f0, "2");
cache.getCache().put(f1, "test", "test");
cache.getCache().put(f2, "test", "test");
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -47,7 +47,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/pojocache-passivation-service.xml";
+ String configFile = "configs/local-passivation.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.getCache().getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.BatchModeTransactionManagerLookup");
@@ -101,7 +101,7 @@
cache_.attach(id, joe);
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
assertEquals("age ", 20, joe.getAge());
joe.setAge(30);
@@ -118,7 +118,7 @@
cache_.attach(id, joe);
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
Address addr = new Address();
addr.setCity("Taipei");
@@ -137,7 +137,7 @@
cache_.attach(id, joe);
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
Person p = (Person) cache_.find(id);
@@ -182,7 +182,7 @@
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
assertEquals("City is ", "Santa Clara", add2.getCity());
@@ -268,7 +268,7 @@
@NodeActivated
public void nodeActivated(NodeEvent ne)
{
- Fqn<?> fqn = ne.getFqn();
+ Fqn fqn = ne.getFqn();
if (!ne.isPre())
{
System.out.println("nodeActivated: " + fqn);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -87,7 +87,7 @@
void initCaches() throws Exception
{
boolean toStart = false;
- cache_ = PojoCacheFactory.createCache("META-INF/local-service.xml", toStart);
+ cache_ = PojoCacheFactory.createCache("configs/local-tx.xml", toStart);
cache_.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -52,7 +52,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
@@ -102,8 +102,8 @@
assertEquals((Object) "Joe Black", p.getName());
assertTrue("Region node should exist ",
- cache_.getCache().getRoot().hasChild(new Fqn<String>(REGION)));
- Fqn<String> fqn = new Fqn<String>(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
+ cache_.getCache().getRoot().hasChild(Fqn.fromString(REGION)));
+ Fqn fqn = Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
assertTrue("Internal region node should exist ",
cache_.getCache().getRoot().hasChild(fqn));
//System.out.println("Cache content: " +((org.jboss.cache.CacheImpl<Object, Object>)cache_.getCache()).printDetails());
@@ -125,7 +125,7 @@
//String str = ((CacheImpl<Object, Object>) cache_.getCache()).printDetails();
//System.out.println("**** Details ***/n" + str);
- Fqn<String> fqn = new Fqn<String>(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
+ Fqn fqn = Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
Node<Object, Object> n = cache_.getCache().getRoot().getChild(fqn);
assertTrue("Internal region node should not exist ",
n.getChildren() != null);
@@ -200,7 +200,7 @@
cache_.detach("person/test1");
- Fqn<String> fqn = new Fqn<String>(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
+ Fqn fqn = Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
Node<Object, Object> n = cache_.getCache().getRoot().getChild(fqn);
assertTrue("Internal region node should not exist ",
n.getChildren() != null);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -41,7 +41,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -47,7 +47,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -64,7 +64,7 @@
public void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.getCache().getConfiguration().setLockAcquisitionTimeout(500); // timeout to 500 ms
@@ -173,11 +173,11 @@
{
try
{
- Fqn<String> f = new Fqn<String>(InternalConstant.JBOSS_INTERNAL_STRING);
- cache_.getCache().put(new Fqn<String>(f, "123"), "key", "test");
- cache_.getCache().put(new Fqn<String>("a"), "key", "test");
+ Fqn f = Fqn.fromString(InternalConstant.JBOSS_INTERNAL_STRING);
+ cache_.getCache().put(Fqn.fromRelativeElements(f, "123"), "key", "test");
+ cache_.getCache().put(Fqn.fromString("a"), "key", "test");
tx_mgr.begin();
- cache_.getCache().put(new Fqn<String>(f, "124"), "key", "test");
+ cache_.getCache().put(Fqn.fromRelativeElements(f, "124"), "key", "test");
while (!isTrue)
{
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -45,7 +45,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -58,7 +58,7 @@
private void startTest() throws Exception
{
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Deleted: pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransfer200AopTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransfer200AopTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransfer200AopTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -1,27 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.cache.pojo.statetransfer;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests that PojoCache state transfer works properly if the version is 2.0.0.
- *
- * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-@Test(groups = {"functional"})
-public class StateTransfer200AopTest extends StateTransferAopTestBase
-{
-
- protected String getReplicationVersion()
- {
- return "2.0.0.GA";
- }
-
-}
Deleted: pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransferAopTestBase.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransferAopTestBase.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransferAopTestBase.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -1,1091 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.cache.pojo.statetransfer;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import javax.transaction.TransactionManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Region;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheFactory;
-import org.jboss.cache.pojo.test.Address;
-import org.jboss.cache.pojo.test.Person;
-import org.jboss.cache.xml.XmlHelper;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.w3c.dom.Element;
-
-/**
- * Tests state transfer in PojoCache.
- *
- * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public abstract class StateTransferAopTestBase
-{
- private Map<String, PojoCache> caches;
-
- public static final String A_B_1 = "/a/b/1";
- public static final String A_B_2 = "/a/b/2";
- public static final String A_C_1 = "/a/c/1";
- public static final String A_C_2 = "/a/c/2";
-
- public static final Fqn<String> A_B_1_f = Fqn.fromString("/a/b/1");
- public static final Fqn<String> A_B_2_f = Fqn.fromString("/a/b/2");
- public static final Fqn<String> A_C_1_f = Fqn.fromString("/a/c/1");
- public static final Fqn<String> A_C_2_f = Fqn.fromString("/a/c/2");
-
- private static final int SUBTREE_SIZE = 10;
-
- private Person joe;
- private Person bob;
- private Person jane;
- private Person jill;
- private Address addr1;
- private Address addr2;
-
- public static final Integer TWENTY = 20;
- public static final Integer TWENTYFIVE = 25;
- public static final Integer FORTY = 40;
-
- private Log log = LogFactory.getLog(StateTransferAopTestBase.class);
-
- public void testInitialStateTransfer() throws Exception
- {
- log.info("Enter testInitialStateTransfer");
-
- PojoCache cache1 = createCache("cache1", true, false, false);
-
- cache1.attach(A_B_1, joe);
- cache1.attach(A_B_2, jane);
- cache1.attach(A_C_1, bob);
- cache1.attach(A_C_2, jill);
-
- PojoCache cache2 = createCache("cache2", true, false, false);
-
- // Pause to give caches time to see each other
-// TestingUtil.blockUntilViewsReceived(new Cache[]
-// {cache1.getCache(), cache2.getCache()}, 60000);
-
- Person ab1 = (Person) cache2.find(A_B_1);
- Person ab2 = (Person) cache2.find(A_B_2);
- Person ac1 = (Person) cache2.find(A_C_1);
- Person ac2 = (Person) cache2.find(A_C_2);
- assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getAddress().getCity());
- assertEquals("Name for /a/b/2 is Jane", jane.getName(), ab2.getName());
- assertEquals("City for /a/b/2 is Anytown", addr1.getCity(), ab2.getAddress().getCity());
- assertTrue("Joe and Jane have same Address", ab1.getAddress() == ab2.getAddress());
- assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName());
- assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getAddress().getCity());
- assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName());
- assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getAddress().getCity());
- assertTrue("Bob and Jill have same Address", ac1.getAddress() == ac2.getAddress());
- }
-
- public void testInitialStateTferWithLoader() throws Exception
- {
- log.info("Enter testInitialStateTferWithLoader");
-
- PojoCache cache1 = createCache("cache1", false, false, true);
-
- cache1.attach(A_B_1, joe);
- cache1.attach(A_B_2, jane);
- cache1.attach(A_C_1, bob);
- cache1.attach(A_C_2, jill);
-
- PojoCache cache2 = createCache("cache2", false, false, true);
-
- // Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new Cache[]
- {cache1.getCache(), cache2.getCache()}, 60000);
-
- Person ab1 = (Person) cache2.find(A_B_1);
- Person ab2 = (Person) cache2.find(A_B_2);
- Person ac1 = (Person) cache2.find(A_C_1);
- Person ac2 = (Person) cache2.find(A_C_2);
- assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getAddress().getCity());
- assertEquals("Name for /a/b/2 is Jane", jane.getName(), ab2.getName());
- assertEquals("City for /a/b/2 is Anytown", addr1.getCity(), ab2.getAddress().getCity());
- assertTrue("Joe and Jane have same Address", ab1.getAddress() == ab2.getAddress());
- assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName());
- assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getAddress().getCity());
- assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName());
- assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getAddress().getCity());
- assertTrue("Bob and Jill have same Address", ac1.getAddress() == ac2.getAddress());
- }
-
- private void createAndActivateRegion(Cache<Object, Object> c, Fqn<String> f)
- {
- Region r = c.getRegion(f, true);
- r.registerContextClassLoader(getClass().getClassLoader());
- r.activate();
- }
-
- public void testPartialStateTransfer() throws Exception
- {
- log.info("Enter testPartialStateTransfer");
-
- PojoCache cache1 = createCache("cache1", false, true, false);
-
- createAndActivateRegion(cache1.getCache(), Fqn.fromString("/a"));
- createAndActivateRegion(cache1.getCache(), Fqn.fromString("/__JBossInternal__"));
-
- cache1.attach(A_B_1, joe);
- cache1.attach(A_B_2, jane);
-
- PojoCache cache2 = createCache("cache2", false, true, false);
-
- // Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new Cache[]
- {cache1.getCache(), cache2.getCache()}, 60000);
-
- assertNull("/a/b/1 not transferred per policy", cache2.find(A_B_1));
- assertNull("/a/b/2 not transferred per policy", cache2.find(A_B_2));
-
- createAndActivateRegion(cache2.getCache(), Fqn.fromString("/a"));
- createAndActivateRegion(cache2.getCache(), Fqn.fromString("/__JBossInternal__"));
-
- Person ab1 = (Person) cache2.find(A_B_1);
- Person ab2 = (Person) cache2.find(A_B_2);
- assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName());
- assertEquals("City for /a/b/1 is Anytown", joe.getAddress().getCity(), ab1.getAddress().getCity());
- assertEquals("Name for /a/b/2 is Jane", jane.getName(), ab2.getName());
- assertEquals("City for /a/b/2 is Anytown", jane.getAddress().getCity(), ab2.getAddress().getCity());
- assertTrue("Address for Joe and Jane is the same object", ab1.getAddress() == ab2.getAddress());
-
- cache1.attach(A_C_1, bob);
- cache1.attach(A_C_2, jill);
-
- assertNotNull("/a/c/1 should be transferred per policy", cache2.find(A_C_1));
-
- cache1.getCache().getRegion(Fqn.fromString("/a"), true).deactivate();
-
- cache1.getCache().getRegion(Fqn.fromString("/a"), true).activate();
-
- ab1 = (Person) cache1.find(A_B_1);
- assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getAddress().getCity());
- ab2 = (Person) cache1.find(A_B_2);
- assertEquals("Name for /a/b/1 is Jane", jane.getName(), ab2.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab2.getAddress().getCity());
- assertTrue("Address for Joe and Jane is the same object", ab1.getAddress() == ab2.getAddress());
- }
-
- public void testPartialStateTransferWithLoader() throws Exception
- {
- log.info("Enter testPartialStateTransferWithLoader");
-
- PojoCache cache1 = createCache("cache1", false, true, true);
- createAndActivateRegion(cache1.getCache(), Fqn.fromString("/a"));
- createAndActivateRegion(cache1.getCache(), Fqn.fromString("/__JBossInternal__"));
-
- cache1.attach(A_B_1, joe);
- cache1.attach(A_B_2, jane);
-
- PojoCache cache2 = createCache("cache2", false, true, true);
-
- // Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new Cache[]
- {cache1.getCache(), cache2.getCache()}, 60000);
-
- CacheLoader loader = ((CacheSPI<Object, Object>) cache2.getCache()).getCacheLoaderManager().getCacheLoader();
-
- Map<Object, Object> map = loader.get(A_B_1_f);
- if (map != null)
- {
- assertNull("/a/b/1 name not transferred per policy", map.get("name"));
- assertNull("/a/b/1 age not transferred per policy", map.get("age"));
- }
- map = loader.get(A_B_2_f);
- if (map != null)
- {
- assertNull("/a/b/1 name not transferred per policy", map.get("name"));
- assertNull("/a/b/1 age not transferred per policy", map.get("age"));
- }
- assertNull("/a/b/1 not transferred per policy", cache2.find(A_B_1));
- assertNull("/a/b/2 not transferred per policy", cache2.find(A_B_2));
-
- createAndActivateRegion(cache2.getCache(), Fqn.fromString("/a"));
- createAndActivateRegion(cache2.getCache(), Fqn.fromString("/__JBossInternal__"));
-
-// assertEquals("Correct name from loader for /a/b/1", joe.getName(), loader.get(A_B_1_f).get("name"));
-// assertEquals("Correct age from loader for /a/b/1", TWENTY, loader.get(A_B_1_f).get("age"));
-// assertEquals("Correct name from loader for /a/b/2", jane.getName(), loader.get(A_B_2_f).get("name"));
-// assertEquals("Correct age from loader for /a/b/2", TWENTYFIVE, loader.get(A_B_2_f).get("age"));
-
-
- Person ab1 = (Person) cache2.find(A_B_1);
- Person ab2 = (Person) cache2.find(A_B_2);
- assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getAddress().getCity());
- assertEquals("Name for /a/b/1 is Jane", jane.getName(), ab2.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab2.getAddress().getCity());
- assertTrue("Address for Joe and Jane is the same object", ab1.getAddress() == ab2.getAddress());
-
- cache1.attach(A_C_1, bob);
- cache1.attach(A_C_2, jill);
- Thread.sleep(200);
-
- assertNotNull("/a/c/1 transferred per policy", cache2.find(A_C_1));
- assertNotNull("/a/c/1 transferred per policy", cache2.find(A_C_2));
-
- Person ac1 = (Person) cache2.find(A_C_1);
- Person ac2 = (Person) cache2.find(A_C_2);
- assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName());
- assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getAddress().getCity());
- assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName());
- assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getAddress().getCity());
- assertTrue("Bob and Jill have same Address", ac1.getAddress() == ac2.getAddress());
-
- cache1.getCache().getRegion(Fqn.fromString("/a"), true).deactivate();
-
- ab1 = (Person) cache1.find(A_B_1);
- assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getAddress().getCity());
- ab2 = (Person) cache1.find(A_B_2);
- assertEquals("Name for /a/b/1 is Jane", jane.getName(), ab2.getName());
- assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab2.getAddress().getCity());
- assertTrue("Address for Joe and Jane is the same object", ab1.getAddress() == ab2.getAddress());
- ac1 = (Person) cache1.find(A_C_1);
- assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName());
- assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getAddress().getCity());
- ac2 = (Person) cache1.find(A_C_2);
- assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName());
- assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getAddress().getCity());
- assertTrue("Address for Bob and Jill is the same object", ac1.getAddress() == ac2.getAddress());
- }
-
-
- /**
- * Tests concurrent activation of the same subtree by multiple nodes in a
- * REPL_SYNC environment. The idea is to see what would happen with a
- * farmed deployment. See <code>concurrentActivationTest</code> for details.
- *
- * @throws Exception
- */
- public void testConcurrentActivationSync() throws Exception
- {
- log.info("Enter testConcurrentActivationSync");
-
- concurrentActivationTest(true);
- }
-
- /**
- * Tests concurrent activation of the same subtree by multiple nodes in a
- * REPL_ASYNC environment. The idea is to see what would happen with a
- * farmed deployment. See <code>concurrentActivationTest</code> for details.
- *
- * @throws Exception
- */
- public void testConcurrentActivationAsync() throws Exception
- {
- log.info("Enter testConcurrentActivationAsync");
-
- concurrentActivationTest(false);
- }
-
- /**
- * Starts 5 caches and then concurrently activates the same region under
- * all 5, causing each to attempt a partial state transfer from the others.
- * As soon as each cache has activated its region, it does a put to a node
- * in the region, thus complicating the lives of the other caches trying
- * to get partial state.
- * <p/>
- * Failure condition is if any node sees an exception or if the final state
- * of all caches is not consistent.
- *
- * @param sync use REPL_SYNC or REPL_ASYNC
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- private void concurrentActivationTest(boolean sync) throws Exception
- {
- String[] names = {"A", "B", "C", "D", "E"};
- int count = names.length;
- CacheActivator[] activators = new CacheActivator[count];
-
-
- try
- {
- // Create a semaphore and take all its tickets
- Semaphore semaphore = new Semaphore(count);
- for (int i = 0; i < count; i++)
- {
- semaphore.acquire();
- }
-
- // Create activation threads that will block on the semaphore
- Cache[] caches = new Cache[count];
- for (int i = 0; i < count; i++)
- {
- activators[i] = new CacheActivator(semaphore, names[i], sync);
- caches[i] = activators[i].getCache();
- activators[i].start();
- }
-
- // Make sure everyone is in sync
- TestingUtil.blockUntilViewsReceived(caches, 60000);
-
- // Release the semaphore to allow the threads to start work
- semaphore.release(count);
-
- // Sleep to ensure the threads get all the semaphore tickets
- TestingUtil.sleepThread(1000);
-
- // Reacquire the semaphore tickets; when we have them all
- // we know the threads are done
- for (int i = 0; i < count; i++)
- {
- boolean acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
- if (!acquired)
- fail("failed to acquire semaphore " + i);
- }
-
- // Sleep to allow any async calls to clear
- if (!sync)
- TestingUtil.sleepThread(500);
-
- // Ensure the caches held by the activators see all the values
- for (int i = 0; i < count; i++)
- {
- assertNull("Activator " + names[i] + " caught an exception",
- activators[i].getException());
-
- for (int j = 0; j < count; j++)
- {
- String fqn = "/a/b/" + names[j];
- Person p = (Person) activators[i].getCacheValue(fqn);
- assertNotNull(names[i] + ":" + fqn + " is not null", p);
- assertEquals("Correct name for " + names[i] + ":" + fqn,
- "Person " + names[j], p.getName());
- assertEquals("Correct street for " + names[i] + ":" + fqn,
- names[j] + " Test Street", p.getAddress().getStreet());
-// System.out.println(names[i] + ":" + fqn + " = " + activators[i].getCacheValue(fqn));
- }
-
- }
- }
- catch (Exception ex)
- {
- fail(ex.getLocalizedMessage());
- }
- finally
- {
- for (int i = 0; i < count; i++)
- activators[i].cleanup();
- }
-
- }
-
- /**
- * Tests partial state transfer under heavy concurrent load and REPL_SYNC.
- * See <code>concurrentUseTest</code> for details.
- *
- * @throws Exception
- */
- public void testConcurrentUseSync() throws Exception
- {
- log.info("Enter testConcurrentUseSync");
-
-// concurrentUseTest(true);
- }
-
- /**
- * Tests partial state transfer under heavy concurrent load and REPL_ASYNC.
- * See <code>concurrentUseTest</code> for details.
- *
- * @throws Exception
- */
- public void testConcurrentUseAsync() throws Exception
- {
- log.info("Enter testConcurrentUseAsync");
-
-// concurrentUseTest(false);
- }
-
- /*
- * Initiates 5 caches, 4 with active trees and one with an inactive tree.
- * Each of the active caches begins rapidly generating puts against nodes
- * in a subtree for which it is responsible. The 5th cache activates
- * each subtree, and at the end confirms no node saw any exceptions and
- * that each node has consistent state.
- *
- * @param sync whether to use REPL_SYNC or REPL_ASYNCE
- * @throws Exception
- */
-// private void XconcurrentUseTest(boolean sync) throws Exception
-// {
-// String[] names = {"B", "C", "D", "E"};
-// int count = names.length;
-// CacheStressor[] stressors = new CacheStressor[count];
-//
-// try
-// {
-//
-// PojoCache cacheA = createCache("cacheA", sync, true, false, false);
-//
-// Cache[] caches = new Cache[count + 1];
-// caches[0] = cacheA.getCache();
-//
-// // Create a semaphore and take all its tickets
-// Semaphore semaphore = new Semaphore(count);
-// for (int i = 0; i < count; i++)
-// {
-// semaphore.acquire();
-// }
-//
-// // Create stressor threads that will block on the semaphore
-//
-// for (int i = 0; i < count; i++)
-// {
-// stressors[i] = new CacheStressor(semaphore, names[i], sync);
-// caches[i + 1] = stressors[i].getCache();
-// stressors[i].start();
-// // Give each one a chance to stabilize
-// TestingUtil.sleepThread(100);
-// }
-//
-// // Make sure everyone's views are in sync
-// TestingUtil.blockUntilViewsReceived(caches, 60000);
-//
-// // Repeat the basic test two times in order to involve inactivation
-// for (int x = 0; x < 2; x++)
-// {
-//// if (x > 0)
-//// {
-// // Reset things by inactivating the region
-// // and enabling the stressors
-// for (int i = 0; i < count; i++)
-// {
-// cacheA.getCache().getRegion(Fqn.fromString("/" + names[i]), true).deactivate();
-// log.info("TEST: Run " + x + "-- /" + names[i] + " inactivated on A");
-// stressors[i].startPuts();
-// }
-//// }
-//
-// // Release the semaphore to allow the threads to start work
-// semaphore.release(count);
-//
-// // Sleep to ensure the threads get all the semaphore tickets
-// // and to ensure puts are actively in progress
-// TestingUtil.sleepThread(300);
-//
-// // Activate cacheA
-// for (int i = 0; i < count; i++)
-// {
-// log.info("TEST: Activating /" + names[i] + " on A");
-// cacheA.getCache().getRegion(Fqn.fromString("/" + names[i]), true).activate();
-// // Stop the stressor so we don't pollute cacheA's state
-// // with too many messages sent after activation -- we want
-// // to compare transferred state with the sender
-// stressors[i].stopPuts();
-// log.info("TEST: Run " + x + "-- /" + names[i] + " activated on A");
-// // Reacquire one semaphore ticket
-// boolean acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
-// if (!acquired)
-// fail("failed to acquire semaphore " + names[i]);
-// log.info("TEST: Run " + x + "-- acquired semaphore from " + names[i]);
-//
-// // Pause to allow other work to proceed
-// TestingUtil.sleepThread(100);
-// }
-//
-// // Sleep to allow any in transit msgs to clear
-// if (!sync)
-// TestingUtil.sleepThread(2000);
-//
-// // Ensure the stressors saw no exceptions
-// for (int i = 0; i < count; i++)
-// {
-// Exception e = stressors[i].getException();
-// if (e != null)
-// {
-// log.error("Stressor " + names[i] + " caught an exception",
-// e);
-// throw e;
-// }
-// }
-//
-//// log.info("Cache A details:\n" + cacheA.printDetails());
-//
-// // Compare cache contents
-// Person p1 = null;
-// Person p2 = null;
-// for (int i = 0; i < count; i++)
-// {
-//// log.info("Cache " + names[i] + " details:\n" +
-//// stressors[i].getTreeCache().printDetails());
-//
-// for (int j = 0; j < SUBTREE_SIZE; j++)
-// {
-//
-// String fqn = "/" + names[i] + "/" + j;
-// log.info("TEST: Getting A:" + fqn);
-// p1 = (Person) cacheA.find(fqn);
-// boolean p1Null = p1 == null;
-// log.info("TEST: Getting " + names[i] + ":" + fqn);
-//// p2 = (Person) stressors[i].getCache().find(fqn);
-// boolean p2Null = p2 == null;
-// assertEquals("Run " + x + ": " + fqn +
-// " null status matches", p1Null, p2Null);
-// if (!p1Null)
-// {
-// assertEquals("Run " + x + ": A:" + fqn + " age matches " + names[i] + ":" + fqn,
-// p1.getAge(), p2.getAge());
-// assertEquals("Run " + x + ": A:" + fqn + " name matches " + names[i] + ":" + fqn,
-// p1.getName(), p2.getName());
-// assertEquals("Run " + x + ": A:" + fqn + " address matches " + names[i] + ":" + fqn,
-// p1.getAddress().getStreet(),
-// p2.getAddress().getStreet());
-// }
-// }
-// }
-// }
-//
-// for (int i = 0; i < count; i++)
-// stressors[i].stopThread();
-//
-// }
-// finally
-// {
-// for (int i = 0; i < count; i++)
-// {
-// if (stressors[i] != null)
-// stressors[i].cleanup();
-// }
-// }
-//
-// }
-
- protected PojoCache createCache(String cacheID, boolean sync, boolean useMarshalling, boolean useCacheLoader)
- throws Exception
- {
- return createCache(cacheID, sync, useMarshalling, useCacheLoader, true);
- }
-
- protected PojoCache createCache(String cacheID, boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader,
- boolean inactiveOnStartup)
- throws Exception
- {
- if (caches.get(cacheID) != null)
- throw new IllegalStateException(cacheID + " already created");
-
- CacheMode mode = sync ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC;
- Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(mode);
- c.setClusterName("StateTransferTestBase");
- c.setReplVersionString(getReplicationVersion());
- // Use a long timeout to facilitate setting debugger breakpoints
- c.setStateRetrievalTimeout(60000);
- c.setLockParentForChildInsertRemove(true);
- if (useMarshalling)
- {
- c.setUseRegionBasedMarshalling(true);
- c.setInactiveOnStartup(inactiveOnStartup);
- }
- if (useCacheLoader)
- {
- configureCacheLoader(c, cacheID);
- }
-
- PojoCache cache = PojoCacheFactory.createCache(c, true);
- // Put the cache in the map before starting, so if it fails in
- // start it can still be destroyed later
- caches.put(cacheID, cache);
-
- return cache;
- }
-
- protected void configureCacheLoader(Configuration c, String cacheID) throws Exception
- {
- String tmp_location = getTempLocation(cacheID);
-
- // Do cleanup in case it failed before
- File file = new File(tmp_location);
- cleanFile(file);
- file.mkdir();
- tmp_location = escapeWindowsPath(tmp_location);
- c.setCacheLoaderConfig(getCacheLoaderConfig("org.jboss.cache.loader.FileCacheLoader", tmp_location));
- }
-
-
- protected CacheLoaderConfig getCacheLoaderConfig(String cl, String loc) throws Exception
- {
- String xml = " <config>\n" +
- " \n" +
- " <passivation>false</passivation>\n" +
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- " <class>" + cl + "</class>\n" +
- " <properties>\n" +
- " location=" + loc + "\n" +
- " </properties>\n" +
- " <async>false</async>\n" +
- " <fetchPersistentState>true</fetchPersistentState>\n" +
- " <ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- Element element = XmlHelper.stringToElement(xml);
- return XmlConfigurationParser.parseCacheLoaderConfig(element);
- }
-
- protected String getTempLocation(String cacheID)
- {
- String tmp_location = System.getProperty("java.io.tmpdir", "c:\\tmp");
- File file = new File(tmp_location);
- file = new File(file, cacheID);
- return file.getAbsolutePath();
- }
-
- protected String escapeWindowsPath(String path)
- {
- if ('/' == File.separatorChar)
- return path;
-
- char[] chars = path.toCharArray();
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < chars.length; i++)
- {
- if (chars[i] == '\\')
- sb.append('\\');
- sb.append(chars[i]);
- }
- return sb.toString();
- }
-
- protected abstract String getReplicationVersion();
-
- @BeforeMethod(alwaysRun = true)
- protected void setUp() throws Exception
- {
- caches = new HashMap<String, PojoCache>();
-
- addr1 = new Address();
- addr1.setStreet("101 Oakview Dr");
- addr1.setCity("Anytown");
- addr1.setZip(11111);
-
- addr2 = new Address();
- addr2.setStreet("222 Happy Dr");
- addr2.setCity("Fremont");
- addr2.setZip(22222);
-
- joe = new Person();
- joe.setName("Joe");
- joe.setAge(TWENTY);
- joe.setAddress(addr1);
- Set<String> skills = new HashSet<String>();
- skills.add("TENNIS");
- skills.add("CARPENTRY");
- joe.setSkills(skills);
-
- jane = new Person();
- jane.setName("Jane");
- jane.setAge(TWENTYFIVE);
- jane.setAddress(addr1);
- skills = new HashSet<String>();
- skills.add("JUJITSU");
- skills.add("MACRAME");
- jane.setSkills(skills);
-
- bob = new Person();
- bob.setName("Bob");
- bob.setAge(FORTY);
- bob.setAddress(addr2);
- skills = new HashSet<String>();
- skills.add("LANGUAGES");
- skills.add("LAWN BOWLING");
- bob.setSkills(skills);
-
- jill = new Person();
- jill.setName("Jill");
- jill.setAge(TWENTYFIVE);
- jill.setAddress(addr2);
- skills = new HashSet<String>();
- skills.add("FORTRAN");
- skills.add("COBOL");
- jane.setSkills(skills);
- }
-
- @AfterMethod(alwaysRun = true)
- protected void tearDown() throws Exception
- {
- Set<String> keys = caches.keySet();
- if (!keys.isEmpty())
- {
- String[] cacheIDs = new String[keys.size()];
- cacheIDs = keys.toArray(cacheIDs);
- PojoCache cache = caches.get(cacheIDs[0]);
- cache.getCache().removeNode(new Fqn<String>("/"));
- Thread.sleep(200);
-
- for (int i = 0; i < cacheIDs.length; i++)
- {
- stopCache(caches.get(cacheIDs[i]));
- File file = new File(getTempLocation(cacheIDs[i]));
- cleanFile(file);
- }
- }
- }
-
- protected void stopCache(PojoCache cache)
- {
- if (cache != null)
- {
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- log.error("Exception stopping cache " + e.getMessage(), e);
- }
- }
- }
-
- protected void cleanFile(File file)
- {
- File[] children = file.listFiles();
- if (children != null)
- {
- for (int i = 0; i < children.length; i++)
- {
- cleanFile(children[i]);
- }
- }
-
- if (file.exists())
- file.delete();
- if (file.exists())
- file.deleteOnExit();
- }
-
- private class CacheActivator extends CacheUser
- {
-
- CacheActivator(Semaphore semaphore,
- String name,
- boolean sync)
- throws Exception
- {
- super(semaphore, name, sync, false);
- }
-
- void useCache() throws Exception
- {
- Region region = cache.getCache().getRegion(Fqn.fromString("/a/b"), true);
- region.registerContextClassLoader(getClass().getClassLoader());
- region.activate();
- log.info("TEST: " + name + " activated region" + " " + System.currentTimeMillis());
- String childFqn = "/a/b/" + name;
-
- Person p = new Person();
- p.setName("Person " + name);
-
- Address addr = new Address();
- addr.setStreet(name + " Test Street");
- addr.setCity(name + ", CA");
- p.setAddress(addr);
-
- TestingUtil.sleepThread(1);
-
-// tm.begin();
-// try
-// {
- cache.attach(childFqn, p);
- log.info("TEST: " + name + " put fqn " + childFqn + " " + System.currentTimeMillis());
-// }
-// catch (Exception e)
-// {
-// tm.setRollbackOnly();
-// throw e;
-// }
-// finally
-// {
-// tm.commit();
-// }
-
- }
-
- public Object getCacheValue(String fqn) throws CacheException
- {
- return cache.find(fqn);
- }
- }
-
- @SuppressWarnings("unused")
- private class CacheStressor extends CacheUser
- {
- private Random random;
- private boolean putsStopped = false;
- private boolean stopped = false;
-
- CacheStressor(Semaphore semaphore,
- String name,
- boolean sync)
- throws Exception
- {
- super(semaphore, name, sync, true);
-
- random = new Random(System.currentTimeMillis() + name.hashCode());
- }
-
- void useCache() throws Exception
- {
- // Do lots of puts into the cache. Use our own nodes,
- // as we're not testing conflicts between writer nodes,
- // just whether activation causes problems
- int factor = 0;
- int i = 0;
- String fqn = null;
-
- Address addr1 = new Address();
- addr1.setStreet("1 Test Street");
- addr1.setCity("TestOne, CA");
-
- Address addr2 = new Address();
- addr2.setStreet("2 Test Street");
- addr2.setCity("TestTwo, CA");
-
- Person[] people = new Person[SUBTREE_SIZE];
- boolean[] loaded = new boolean[SUBTREE_SIZE];
- for (int j = 0; j < SUBTREE_SIZE; j++)
- {
- Person p = new Person();
- p.setName("Person " + j);
- p.setAge(j);
- p.setAddress((j % 2 == 0) ? addr1 : addr2);
- people[j] = p;
- }
-
- boolean acquired = true;
- try
- {
- while (!stopped)
- {
- if (i > 0)
- {
- acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
- if (!acquired)
- throw new Exception(name + " cannot acquire semaphore");
- log.info("TEST: " + name + " reacquired semaphore");
- System.out.println("TEST: " + name + " reacquired semaphore");
- }
-
- int lastIndex = -1;
- int index = -1;
- while (!putsStopped)
- {
- // Ensure we don't operate on the same address twice in a row
- // otherwise deadlock detection sometimes causes
- // the _put for the second call to precede the commit
- // for the first, leading to deadlock. This seems like a
- // JGroups bug, but the purpose of this test isn't to expose it
- while (index % 2 == lastIndex % 2)
- {
- factor = random.nextInt(50);
- index = factor % SUBTREE_SIZE;
- }
-
- lastIndex = index;
-
- TestingUtil.sleepThread(factor);
-
- fqn = "/" + name + "/" + String.valueOf(index);
-
-// tm.begin();
-// try
-// {
- if (loaded[index] == false)
- {
- cache.attach(fqn, people[index]);
- loaded[index] = true;
- log.info("TEST: " + name + " put Person at " + fqn);
- }
- else if (i % 2 == 0)
- {
- int newAge = factor / SUBTREE_SIZE;
- people[index].setAge(newAge);
- }
- else
- {
- people[index].getAddress().setStreet(factor + " Test Street");
- }
-// }
-// catch (Exception e)
-// {
-// tm.setRollbackOnly();
-// throw e;
-// }
-// finally
-// {
-// tm.commit();
-// }
-
- i++;
- }
-
- log.info("TEST: " + name + ": last put [#" + i + "] -- " + fqn + " = " + (factor / SUBTREE_SIZE));
-
- semaphore.release();
- acquired = false;
-
- // Go to sleep until directed otherwise
- while (!stopped && putsStopped)
- TestingUtil.sleepThread(100);
- }
- }
- finally
- {
- if (acquired)
- semaphore.release();
- }
- }
-
-// public void start() throws Exception
-// {
-// super.start();
-// cache.activateRegion("/" + name);
-// }
-
- public void stopPuts()
- {
- putsStopped = true;
- log.info("TEST: " + name + " putsStopped");
- }
-
- public void startPuts()
- {
- putsStopped = false;
- }
-
- public void stopThread()
- {
- stopped = true;
- if (thread.isAlive())
- thread.interrupt();
- }
-
-
- }
-
- private abstract class CacheUser implements Runnable
- {
- protected Semaphore semaphore;
- protected PojoCache cache;
- protected TransactionManager tm;
- protected String name;
- protected Exception exception;
- protected Thread thread;
-
- CacheUser(Semaphore semaphore,
- String name,
- boolean sync,
- boolean activateRoot)
- throws Exception
- {
- this.cache = createCache(name, sync, true, false, !activateRoot);
- tm = ((CacheSPI<Object, Object>) cache.getCache()).getTransactionManager();
- if (tm == null)
- throw new IllegalStateException("TransactionManager required");
- this.semaphore = semaphore;
- this.name = name;
-
- log.info("TEST: Cache " + name + " started");
- System.out.println("TEST: Cache " + name + " started");
- }
-
- public void run()
- {
- log.info("TEST: " + name + " started");
- System.out.println("TEST: " + name + " started");
-
- boolean acquired = false;
- try
- {
- acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
- if (!acquired)
- throw new Exception(name + " cannot acquire semaphore");
- log.info("TEST: " + name + " acquired semaphore");
- System.out.println("TEST: " + name + " acquired semaphore");
- useCache();
-
- }
- catch (Exception e)
- {
- log.error("TEST: " + name + ": " + e.getLocalizedMessage(), e);
-
- // Save it for the test to check
- exception = e;
- }
- finally
- {
- if (acquired)
- semaphore.release();
- }
-
- }
-
- abstract void useCache() throws Exception;
-
- public Exception getException()
- {
- return exception;
- }
-
- public Cache<Object, Object> getCache()
- {
- return cache.getCache();
- }
-
- public void start() throws Exception
- {
- thread = new Thread(this);
- thread.start();
- }
-
- public void cleanup()
- {
- if (thread != null && thread.isAlive())
- thread.interrupt();
- }
- }
-}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java 2008-08-13 20:29:58 UTC (rev 6556)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java 2008-08-14 02:46:03 UTC (rev 6557)
@@ -32,7 +32,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "META-INF/local-service.xml";
+ String configFile = "configs/local-tx.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
16 years, 4 months