JBoss Cache SVN: r6624 - core/trunk/src/test/java/org/jboss/cache/api.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-27 08:32:37 -0400 (Wed, 27 Aug 2008)
New Revision: 6624
Modified:
core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
Log:
this is a pessimistic scenario test
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-08-27 10:24:04 UTC (rev 6623)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-08-27 12:32:37 UTC (rev 6624)
@@ -4,6 +4,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.config.Configuration;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -23,7 +24,9 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.start();
root = cache.getRoot();
}
16 years, 4 months
JBoss Cache SVN: r6623 - core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-27 06:24:04 -0400 (Wed, 27 Aug 2008)
New Revision: 6623
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
Log:
fixed NP in UT
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java 2008-08-27 10:20:06 UTC (rev 6622)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java 2008-08-27 10:24:04 UTC (rev 6623)
@@ -35,8 +35,8 @@
{
Configuration c = new Configuration();
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.AsyncRollbackTransactionManagerLookup");
+ c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache = (CacheSPI<String, String>) instance.createCache(c);
tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
tm.setTransactionTimeout(txTimeout);
16 years, 4 months
JBoss Cache SVN: r6622 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-27 06:20:06 -0400 (Wed, 27 Aug 2008)
New Revision: 6622
Modified:
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml
core/trunk/src/test/resources/jbc2-registry-configs.xml
Log:
xml improvements and bug fixes
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-08-26 22:46:35 UTC (rev 6621)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-08-27 10:20:06 UTC (rev 6622)
@@ -70,7 +70,7 @@
{
c = parser.parseFile(configFileName);
}
- catch (OldFileFormatException e)
+ catch (ConfigurationException e)
{
log.warn("Detected legacy configuration file format when parsing [" + configFileName + "]. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
@@ -160,7 +160,7 @@
{
c = parser.parseStream(is);
}
- catch (OldFileFormatException e)
+ catch (ConfigurationException e)
{
log.warn("Detected legacy configuration file format when parsing configuration file. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
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-26 22:46:35 UTC (rev 6621)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-08-27 10:20:06 UTC (rev 6622)
@@ -50,8 +50,8 @@
* This class is stateful and one instance should be used for parsing a single configuration file.
*
* @author Mircea.Markus(a)jboss.com
- * @since 3.0
* @see org.jboss.cache.config.parsing.RootElementBuilder
+ * @since 3.0
*/
public class XmlConfigurationParser extends XmlParserBase
{
@@ -64,6 +64,7 @@
*/
private Configuration config = new Configuration();
private Element root;
+
/**
* If validation is on (default) one can specify an error handler for handling validation errors.
* The default error handler just logs parsing errors received.
@@ -95,7 +96,6 @@
* Parses an XML file and returns a new configuration.
* For looking up the file, {@link org.jboss.cache.util.FileLookup} is used.
*
- * @throws OldFileFormatException if the file has a 2.x format
* @see org.jboss.cache.util.FileLookup
*/
public Configuration parseFile(String filename)
@@ -110,8 +110,6 @@
/**
* Similar to {@link #parseFile(String)}, just that it does not create the input stream.
- *
- * @throws OldFileFormatException if the file has a 2.x format
*/
public Configuration parseStream(InputStream configStream)
{
@@ -121,8 +119,6 @@
/**
* Root should be the <b>jbosscache</b> element in the configuration file.
- *
- * @throws OldFileFormatException if the file has a 2.x format
*/
public Configuration parseElement(Element root)
{
@@ -147,11 +143,6 @@
{
if (!ignoreRoot)
{
- if ("server".equalsIgnoreCase(root.getNodeName()))
- {
- throw new OldFileFormatException();
- }
-
if (!"jbosscache".equals(root.getLocalName()) || !RootElementBuilder.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))
throw new ConfigurationException("Expected root element {" + RootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache");
}
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-08-26 22:46:35 UTC (rev 6621)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-08-27 10:20:06 UTC (rev 6622)
@@ -15,7 +15,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.OldFileFormatException;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -87,7 +86,7 @@
{
c = parser.parseFile(configFileName);
}
- catch (OldFileFormatException e)
+ catch (ConfigurationException e)
{
System.out.println("Detected legacy configuration file format when parsing [" + configFileName + "]. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
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-26 22:46:35 UTC (rev 6621)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-08-27 10:20:06 UTC (rev 6622)
@@ -1,12 +1,6 @@
package org.jboss.cache.config.parsing;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.CustomInterceptorConfig;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.OldFileFormatException;
+import org.jboss.cache.config.*;
import org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor;
import org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
@@ -45,7 +39,7 @@
parser.parseFile("configs/conf2x/pess-local.xml");
assert false : "exception expected";
}
- catch (OldFileFormatException e)
+ catch (ConfigurationException e)
{
//expectd
}
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-26 22:46:35 UTC (rev 6621)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-27 10:20:06 UTC (rev 6622)
@@ -32,7 +32,8 @@
"parser-test.xml",
"policyPerRegion-eviction.xml",
"replSync.xml",
- "string-property-replaced.xml"
+ "string-property-replaced.xml",
+ "mvcc-repl-sync-br.xml"
};
/**
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-26 22:46:35 UTC (rev 6621)
+++ core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-27 10:20:06 UTC (rev 6622)
@@ -31,7 +31,7 @@
</jgroupsConfig>
</transport>
<replication>
- <async replTimeout="15000"/>
+ <async/>
<buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
<dataGravitation auto="false" removeOnFind="true" searchBackupTrees="true"/>
<locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
Modified: core/trunk/src/test/resources/jbc2-registry-configs.xml
===================================================================
(Binary files differ)
16 years, 4 months
JBoss Cache SVN: r6621 - in core/trunk/src: main/resources/schema and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-26 18:46:35 -0400 (Tue, 26 Aug 2008)
New Revision: 6621
Added:
core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd
core/trunk/src/test/resources/jbc3-registry-configs.xml
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.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/resources/schema/jbosscache-config-3.0.xsd
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java
Log:
xml improvements
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-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -22,10 +22,6 @@
package org.jboss.cache.config.parsing;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.Configuration;
@@ -35,6 +31,10 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Parser able to parse a series of cache configurations stored in an
* XML document with the following structure:
@@ -89,8 +89,8 @@
public Map<String, Configuration> parseConfigs(InputStream stream) throws CloneNotSupportedException
{
// loop through all elements in XML.
- Element root = XmlConfigHelper.getDocumentRoot(stream);
- NodeList list = root.getElementsByTagName(CONFIG_ROOT);
+ Element root = getDocumentRoot(stream);
+ NodeList list = root.getElementsByTagNameNS(RootElementBuilder.JBOSSCACHE_REPO_NS, CONFIG_ROOT);
if (list == null || list.getLength() == 0)
throw new ConfigurationException("Can't find " + CONFIG_ROOT + " tag");
@@ -118,4 +118,10 @@
return result;
}
+
+ private Element getDocumentRoot(InputStream stream)
+ {
+ RootElementBuilder rootElementBuilder = new RootElementBuilder();
+ return rootElementBuilder.readRoot(stream);
+ }
}
\ No newline at end of file
Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.config.parsing;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import java.io.InputStream;
+
+/**
+ * Parses an xml files and validates xml elements form {@link RootElementBuilder#JBOSSCACHE_CORE_NS} namespace
+ * according to the configured schema.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class RootElementBuilder
+{
+
+ private static final JBossEntityResolver resolver = new JBossEntityResolver();
+
+ public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.0";
+ public static final String JBOSSCACHE_REPO_NS = "urn:jboss:jbosscache-core:cache-repo:3.0";
+
+ static
+ {
+ // Globally register this namespace
+ JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.0.xsd");
+ JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "jbosscache-registry-3.0.xsd");
+ }
+
+ private static final Log log = LogFactory.getLog(RootElementBuilder.class);
+ private ErrorHandler errorHandler;
+ private boolean isValidating;
+ public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
+
+ public RootElementBuilder(ErrorHandler errorHandler)
+ {
+ this.errorHandler = errorHandler;
+ isValidating = System.getProperty(VALIDATING_SYSTEM_PROPERTY) == null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY);
+ }
+
+ public RootElementBuilder(ErrorHandler errorHandler, boolean validating)
+ {
+ this.errorHandler = errorHandler;
+ isValidating = validating;
+ }
+
+ public RootElementBuilder()
+ {
+ this(new FailureErrorHandler());
+ }
+
+ public Element readRoot(InputStream config)
+ {
+ try
+ {
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ docBuilderFactory.setNamespaceAware(true);
+ if (isValidating)
+ {
+ docBuilderFactory.setValidating(true);
+ docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
+ String[] value = {JBOSSCACHE_CORE_NS, JBOSSCACHE_REPO_NS};
+ docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", value);
+ }
+ DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+ parser.setEntityResolver(resolver);
+ parser.setErrorHandler(errorHandler);
+ Document doc = parser.parse(config);
+ Element root = doc.getDocumentElement();
+ root.normalize();
+ return root;
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ throw new ConfigurationException("Could not parse the config file");
+ }
+ }
+
+ /**
+ * Default schema validation error handler, that throws an exception on validation errors.
+ */
+ private static class FailureErrorHandler implements ErrorHandler
+ {
+ public void warning(SAXParseException exception) throws SAXException
+ {
+ logAndThrowException(exception);
+ }
+
+ public void error(SAXParseException exception) throws SAXException
+ {
+ logAndThrowException(exception);
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException
+ {
+ logAndThrowException(exception);
+ }
+
+ private void logAndThrowException(SAXParseException exception)
+ {
+ log.error("Configuration warning: " + exception.getMessage());
+ throw new ConfigurationException("Incorrect configuration file. Use '-Djbosscache.config.validate=false' to disable validation.", exception);
+ }
+ }
+
+ public boolean isValidating()
+ {
+ return isValidating;
+ }
+}
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-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -366,7 +366,7 @@
*/
public static Element stringToElementInCoreNS(String xml) throws Exception
{
- xml = "<wrapper xmlns='" + XmlParserBase.JBOSSCACHE_CORE_NS + "'>" + xml + "</wrapper>";
+ xml = "<wrapper xmlns='" + RootElementBuilder.JBOSSCACHE_CORE_NS + "'>" + xml + "</wrapper>";
ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
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-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -23,27 +23,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.CustomInterceptorConfig;
-import org.jboss.cache.config.OldFileFormatException;
+import org.jboss.cache.config.*;
import org.jboss.cache.config.parsing.element.BuddyElementParser;
import org.jboss.cache.config.parsing.element.CustomInterceptorsElementParser;
import org.jboss.cache.config.parsing.element.EvictionElementParser;
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;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import java.io.InputStream;
import java.util.List;
@@ -60,38 +51,26 @@
*
* @author Mircea.Markus(a)jboss.com
* @since 3.0
+ * @see org.jboss.cache.config.parsing.RootElementBuilder
*/
public class XmlConfigurationParser extends XmlParserBase
{
private static final Log log = LogFactory.getLog(XmlConfigurationParser.class);
- private static final JBossEntityResolver resolver = new JBossEntityResolver();
+ private RootElementBuilder rootElementBuilder;
-
- public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
-
- static
- {
- // Globally register this namespace
- JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.0.xsd");
- }
-
/**
* the resulting configuration.
*/
private Configuration config = new Configuration();
private Element root;
- private ErrorHandler errorHandler;
- private boolean isValidating;
-
/**
* If validation is on (default) one can specify an error handler for handling validation errors.
* The default error handler just logs parsing errors received.
*/
public XmlConfigurationParser(ErrorHandler errorHandler)
{
- this.errorHandler = errorHandler;
- isValidating = System.getProperty(VALIDATING_SYSTEM_PROPERTY) == null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY);
+ rootElementBuilder = new RootElementBuilder(errorHandler);
}
/**
@@ -101,8 +80,7 @@
*/
public XmlConfigurationParser(boolean validating, ErrorHandler errorHandler)
{
- isValidating = validating;
- this.errorHandler = errorHandler;
+ rootElementBuilder = new RootElementBuilder(errorHandler, validating);
}
/**
@@ -110,7 +88,7 @@
*/
public XmlConfigurationParser()
{
- this(new LoggingErrorHandler());
+ rootElementBuilder = new RootElementBuilder();
}
/**
@@ -153,8 +131,6 @@
return processElements(false);
}
- // FIXME: CacheConfigsXmlParser should be using a valid schema!
- @Deprecated
public Configuration parseElementIgnoringRoot(Element root)
{
this.root = root;
@@ -164,7 +140,7 @@
public boolean isValidating()
{
- return isValidating;
+ return rootElementBuilder.isValidating();
}
private Configuration processElements(boolean ignoreRoot)
@@ -176,8 +152,8 @@
throw new OldFileFormatException();
}
- if (!"jbosscache".equals(root.getLocalName()) || !JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))
- throw new ConfigurationException("Expected root element {" + JBOSSCACHE_CORE_NS + "}" + "jbosscache");
+ if (!"jbosscache".equals(root.getLocalName()) || !RootElementBuilder.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))
+ throw new ConfigurationException("Expected root element {" + RootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache");
}
try
@@ -415,49 +391,33 @@
private void readRoot(InputStream config)
{
- try
- {
- DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
- docBuilderFactory.setNamespaceAware(true);
- if (isValidating)
- {
- docBuilderFactory.setValidating(true);
- docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
- 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();
- root.normalize();
- }
- catch (Exception e)
- {
- log.error(e);
- throw new ConfigurationException("Could not parse the config file");
- }
+ root = rootElementBuilder.readRoot(config);
}
/**
- * Default schema validation error handler, that only logs validation exceptions.
+ * Default schema validation error handler, that throws an exception on validation errors.
*/
- private static class LoggingErrorHandler implements ErrorHandler
+ private static class FailureErrorHandler implements ErrorHandler
{
public void warning(SAXParseException exception) throws SAXException
{
- log.warn("Configuration warning: " + exception.getMessage());
+ logAndThrowException(exception);
}
public void error(SAXParseException exception) throws SAXException
{
- log.warn("Configuration error: " + exception.getMessage());
+ logAndThrowException(exception);
}
public void fatalError(SAXParseException exception) throws SAXException
{
- log.warn("Configuration fatal error : " + exception.getMessage());
+ logAndThrowException(exception);
}
+
+ private void logAndThrowException(SAXParseException exception)
+ {
+ log.error("Configuration warning: " + exception.getMessage());
+ throw new ConfigurationException("Incorrect configuration file. Use '-Djbosscache.config.validate=false' to disable validation.", exception);
+ }
}
}
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-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -33,7 +33,6 @@
*/
public abstract class XmlParserBase
{
- public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.0";
/**
* @see Integer#parseInt(String)
@@ -85,7 +84,7 @@
*/
protected Element getSingleElementInCoreNS(String elementName, Element parent)
{
- return getSingleElement(JBOSSCACHE_CORE_NS, elementName, parent);
+ return getSingleElement(RootElementBuilder.JBOSSCACHE_CORE_NS, elementName, parent);
}
/**
Modified: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2008-08-26 22:46:35 UTC (rev 6621)
@@ -2,33 +2,33 @@
<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:element name="jbosscache" type="tns:cacheConfigurationType"/>
+ <xs:complexType name="cacheConfigurationType">
+ <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:complexType name="lockingType">
<xs:attribute name="isolationLevel">
<xs:simpleType>
<xs:restriction base="xs:string">
- <xs:pattern value="SERIALIZABLE|REPEATABLE_READ|READ_COMMITTED|NONE|\$\{.*\}"/>
+ <xs:pattern value="[Ss][Ee][Rr][Ii][Aa][Ll][Ii][Zz][Aa][Bb][Ll][Ee]|[Rr][Ee][Pp][Ee][Aa][Tt][Aa][Bb][Ll][Ee]_[Rr][Ee][Aa][Dd]|[Rr][Ee][Aa][Dd]_[Cc][Oo][Mm][Mm][Ii][Tt][Tt][Ee][Dd]|[Nn][Oo][Nn][Ee]|\$\{.*\}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
@@ -64,7 +64,7 @@
<xs:attribute name="hookBehavior">
<xs:simpleType>
<xs:restriction base="xs:string">
- <xs:pattern value="DEFAULT|REGISTER|DONT_REGISTER|\$\{.*\}"/>
+ <xs:pattern value="[Dd][Ee][Ff][Aa][Uu][Ll][Tt]|[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|[Dd][Oo][Nn][Tt]_[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|\$\{.*\}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
@@ -81,7 +81,7 @@
<xs:simpleType name="booleanType">
<xs:restriction base="xs:string">
- <xs:pattern value="\$\{.*\}|true|false"/>
+ <xs:pattern value="\$\{.*\}|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]"/>
</xs:restriction>
</xs:simpleType>
@@ -230,8 +230,7 @@
<xs:attribute name="position">
<xs:simpleType>
<xs:restriction base="xs:string">
- <xs:enumeration value="first"/>
- <xs:enumeration value="last"/>
+ <xs:pattern value="[Ff][Ii][Rr][Ss][Tt]|[Ll][Aa][Ss][Tt]"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
Added: core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd (rev 0)
+++ core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd 2008-08-26 22:46:35 UTC (rev 6621)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
+ xmlns:tns="urn:jboss:jbosscache-core:config:3.0"
+ xmlns:repo="urn:jboss:jbosscache-core:cache-repo:3.0"
+ targetNamespace="urn:jboss:jbosscache-core:cache-repo:3.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
+ <xs:import schemaLocation="jbosscache-config-3.0.xsd" namespace="urn:jboss:jbosscache-core:config:3.0"/>
+
+ <xs:element name="cache-configs">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="cache-config" type="repo:cacheConfig" minOccurs="1" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="cacheConfig">
+ <xs:complexContent>
+ <xs:extension base="tns:cacheConfigurationType" xml:space="default">
+ <xs:attribute name="name" type="xs:string"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+</xs:schema>
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-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -38,6 +38,7 @@
public void testParseOldConfigFile()
{
+ System.setProperty("jbosscache.config.validate","false");
XmlConfigurationParser parser = new XmlConfigurationParser();
try
{
@@ -48,6 +49,9 @@
{
//expectd
}
+ finally {
+ System.setProperty("jbosscache.config.validate","true");
+ }
}
public void testTransactionManagerLookupClass()
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -61,11 +61,11 @@
XmlConfigurationParser parser = new XmlConfigurationParser();
assert parser.isValidating() : "by default we have a validating parser";
- System.setProperty(XmlConfigurationParser.VALIDATING_SYSTEM_PROPERTY, "false");
+ System.setProperty(RootElementBuilder.VALIDATING_SYSTEM_PROPERTY, "false");
parser = new XmlConfigurationParser();
assert !parser.isValidating();
- System.setProperty(XmlConfigurationParser.VALIDATING_SYSTEM_PROPERTY, "true");
+ System.setProperty(RootElementBuilder.VALIDATING_SYSTEM_PROPERTY, "true");
parser = new XmlConfigurationParser();
assert parser.isValidating();
}
Modified: core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java 2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java 2008-08-26 22:46:35 UTC (rev 6621)
@@ -32,7 +32,7 @@
/**
* A file that includes every configuration element I could think of
*/
- public static final String DEFAULT_CONFIGURATION_FILE = "jbc2-registry-configs.xml";
+ public static final String DEFAULT_CONFIGURATION_FILE = "jbc3-registry-configs.xml";
private Set<Cache<Object, Object>> caches = new HashSet<Cache<Object, Object>>();
Added: core/trunk/src/test/resources/jbc3-registry-configs.xml
===================================================================
--- core/trunk/src/test/resources/jbc3-registry-configs.xml (rev 0)
+++ core/trunk/src/test/resources/jbc3-registry-configs.xml 2008-08-26 22:46:35 UTC (rev 6621)
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.0" xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.0">
+
+ <!--
+ Various JBoss Cache configurations, suitable for different caching
+ uses (e.g. entities vs. queries).
+
+ In all cases, TransactionManager configuration not required.
+ Hibernate will plug in its own transaction manager integration.
+ -->
+
+
+ <!-- A config appropriate for entity/collection caching. -->
+ <registry:cache-config name="optimistic-entity">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction syncCommitPhase="true" syncRollbackPhase="true"
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <transport clusterName="optimistic-entity" multiplexerStack="udp-sync"/>
+ <invalidation>
+ <sync replTimeout="20000"/>
+ </invalidation>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A config appropriate for entity/collection caching that
+ uses pessimistic locking -->
+ <registry:cache-config name="pessimistic-entity">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <transport clusterName="pessimistic-entity" multiplexerStack="udp-sync"/>
+ <invalidation>
+ <sync replTimeout="20000"/>
+ </invalidation>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A config appropriate for query caching. Does not replicate
+ queries. DO NOT STORE TIMESTAMPS IN THIS CACHE.
+ -->
+ <registry:cache-config name="local-query">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A query cache that replicates queries. Replication is asynchronous.
+ DO NOT STORE TIMESTAMPS IN THIS CACHE.
+ -->
+ <registry:cache-config name="replicated-query">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="false"/>
+ <startup regionsInactiveOnStartup="false"/>
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <transport clusterName="replicated-query" multiplexerStack="udp"/>
+ <replication>
+ <async/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS" >
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- Optimized for timestamp caching. A clustered timestamp cache
+ is required if query caching is used, even if the query cache
+ itself is configured with CacheMode=LOCAL.
+ -->
+ <registry:cache-config name="timestamps-cache">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <transport clusterName="timestamps-cache" multiplexerStack="udp"/>
+ <replication>
+ <async/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A config appropriate for a cache that's shared for
+ entity, collection, query and timestamp caching. Not an advised
+ configuration, since it requires cache mode REPL_SYNC, which is the
+ least efficient mode. Also requires a full state transfer at startup,
+ which can be expensive. Uses optimistic locking. -->
+ <registry:cache-config name="optimistic-shared">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction syncCommitPhase="true" syncRollbackPhase="true"
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <transport clusterName="optimistic-shared" multiplexerStack="udp"/>
+ <replication>
+ <sync replTimeout="20000"/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+
+
+ <!-- A config appropriate for a cache that's shared for
+ entity, collection, query and timestamp caching. Not an advised
+ configuration, since it requires cache mode REPL_SYNC, which is the
+ least efficient mode. Also requires a full state transfer at startup,
+ which can be expensive. Uses pessmistic locking.
+ -->
+ <registry:cache-config name="pessimistic-shared">
+
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <transport clusterName="pessimistic-shared" multiplexerStack="udp"/>
+ <replication>
+ <sync replTimeout="20000"/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+</registry:cache-configs>
16 years, 4 months
JBoss Cache SVN: r6620 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-26 07:07:03 -0400 (Tue, 26 Aug 2008)
New Revision: 6620
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
Log:
Fixed broken tests to use Pess locking instead of MVCC
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-08-26 10:45:29 UTC (rev 6619)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-08-26 11:07:03 UTC (rev 6620)
@@ -13,8 +13,8 @@
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
@@ -142,10 +142,8 @@
c.getConfiguration().setBuddyReplicationConfig(brc);
c.getConfiguration().setFetchInMemoryState(true);
- if (optimisticLocks)
- {
- c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- }
+ c.getConfiguration().setNodeLockingScheme(optimisticLocks ? NodeLockingScheme.OPTIMISTIC : NodeLockingScheme.PESSIMISTIC);
+
c.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.getConfiguration().setSyncCommitPhase(true);// helps track down breakages
16 years, 4 months
JBoss Cache SVN: r6619 - core/trunk/src/test/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-26 06:45:29 -0400 (Tue, 26 Aug 2008)
New Revision: 6619
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java
Log:
Fixed broken tests to use Pess locking instead of MVCC
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-08-26 10:39:49 UTC (rev 6618)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-08-26 10:45:29 UTC (rev 6619)
@@ -15,6 +15,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.commands.legacy.write.PessPutKeyValueCommand;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.marshall.data.Address;
import org.jboss.cache.marshall.data.Person;
@@ -79,6 +80,7 @@
private CacheSPI<Object, Object> createCache(String name)
{
CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC), false);
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache.getConfiguration().setClusterName(name);
// Use marshaller
cache.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-08-26 10:39:49 UTC (rev 6618)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-08-26 10:45:29 UTC (rev 6619)
@@ -10,8 +10,8 @@
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.commands.legacy.write.PessPutKeyValueCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -113,7 +113,7 @@
public void testMethodCall() throws Exception
{
Fqn fqn = Fqn.fromElements(3, false);
- ReplicableCommand cmd = new PessPutKeyValueCommand(null, fqn, "key", "value");
+ ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value");
byte[] asBytes = marshaller.objectToByteBuffer(cmd);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -126,7 +126,7 @@
public void testNestedMethodCall() throws Exception
{
Fqn fqn = Fqn.fromElements(3, false);
- ReplicableCommand cmd = new PessPutKeyValueCommand(null, fqn, "key", "value");
+ ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value");
ReplicableCommand replicateCmd = new ReplicateCommand(cmd);
byte[] asBytes = marshaller.objectToByteBuffer(replicateCmd);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -216,12 +216,12 @@
Fqn f = Fqn.fromElements("BlahBlah", 3, false);
String k = "key", v = "value";
- ReplicableCommand cmd = new PessPutKeyValueCommand(null, f, k, v);
+ ReplicableCommand cmd = new PutKeyValueCommand(null, f, k, v);
ReplicableCommand replCmd = new ReplicateCommand(cmd);
calls.add(replCmd);
- cmd = new PessPutKeyValueCommand(null, f, k, v);
+ cmd = new PutKeyValueCommand(null, f, k, v);
replCmd = new ReplicateCommand(cmd);
calls.add(replCmd);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java 2008-08-26 10:39:49 UTC (rev 6618)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java 2008-08-26 10:45:29 UTC (rev 6619)
@@ -4,10 +4,11 @@
import org.jboss.cache.DefaultCacheFactory;
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.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.internals.ReplicationListener;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -34,7 +35,7 @@
public void setUp() throws CloneNotSupportedException
{
c1 = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_ASYNC), false);
-
+ c1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
String jgroupsCfg = c1.getConfiguration().getClusterConfig();
// make sure we use STATE_TRANSFER and not STREAMING_STATE_TRANSFER, so the same thread pool is used for incoming calls and ST
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-08-26 10:39:49 UTC (rev 6618)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-08-26 10:45:29 UTC (rev 6619)
@@ -12,6 +12,7 @@
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -42,6 +43,7 @@
public void setUp() throws Exception
{
cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache1.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
cache1.getConfiguration().setUseRegionBasedMarshalling(!useMarshalledValues);
cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
@@ -49,6 +51,7 @@
cache1.start();
cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache2.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
cache2.getConfiguration().setUseRegionBasedMarshalling(!useMarshalledValues);
cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 2008-08-26 10:39:49 UTC (rev 6618)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 2008-08-26 10:45:29 UTC (rev 6619)
@@ -14,6 +14,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.marshall.data.Address;
import org.jboss.cache.marshall.data.Person;
@@ -68,6 +69,7 @@
private CacheSPI<Object, Object> createCache(String name)
{
CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache.getConfiguration().setClusterName(name);
// Use marshaller
cache.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
16 years, 4 months
JBoss Cache SVN: r6618 - in core/trunk/src/test/java/org/jboss/cache: lock and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-26 06:39:49 -0400 (Tue, 26 Aug 2008)
New Revision: 6618
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java
core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
Log:
Fixed broken tests to use Pess locking instead of MVCC
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -8,6 +8,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
@@ -30,6 +31,7 @@
{
if (cache != null) tearDown();
cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyCountingCacheLoader.class.getName(), "", false, false, false));
cache.start();
dummyLoader = (DummyCountingCacheLoader) cache.getCacheLoaderManager().getCacheLoader();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -13,6 +13,7 @@
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.internals.ReplicationListener;
import static org.testng.AssertJUnit.assertEquals;
@@ -140,6 +141,11 @@
cache1.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
cache2.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
}
+ else
+ {
+ cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ }
cache1.start();
cache2.start();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -13,6 +13,7 @@
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.lock.TimeoutException;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
@@ -71,6 +72,9 @@
cache2.getRegionManager().getRegion(fqn, Region.Type.MARSHALLING, true).registerContextClassLoader(this.getClass().getClassLoader());
}
+ cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+
cache1.start();
cache2.start();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -7,6 +7,7 @@
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.Test;
@@ -47,6 +48,7 @@
iclc.setCacheLoader(new TestSlowCacheLoader());
clc.addIndividualCacheLoaderConfig(iclc);
cache.getConfiguration().setCacheLoaderConfig(clc);
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache.start();
long begin = System.currentTimeMillis();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -13,6 +13,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.internals.ViewChangeListener;
import static org.testng.AssertJUnit.*;
@@ -47,6 +48,10 @@
cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache3 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+
+ cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ cache3.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
}
public void testPutCacheLoaderWithNoPush() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -3,6 +3,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
@@ -33,7 +34,7 @@
cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
cache1.getConfiguration().setCacheMode("repl_sync");
cache1.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
-
+ cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
// cache1.setReplQueueInterval(3000);
cache1.create();
@@ -41,6 +42,7 @@
cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
cache2.getConfiguration().setCacheMode("repl_sync");
+ cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache2.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
cache2.getConfiguration().setLockAcquisitionTimeout(2000);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -6,6 +6,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -37,6 +38,7 @@
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
clc.addIndividualCacheLoaderConfig(iclc);
cache.getConfiguration().setCacheLoaderConfig(clc);
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
mockCacheLoader = createMock(CacheLoader.class);
expect(mockCacheLoader.getConfig()).andReturn(null).anyTimes();
Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-08-26 09:55:47 UTC (rev 6617)
+++ core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-08-26 10:39:49 UTC (rev 6618)
@@ -12,6 +12,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.transaction.GenericTransactionManagerLookup;
import org.jboss.cache.transaction.TransactionSetup;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.fail;
@@ -77,9 +79,10 @@
CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
c.getConfiguration().setClusterName("test");
c.getConfiguration().setStateRetrievalTimeout(10000);
- c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.GenericTransactionManagerLookup");
+ c.getConfiguration().setTransactionManagerLookupClass(GenericTransactionManagerLookup.class.getName());
c.getConfiguration().setLockAcquisitionTimeout(500);
c.getConfiguration().setIsolationLevel(level);
+ c.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
c.create();
c.start();
return c;
16 years, 4 months
JBoss Cache SVN: r6617 - jbosscache-lucene/jbosscache.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-08-26 05:55:47 -0400 (Tue, 26 Aug 2008)
New Revision: 6617
Modified:
jbosscache-lucene/jbosscache/README.txt
Log:
Edited README.txt
Modified: jbosscache-lucene/jbosscache/README.txt
===================================================================
--- jbosscache-lucene/jbosscache/README.txt 2008-08-26 06:56:09 UTC (rev 6616)
+++ jbosscache-lucene/jbosscache/README.txt 2008-08-26 09:55:47 UTC (rev 6617)
@@ -3,6 +3,9 @@
* This implementation is built using JBoss Cache 2.1.1.CR2, and requires Java 5.
* See distribution on http://www.jbosscache.org for complete list of dependencies.
+* Make sure you check the directory that contains this file into [your_lucene_path]/contrib
+
+
* For the locking implementation to work accurately, JBoss Cache must be configured:
* to use SYNC_REPL
* Synchronous Commit
16 years, 4 months
JBoss Cache SVN: r6616 - in core/trunk/src/main/java/org/jboss/cache: invocation and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-26 02:56:09 -0400 (Tue, 26 Aug 2008)
New Revision: 6616
Removed:
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
Log:
Made invocation context an abstract class instead of an interface
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08-26 06:44:18 UTC (rev 6615)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08-26 06:56:09 UTC (rev 6616)
@@ -1,12 +1,19 @@
package org.jboss.cache;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.annotations.Compat;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.Immutables;
import javax.transaction.Transaction;
+import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -14,23 +21,48 @@
* A context that holds information regarding the scope of a single invocation. May delegate some calls to a {@link org.jboss.cache.transaction.TransactionContext}
* if one is in scope.
* <p/>
- * Note that prior to 3.0.0, InvocationContext was a concrete class and not an interface.
+ * Note that prior to 3.0.0, InvocationContext was a concrete class and not an abstract one.
* <p/>
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @see org.jboss.cache.transaction.TransactionContext
*/
@SuppressWarnings("deprecation")
-public interface InvocationContext
+@Compat(notes = "This really ought to be an interface, just like TransactionContext, but since this is public API making this an interface will break binary compat with 2.x.")
+public abstract class InvocationContext
{
+ private static final Log log = LogFactory.getLog(InvocationContext.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ private Transaction transaction;
+ private GlobalTransaction globalTransaction;
+ protected TransactionContext transactionContext;
+ private Option optionOverrides;
+ // defaults to true.
+ private boolean originLocal = true;
+ private boolean localRollbackOnly;
+ @Deprecated
+ private MethodCall methodCall;
+ @Deprecated
+ private VisitableCommand command;
+
/**
+ * LinkedHashSet of locks acquired by the invocation. We use a LinkedHashSet because we need efficient Set semantics
+ * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
+ * <p/>
+ * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
+ * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
+ */
+ protected LinkedHashSet invocationLocks;
+
+ /**
* Retrieves a node from the registry of looked up nodes in the current scope.
*
* @param fqn fqn to look up
* @return a node, or null if it cannot be found.
* @since 3.0.
*/
- NodeSPI lookUpNode(Fqn fqn);
+ public abstract NodeSPI lookUpNode(Fqn fqn);
/**
* Puts an entry in the registry of looked up nodes in the current scope.
@@ -39,14 +71,14 @@
* @param n node to add
* @since 3.0.
*/
- void putLookedUpNode(Fqn f, NodeSPI n);
+ public abstract void putLookedUpNode(Fqn f, NodeSPI n);
/**
* Clears the registry of looked up nodes.
*
* @since 3.0.
*/
- void clearLookedUpNodes();
+ public abstract void clearLookedUpNodes();
/**
* Retrieves a map of nodes looked up within the current invocation's scope.
@@ -54,34 +86,46 @@
* @return a map of looked up nodes.
* @since 3.0
*/
- Map<Fqn, NodeSPI> getLookedUpNodes();
+ public abstract Map<Fqn, NodeSPI> getLookedUpNodes();
/**
* Marks teh context as only rolling back.
*
* @param localRollbackOnly if true, the context is only rolling back.
*/
- void setLocalRollbackOnly(boolean localRollbackOnly);
+ public void setLocalRollbackOnly(boolean localRollbackOnly)
+ {
+ this.localRollbackOnly = localRollbackOnly;
+ }
/**
* Retrieves the transaction associated with this invocation
*
* @return The transaction associated with this invocation
*/
- Transaction getTransaction();
+ public Transaction getTransaction()
+ {
+ return transaction;
+ }
/**
* Sets a transaction object on the invocation context.
*
* @param transaction transaction to set
*/
- void setTransaction(Transaction transaction);
+ public void setTransaction(Transaction transaction)
+ {
+ this.transaction = transaction;
+ }
/**
* @return the transaction entry associated with the current transaction, or null if the current thread is not associated with a transaction.
* @since 2.2.0
*/
- TransactionContext getTransactionContext();
+ public TransactionContext getTransactionContext()
+ {
+ return transactionContext;
+ }
/**
* Sets the transaction context to be associated with the current thread.
@@ -89,47 +133,73 @@
* @param transactionContext transaction context to set
* @since 2.2.0
*/
- void setTransactionContext(TransactionContext transactionContext);
+ public void setTransactionContext(TransactionContext transactionContext)
+ {
+ this.transactionContext = transactionContext;
+ }
/**
* Retrieves the global transaction associated with this invocation
*
* @return the global transaction associated with this invocation
*/
- GlobalTransaction getGlobalTransaction();
+ public GlobalTransaction getGlobalTransaction()
+ {
+ return globalTransaction;
+ }
/**
* Sets the global transaction associated with this invocation
*
* @param globalTransaction global transaction to set
*/
- void setGlobalTransaction(GlobalTransaction globalTransaction);
+ public void setGlobalTransaction(GlobalTransaction globalTransaction)
+ {
+ this.globalTransaction = globalTransaction;
+ }
+
/**
* Retrieves the option overrides associated with this invocation
*
* @return the option overrides associated with this invocation
*/
- Option getOptionOverrides();
+ public Option getOptionOverrides()
+ {
+ if (optionOverrides == null)
+ {
+ optionOverrides = new Option();
+ }
+ return optionOverrides;
+ }
/**
* @return true of no options have been set on this context, false otherwise.
*/
- boolean isOptionsUninitialised();
+ public boolean isOptionsUninitialised()
+ {
+ return optionOverrides == null;
+ }
/**
* Sets the option overrides to be associated with this invocation
*
* @param optionOverrides options to set
*/
- void setOptionOverrides(Option optionOverrides);
+ public void setOptionOverrides(Option optionOverrides)
+ {
+ this.optionOverrides = optionOverrides;
+ }
/**
* Tests if this invocation originated locally or from a remote cache.
*
* @return true if the invocation originated locally.
*/
- boolean isOriginLocal();
+ public boolean isOriginLocal()
+ {
+ return originLocal;
+ }
/**
* Returns an immutable, defensive copy of the List of locks currently maintained for the current scope.
@@ -144,7 +214,12 @@
* @return locks held in current scope.
*/
@SuppressWarnings("unchecked")
- List getLocks();
+ public List getLocks()
+ {
+ // first check transactional scope
+ if (transactionContext != null) return transactionContext.getLocks();
+ return invocationLocks == null || invocationLocks.isEmpty() ? Collections.emptyList() : Immutables.immutableListConvert(invocationLocks);
+ }
/**
* Adds a List of locks to the currently maintained collection of locks acquired.
@@ -159,7 +234,20 @@
* @param locks locks to add
*/
@SuppressWarnings("unchecked")
- void addAllLocks(List locks);
+ public void addAllLocks(List locks)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.addAllLocks(locks);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
+ invocationLocks.addAll(locks);
+ }
+ }
/**
* Adds a lock to the currently maintained collection of locks acquired.
@@ -174,7 +262,20 @@
* @param lock lock to add
*/
@SuppressWarnings("unchecked")
- void addLock(Object lock);
+ public void addLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.addLock(lock);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
+ invocationLocks.add(lock);
+ }
+ }
/**
* Removes a lock from the currently maintained collection of locks acquired.
@@ -189,7 +290,19 @@
* @param lock lock to remove
*/
@SuppressWarnings("unchecked")
- void removeLock(Object lock);
+ public void removeLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.removeLock(lock);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks != null) invocationLocks.remove(lock);
+ }
+ }
/**
* Clears all locks from the currently maintained collection of locks acquired.
@@ -201,9 +314,20 @@
* as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
* legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
*/
- void clearLocks();
+ public void clearLocks()
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.clearLocks();
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks != null) invocationLocks.clear();
+ }
+ }
-
/**
* Note that if a transaction is in scope, implementations should test this lock from on {@link org.jboss.cache.transaction.TransactionContext}.
* Using this method should always ensure locks checked in the appropriate scope.
@@ -211,12 +335,26 @@
* @param lock lock to test
* @return true if the lock being tested is already held in the current scope, false otherwise.
*/
- boolean hasLock(Object lock);
+ public boolean hasLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ return transactionContext.hasLock(lock);
+ }
+ else
+ {
+ return invocationLocks != null && invocationLocks.contains(lock);
+ }
+ }
/**
* @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
*/
- boolean isLockingSuppressed();
+ public boolean isLockingSuppressed()
+ {
+ return getOptionOverrides() != null && getOptionOverrides().isSuppressLocking();
+ }
/**
* If set to true, the invocation is assumed to have originated locally. If set to false,
@@ -224,17 +362,32 @@
*
* @param originLocal flag to set
*/
- void setOriginLocal(boolean originLocal);
+ public void setOriginLocal(boolean originLocal)
+ {
+ this.originLocal = originLocal;
+ }
/**
* @return true if the current transaction is set to rollback only.
*/
- boolean isLocalRollbackOnly();
+ public boolean isLocalRollbackOnly()
+ {
+ return localRollbackOnly;
+ }
/**
* Resets the context, freeing up any references.
*/
- void reset();
+ public void reset()
+ {
+ transaction = null;
+ globalTransaction = null;
+ optionOverrides = null;
+ originLocal = true;
+ invocationLocks = null;
+ methodCall = null;
+ command = null;
+ }
/**
* This is a "copy-factory-method" that should be used whenever a clone of this class is needed. The resulting instance
@@ -245,22 +398,50 @@
* @return a new InvocationContext
*/
@SuppressWarnings("unchecked")
- InvocationContext copy();
+ public abstract InvocationContext copy();
/**
* Sets the state of the InvocationContext based on the template context passed in
*
* @param template template to copy from
*/
- void setState(InvocationContext template);
+ public void setState(InvocationContext template)
+ {
+ if (template == null)
+ {
+ throw new NullPointerException("Template InvocationContext passed in to InvocationContext.setState() passed in is null");
+ }
+ this.setGlobalTransaction(template.getGlobalTransaction());
+ this.setLocalRollbackOnly(template.isLocalRollbackOnly());
+ this.setOptionOverrides(template.getOptionOverrides());
+ this.setOriginLocal(template.isOriginLocal());
+ this.setTransaction(template.getTransaction());
+ }
+
/**
* @return the method call associated with this invocation
*/
@Deprecated
@SuppressWarnings("deprecation")
- MethodCall getMethodCall();
+ public MethodCall getMethodCall()
+ {
+ if (methodCall == null)
+ {
+ methodCall = createMethodCall();
+ }
+ return methodCall;
+ }
+ @SuppressWarnings("deprecation")
+ private MethodCall createMethodCall()
+ {
+ if (command == null) return null;
+ MethodCall call = new MethodCall();
+ call.setMethodId(command.getCommandId());
+ call.setArgs(command.getParameters());
+ return call;
+ }
/**
* Sets the method call associated with this invocation.
@@ -269,16 +450,28 @@
* @deprecated not used anymore. Interceptors will get a {@link org.jboss.cache.commands.ReplicableCommand} instance passed in along with an InvocationContext.
*/
@Deprecated
- void setMethodCall(MethodCall methodCall);
+ public void setMethodCall(MethodCall methodCall)
+ {
+ this.methodCall = methodCall;
+ }
/**
* If the lock acquisition timeout is overridden for current call using an option, then return that one.
* If not overridden, return default value.
*
- * @param defaultTimeout timeout to fall back to
+ * @param timeout timeout to fall back to
* @return timeout to use
*/
- long getLockAcquisitionTimeout(long defaultTimeout);
+ public long getLockAcquisitionTimeout(long timeout)
+ {
+ // TODO: this stuff really doesn't belong here. Put it somewhere else.
+ if (getOptionOverrides() != null
+ && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
+ {
+ timeout = getOptionOverrides().getLockAcquisitionTimeout();
+ }
+ return timeout;
+ }
/**
* This is only used for backward compatibility with old interceptors implementation and should <b>NOT</b> be
@@ -289,7 +482,10 @@
*/
@Deprecated
@SuppressWarnings("deprecation")
- void setCommand(VisitableCommand cacheCommand);
+ public void setCommand(VisitableCommand cacheCommand)
+ {
+ this.command = cacheCommand;
+ }
/**
* @return command that is in scope
@@ -297,18 +493,97 @@
*/
@Deprecated
@SuppressWarnings("deprecation")
- VisitableCommand getCommand();
+ public VisitableCommand getCommand()
+ {
+ return command;
+ }
/**
* @return true if there is current transaction associated with the invocation, and this transaction is in a valid state.
*/
- boolean isValidTransaction();
+ public boolean isValidTransaction()
+ {
+ // ought to move to the transaction context
+ return transaction != null && TransactionTable.isValid(transaction);
+ }
/**
* Throws the given throwable provided no options suppress or prevent this from happening.
*
- * @param throwable throwable to throw
+ * @param e throwable to throw
* @throws Throwable if allowed to throw one.
*/
- void throwIfNeeded(Throwable throwable) throws Throwable;
+ public void throwIfNeeded(Throwable e) throws Throwable
+ {
+ // TODO: this stuff really doesn't belong here. Put it somewhere else.
+ Option optionOverride = getOptionOverrides();
+ boolean shouldRethtrow = optionOverride == null || !optionOverride.isFailSilently();
+ if (!shouldRethtrow)
+ {
+ if (trace)
+ log.trace("There was a problem handling this request, but failSilently was set, so suppressing exception", e);
+ return;
+ }
+ throw e;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void doCopy(InvocationContext copy)
+ {
+ copy.command = command;
+ copy.globalTransaction = globalTransaction;
+ copy.invocationLocks = invocationLocks == null ? null : new LinkedHashSet(invocationLocks);
+ copy.localRollbackOnly = localRollbackOnly;
+ copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
+ copy.originLocal = originLocal;
+ copy.transaction = transaction;
+ copy.transactionContext = transactionContext;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "InvocationContext{" +
+ "transaction=" + transaction +
+ ", globalTransaction=" + globalTransaction +
+ ", transactionContext=" + transactionContext +
+ ", optionOverrides=" + optionOverrides +
+ ", originLocal=" + originLocal +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final InvocationContext that = (InvocationContext) o;
+
+ if (localRollbackOnly != that.localRollbackOnly) return false;
+ if (originLocal != that.originLocal) return false;
+ if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+ {
+ return false;
+ }
+ if (optionOverrides != null ? !optionOverrides.equals(that.optionOverrides) : that.optionOverrides != null)
+ {
+ return false;
+ }
+ if (transaction != null ? !transaction.equals(that.transaction) : that.transaction != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (transaction != null ? transaction.hashCode() : 0);
+ result = 29 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
+ result = 29 * result + (optionOverrides != null ? optionOverrides.hashCode() : 0);
+ result = 29 * result + (originLocal ? 1 : 0);
+ result = 29 * result + (localRollbackOnly ? 1 : 0);
+ return result;
+ }
}
Deleted: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java 2008-08-26 06:44:18 UTC (rev 6615)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java 2008-08-26 06:56:09 UTC (rev 6616)
@@ -1,370 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.invocation;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-
-import javax.transaction.Transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionContext;
-import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.util.Immutables;
-
-/**
- * This context holds information specific to a method invocation. This is used for Optimistic and Pessimisic Node Locking Schemes.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-@SuppressWarnings("deprecation")
-public abstract class AbstractInvocationContext implements InvocationContext
-{
- private static final Log log = LogFactory.getLog(AbstractInvocationContext.class);
- private static final boolean trace = log.isTraceEnabled();
-
- private Transaction transaction;
- private GlobalTransaction globalTransaction;
- protected TransactionContext transactionContext;
- private Option optionOverrides;
- // defaults to true.
- private boolean originLocal = true;
- private boolean localRollbackOnly;
- @Deprecated
- private MethodCall methodCall;
- @Deprecated
- private VisitableCommand command;
-
- /**
- * LinkedHashSet of locks acquired by the invocation. We use a LinkedHashSet because we need efficient Set semantics
- * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
- * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
- */
- protected LinkedHashSet invocationLocks;
-
- public void setLocalRollbackOnly(boolean localRollbackOnly)
- {
- this.localRollbackOnly = localRollbackOnly;
- }
-
- public Transaction getTransaction()
- {
- return transaction;
- }
-
- public void setTransaction(Transaction transaction)
- {
- this.transaction = transaction;
- }
-
- public TransactionContext getTransactionContext()
- {
- return transactionContext;
- }
-
- public void setTransactionContext(TransactionContext transactionContext)
- {
- this.transactionContext = transactionContext;
- }
-
- public GlobalTransaction getGlobalTransaction()
- {
- return globalTransaction;
- }
-
- public void setGlobalTransaction(GlobalTransaction globalTransaction)
- {
- this.globalTransaction = globalTransaction;
- }
-
- public Option getOptionOverrides()
- {
- if (optionOverrides == null)
- {
- optionOverrides = new Option();
- }
- return optionOverrides;
- }
-
- public boolean isOptionsUninitialised()
- {
- return optionOverrides == null;
- }
-
- public void setOptionOverrides(Option optionOverrides)
- {
- this.optionOverrides = optionOverrides;
- }
-
- public boolean isOriginLocal()
- {
- return originLocal;
- }
-
- @SuppressWarnings("unchecked")
- public List getLocks()
- {
- // first check transactional scope
- if (transactionContext != null) return transactionContext.getLocks();
- return invocationLocks == null || invocationLocks.isEmpty() ? Collections.emptyList() : Immutables.immutableListConvert(invocationLocks);
- }
-
- @SuppressWarnings("unchecked")
- public void addAllLocks(List locks)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.addAllLocks(locks);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
- invocationLocks.addAll(locks);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void addLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.addLock(lock);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
- invocationLocks.add(lock);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void removeLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.removeLock(lock);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks != null) invocationLocks.remove(lock);
- }
- }
-
- public void clearLocks()
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.clearLocks();
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks != null) invocationLocks.clear();
- }
- }
-
- public boolean hasLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- return transactionContext.hasLock(lock);
- }
- else
- {
- return invocationLocks != null && invocationLocks.contains(lock);
- }
- }
-
- public boolean isLockingSuppressed()
- {
- return getOptionOverrides() != null && getOptionOverrides().isSuppressLocking();
- }
-
- public void setOriginLocal(boolean originLocal)
- {
- this.originLocal = originLocal;
- }
-
- @Override
- public String toString()
- {
- return "InvocationContext{" +
- "transaction=" + transaction +
- ", globalTransaction=" + globalTransaction +
- ", transactionContext=" + transactionContext +
- ", optionOverrides=" + optionOverrides +
- ", originLocal=" + originLocal +
- '}';
- }
-
- public boolean isLocalRollbackOnly()
- {
- return localRollbackOnly;
- }
-
- public void reset()
- {
- transaction = null;
- globalTransaction = null;
- optionOverrides = null;
- originLocal = true;
- invocationLocks = null;
- methodCall = null;
- command = null;
- }
-
- @SuppressWarnings("unchecked")
- protected void doCopy(AbstractInvocationContext copy)
- {
- copy.command = command;
- copy.globalTransaction = globalTransaction;
- copy.invocationLocks = invocationLocks == null ? null : new LinkedHashSet(invocationLocks);
- copy.localRollbackOnly = localRollbackOnly;
- copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
- copy.originLocal = originLocal;
- copy.transaction = transaction;
- copy.transactionContext = transactionContext;
- }
-
- public void setState(InvocationContext template)
- {
- if (template == null)
- {
- throw new NullPointerException("Template InvocationContext passed in to InvocationContext.setState() passed in is null");
- }
-
- this.setGlobalTransaction(template.getGlobalTransaction());
- this.setLocalRollbackOnly(template.isLocalRollbackOnly());
- this.setOptionOverrides(template.getOptionOverrides());
- this.setOriginLocal(template.isOriginLocal());
- this.setTransaction(template.getTransaction());
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final AbstractInvocationContext that = (AbstractInvocationContext) o;
-
- if (localRollbackOnly != that.localRollbackOnly) return false;
- if (originLocal != that.originLocal) return false;
- if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
- {
- return false;
- }
- if (optionOverrides != null ? !optionOverrides.equals(that.optionOverrides) : that.optionOverrides != null)
- {
- return false;
- }
- if (transaction != null ? !transaction.equals(that.transaction) : that.transaction != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result;
- result = (transaction != null ? transaction.hashCode() : 0);
- result = 29 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
- result = 29 * result + (optionOverrides != null ? optionOverrides.hashCode() : 0);
- result = 29 * result + (originLocal ? 1 : 0);
- result = 29 * result + (localRollbackOnly ? 1 : 0);
- return result;
- }
-
- @Deprecated
- @SuppressWarnings("deprecation")
- public MethodCall getMethodCall()
- {
- if (methodCall == null)
- {
- methodCall = createMethodCall();
- }
- return methodCall;
- }
-
- @SuppressWarnings("deprecation")
- private MethodCall createMethodCall()
- {
- if (command == null) return null;
- MethodCall call = new MethodCall();
- call.setMethodId(command.getCommandId());
- call.setArgs(command.getParameters());
- return call;
- }
-
- @Deprecated
- public void setMethodCall(MethodCall methodCall)
- {
- this.methodCall = methodCall;
- }
-
- public long getLockAcquisitionTimeout(long timeout)
- {
- // TODO: this stuff really doesn't belong here. Put it somewhere else.
- if (getOptionOverrides() != null
- && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
- {
- timeout = getOptionOverrides().getLockAcquisitionTimeout();
- }
- return timeout;
- }
-
- @Deprecated
- @SuppressWarnings("deprecation")
- public void setCommand(VisitableCommand cacheCommand)
- {
- this.command = cacheCommand;
- }
-
- @Deprecated
- @SuppressWarnings("deprecation")
- public VisitableCommand getCommand()
- {
- return command;
- }
-
- public boolean isValidTransaction()
- {
- // ought to move to the transaction context
- return transaction != null && TransactionTable.isValid(transaction);
- }
-
- public void throwIfNeeded(Throwable e) throws Throwable
- {
- // TODO: this stuff really doesn't belong here. Put it somewhere else.
- Option optionOverride = getOptionOverrides();
- boolean shouldRethtrow = optionOverride == null || !optionOverride.isFailSilently();
- if (!shouldRethtrow)
- {
- if (trace)
- log.trace("There was a problem handling this request, but failSilently was set, so suppressing exception", e);
- return;
- }
- throw e;
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-08-26 06:44:18 UTC (rev 6615)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-08-26 06:56:09 UTC (rev 6616)
@@ -15,7 +15,7 @@
* @deprecated will be removed along with optimistic and pessimistic locking.
*/
@Deprecated
-public class LegacyInvocationContext extends AbstractInvocationContext
+public class LegacyInvocationContext extends InvocationContext
{
DataContainer container;
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-26 06:44:18 UTC (rev 6615)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-26 06:56:09 UTC (rev 6616)
@@ -16,7 +16,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 3.0
*/
-public class MVCCInvocationContext extends AbstractInvocationContext
+public class MVCCInvocationContext extends InvocationContext
{
private HashMap<Fqn, NodeSPI> lookedUpNodes = null;
private MVCCTransactionContext mvccTCtx;
16 years, 4 months