JBoss Cache SVN: r6157 - core/trunk/src/main/java/org/jboss/cache/commands/write.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-03 08:04:30 -0400 (Thu, 03 Jul 2008)
New Revision: 6157
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
Log:
Deal with evictions on root
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-07-03 12:00:46 UTC (rev 6156)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-07-03 12:04:30 UTC (rev 6157)
@@ -116,7 +116,7 @@
try
{
if (node == null) return true;
- if (node.hasChildrenDirect())
+ if (node.hasChildrenDirect() || fqn.isRoot())
{
if (trace) log.trace("removing DATA as node has children: evict(" + fqn + ")");
node.clearDataDirect();
16 years, 6 months
JBoss Cache SVN: r6156 - in core/trunk/src/test/java/org/jboss/cache: factories and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-03 08:00:46 -0400 (Thu, 03 Jul 2008)
New Revision: 6156
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
Log:
Build cfgs using beans rather than XML
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-07-03 12:00:22 UTC (rev 6155)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-07-03 12:00:46 UTC (rev 6156)
@@ -12,21 +12,19 @@
import org.jboss.cache.Fqn;
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.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.element.LoadersElementParser;
-import org.jboss.cache.config.parsing.element.BuddyElementParser;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
import javax.transaction.TransactionManager;
import java.util.ArrayList;
@@ -130,38 +128,25 @@
{
CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, false, false, true), false);
c.getConfiguration().setClusterName("BuddyReplicationTest");
- String buddyPoolNameStr = buddyPoolName != null ? "buddyPoolName=\"" + buddyPoolName + "\"" : "";
- String xmlStr =
- " <buddyReplication enabled=\"true\" " + buddyPoolNameStr + " buddyCommunicationTimeout=\"500000\">\n" +
- " <dataGravitation auto=\"" + useDataGravitation + "\" removeOnFind=\""+ removeOnFind + "\" searchBackupTrees=\"true\"/>\n" +
- " <buddyLocator class=\"org.jboss.cache.buddyreplication.NextMemberBuddyLocator\">\n" +
- " <properties>\n" +
- " numBuddies = " + numBuddies +"\n" +
- " </properties>\n" +
- " </buddyLocator>\n" +
- " </buddyReplication>";
-// // basic config
-// String xmlString = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n" +
-// "<buddyCommunicationTimeout>500000</buddyCommunicationTimeout>\n" +
-// " <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>\n" +
-// " <autoDataGravitation>" + useDataGravitation + "</autoDataGravitation>\n" +
-// " <dataGravitationRemoveOnFind>" + removeOnFind + "</dataGravitationRemoveOnFind>\n" +
-// " <buddyLocatorProperties>numBuddies = " + numBuddies + "</buddyLocatorProperties>\n";
-//
-// if (buddyPoolName != null) xmlString += "<buddyPoolName>" + buddyPoolName + "</buddyPoolName>";
-// xmlString += "</config>";
- BuddyElementParser parser = new BuddyElementParser();
- Element element = XmlConfigHelper.stringToElement(xmlStr);
- BuddyReplicationConfig config = parser.parseBuddyElement(element);
-// BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
- c.getConfiguration().setBuddyReplicationConfig(config);
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ if (buddyPoolName != null) brc.setBuddyPoolName(buddyPoolName);
+ brc.setEnabled(true);
+ brc.setBuddyCommunicationTimeout(500000);
+ brc.setDataGravitationRemoveOnFind(removeOnFind);
+ brc.setDataGravitationSearchBackupTrees(true);
+ brc.setAutoDataGravitation(useDataGravitation);
+ NextMemberBuddyLocatorConfig nextMemberBuddyLocatorConfig = new NextMemberBuddyLocatorConfig();
+ nextMemberBuddyLocatorConfig.setNumBuddies(numBuddies);
+ brc.setBuddyLocatorConfig(nextMemberBuddyLocatorConfig);
+ c.getConfiguration().setBuddyReplicationConfig(brc);
+
c.getConfiguration().setFetchInMemoryState(true);
if (optimisticLocks)
{
c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
}
- c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.getConfiguration().setSyncCommitPhase(true);// helps track down breakages
// Call the hook that allows mux integration if that's what the test wants
@@ -237,15 +222,13 @@
{
CacheSPI cache = createCache(1, null, useDataGravitation, removeOnFind, false);
- String xmlStr = " " +
- " <loaders passivation=\"" + passivation + "\" shared=\"false\">\n" +
- " <preload/>\n" +
- " <loader class=\"" + DummyInMemoryCacheLoader.class.getName() + "\" async=\"false\" fetchPersistentState=\""+ fetchPersistent + "\"/>\n" +
- " </loaders>";
- System.out.println("xmlStr = +\n" + xmlStr);
- Element xmlEl = XmlConfigHelper.stringToElement(xmlStr);
- LoadersElementParser parser = new LoadersElementParser();
- CacheLoaderConfig config = parser.parseLoadersElement(xmlEl);
+ CacheLoaderConfig config = new CacheLoaderConfig();
+ IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
+ iclc.setClassName(DummyInMemoryCacheLoader.class.getName());
+ iclc.setFetchPersistentState(fetchPersistent);
+ config.addIndividualCacheLoaderConfig(iclc);
+ config.setShared(false);
+ config.setPassivation(passivation);
cache.getConfiguration().setCacheLoaderConfig(config);
if (start)
{
Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-07-03 12:00:22 UTC (rev 6155)
+++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-07-03 12:00:46 UTC (rev 6156)
@@ -5,20 +5,20 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import static org.jboss.cache.config.Configuration.CacheMode.*;
+import static org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.element.BuddyElementParser;
-import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.interceptors.*;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
import java.util.Iterator;
import java.util.List;
@@ -32,7 +32,7 @@
public void setUp() throws Exception
{
cache = (CacheSPI) new DefaultCacheFactory().createCache(false);
- cache.getConfiguration().setCacheMode("LOCAL");
+ cache.getConfiguration().setCacheMode(LOCAL);
cache.getConfiguration().setUseLazyDeserialization(false);
}
@@ -70,7 +70,7 @@
public void testTxConfig() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
@@ -91,28 +91,21 @@
protected CacheLoaderConfig getCacheLoaderConfig(boolean pasv, boolean fetchPersistentState) throws Exception
{
- String xmlStr =
- " <loaders passivation=\"" + pasv + "\">\n" +
- " <preload/>\n" +
- " <loader class=\"org.jboss.cache.loader.FileCacheLoader\" fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
- " ignoreModifications=\"false\">\n" +
- " <properties>\n" +
- " location=/tmp\n" +
- " </properties>\n" +
- " </loader>\n" +
- " </loaders>";
-
- Element element = XmlConfigHelper.stringToElement(xmlStr);
- LoadersElementParser parser = new LoadersElementParser();
- return parser.parseLoadersElement(element);
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
+ iclc.setClassName(DummyInMemoryCacheLoader.class.getName());
+ iclc.setFetchPersistentState(fetchPersistentState);
+ clc.addIndividualCacheLoaderConfig(iclc);
+ clc.setPassivation(pasv);
+ return clc;
}
public void testSharedCacheLoaderConfig() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(false, false));
- cache.getConfiguration().setCacheMode("REPL_ASYNC");
+ cache.getConfiguration().setCacheMode(REPL_ASYNC);
cache.getConfiguration().setFetchInMemoryState(false);
cache.create();
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
@@ -139,9 +132,9 @@
public void testUnsharedCacheLoaderConfig() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(false, true));
- cache.getConfiguration().setCacheMode("REPL_ASYNC");
+ cache.getConfiguration().setCacheMode(REPL_ASYNC);
cache.getConfiguration().setFetchInMemoryState(false);
cache.create();
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
@@ -168,8 +161,8 @@
public void testTxAndRepl() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setCacheMode("repl_sync");
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setCacheMode(REPL_SYNC);
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
Iterator<CommandInterceptor> interceptors = list.iterator();
@@ -193,7 +186,7 @@
public void testOptimisticChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ cache.getConfiguration().setNodeLockingScheme(OPTIMISTIC);
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
@@ -216,8 +209,8 @@
public void testOptimisticReplicatedChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- cache.getConfiguration().setCacheMode("REPL_SYNC");
+ cache.getConfiguration().setNodeLockingScheme(OPTIMISTIC);
+ cache.getConfiguration().setCacheMode(REPL_SYNC);
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
@@ -241,7 +234,7 @@
public void testOptimisticCacheLoaderChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ cache.getConfiguration().setNodeLockingScheme(OPTIMISTIC);
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(false, false));
cache.create();
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
@@ -267,7 +260,7 @@
public void testOptimisticPassivationCacheLoaderChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ cache.getConfiguration().setNodeLockingScheme(OPTIMISTIC);
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(true, false));
cache.create();
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
@@ -293,7 +286,7 @@
public void testInvalidationInterceptorChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setCacheMode("REPL_ASYNC");
+ cache.getConfiguration().setCacheMode(REPL_ASYNC);
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
@@ -312,7 +305,7 @@
// now for my invalidation chain.
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setCacheMode("INVALIDATION_ASYNC");
+ cache.getConfiguration().setCacheMode(INVALIDATION_ASYNC);
chain = getInterceptorChainFactory(cache).buildInterceptorChain();
list = chain.asList();
interceptors = list.iterator();
@@ -384,17 +377,12 @@
public void testBuddyReplicationOptLocking() throws Exception
{
- String xmlStr =
- " <buddy enabled=\"true\" buddyPoolName=\"buddyPoolName\" buddyCommunicationTimeout=\"600000\">\n" +
- " <dataGravitation auto=\"true\" removeOnFind=\"true\" searchBackupTrees=\"true\"/>\n" +
- " </buddy>";
- Element element = XmlConfigHelper.stringToElement(xmlStr);
- BuddyElementParser parser = new BuddyElementParser();
- BuddyReplicationConfig brc = parser.parseBuddyElement(element);
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ brc.setEnabled(true);
cache.getConfiguration().setBuddyReplicationConfig(brc);
- cache.getConfiguration().setCacheMode("REPL_SYNC");
- cache.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
+ cache.getConfiguration().setCacheMode(REPL_SYNC);
+ cache.getConfiguration().setNodeLockingScheme(OPTIMISTIC);
cache.create();// initialise various subsystems such as BRManager
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
@@ -421,12 +409,10 @@
public void testBuddyReplicationPessLocking() throws Exception
{
- String xmlStr = "<buddy enabled=\"true\" buddyPoolName=\"buddyPoolName\" buddyCommunicationTimeout=\"600000\"/>";
- Element element = XmlConfigHelper.stringToElement(xmlStr);
- BuddyElementParser parser = new BuddyElementParser();
- BuddyReplicationConfig brc = parser.parseBuddyElement(element);
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ brc.setEnabled(true);
cache.getConfiguration().setBuddyReplicationConfig(brc);
- cache.getConfiguration().setCacheMode("REPL_SYNC");
+ cache.getConfiguration().setCacheMode(REPL_SYNC);
cache.create();// initialise various subsystems such as BRManager
InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-07-03 12:00:22 UTC (rev 6155)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-07-03 12:00:46 UTC (rev 6156)
@@ -7,13 +7,13 @@
package org.jboss.cache.factories;
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.ConfigurationException;
import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.transaction.TransactionSetup;
import org.jgroups.conf.XmlConfigurator;
@@ -82,18 +82,18 @@
String properties, boolean async, boolean fetchPersistentState,
boolean shared, boolean purgeOnStartup, boolean ignoreModifications) throws Exception
{
- String xmlStr =
- " <loaders passivation=\"" + passivation + "\" shared=\"" + shared + "\">\n" +
- " <loader class=\""+ cacheloaderClass + "\" async=\"" + async + "\" fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
- " purgeOnStartup=\"" + purgeOnStartup + "\" ignoreModifications=\"" + ignoreModifications + "\">\n" +
- " <properties>" + properties + "</properties>\n" +
- " </loader>\n" +
- " </loaders>";
- Element xmlElement = XmlConfigHelper.stringToElement(xmlStr);
- LoadersElementParser parser = new LoadersElementParser();
- CacheLoaderConfig clConfig = parser.parseLoadersElement(xmlElement);
- clConfig.setPreload(preload);
- return clConfig;
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
+ iclc.setClassName(cacheloaderClass);
+ iclc.setAsync(async);
+ iclc.setFetchPersistentState(fetchPersistentState);
+ iclc.setPurgeOnStartup(purgeOnStartup);
+ iclc.setIgnoreModifications(ignoreModifications);
+ iclc.setProperties(properties);
+ clc.addIndividualCacheLoaderConfig(iclc);
+ clc.setPassivation(passivation);
+ clc.setShared(shared);
+ return clc;
}
public static CacheLoaderConfig.IndividualCacheLoaderConfig buildIndividualCacheLoaderConfig(String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean purgeOnStartup, boolean ignoreModifications) throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-07-03 12:00:22 UTC (rev 6155)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-07-03 12:00:46 UTC (rev 6156)
@@ -7,11 +7,9 @@
package org.jboss.cache.loader;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
import java.io.File;
@@ -23,8 +21,8 @@
@Test(groups = {"functional"})
public class ChainingCacheLoaderBasicTest extends CacheLoaderTestsBase
{
- private String loc1 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-1";
- private String loc2 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-2";
+ private String loc1 = "JBossCache-ChainingCacheLoaderBasicTest-1";
+ private String loc2 = "JBossCache-ChainingCacheLoaderBasicTest-2";
public ChainingCacheLoaderBasicTest()
{
@@ -45,23 +43,23 @@
protected CacheLoaderConfig getCacheLoaderConfig(String loc1, String loc2) throws Exception
{
- String xmlStr =
- " <loaders passivation=\"false\">\n" +
- " <loader class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\" fetchPersistentState=\"true\"\n" +
- " ignoreModifications=\"false\" purgeOnStartup=\"false\">\n" +
- " <properties>\n" +
- " location=" + loc1+ "\n" +
- " </properties>\n" +
- " </loader>\n" +
- " <loader class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\" fetchPersistentState=\"false\"\n" +
- " ignoreModifications=\"false\" purgeOnStartup=\"false\">\n" +
- " <properties>\n" +
- " location=" + loc2+ "\n" +
- " </properties>\n" +
- " </loader>\n" +
- " </loaders>";
- Element element = XmlConfigHelper.stringToElement(xmlStr);
- LoadersElementParser parser = new LoadersElementParser();
- return parser.parseLoadersElement(element);
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ // clc 1
+ IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
+ iclc.setClassName(DummySharedInMemoryCacheLoader.class.getName());
+ iclc.setAsync(false);
+ iclc.setFetchPersistentState(true);
+ iclc.setPurgeOnStartup(false);
+ iclc.setIgnoreModifications(false);
+ iclc.setProperties("bin=" + loc1);
+ clc.addIndividualCacheLoaderConfig(iclc);
+
+ IndividualCacheLoaderConfig iclc2 = iclc.clone();
+ iclc2.setFetchPersistentState(false);
+ iclc2.setProperties("bin=" + loc2);
+ clc.addIndividualCacheLoaderConfig(iclc2);
+ clc.setPassivation(false);
+ clc.setShared(false);
+ return clc;
}
}
16 years, 6 months
JBoss Cache SVN: r6155 - core/trunk/src/main/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-03 08:00:22 -0400 (Thu, 03 Jul 2008)
New Revision: 6155
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
Log:
get root directly
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-07-02 17:34:40 UTC (rev 6154)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-07-03 12:00:22 UTC (rev 6155)
@@ -293,7 +293,12 @@
broadcastBuddyPoolMembership();
- if (!cache.exists(BUDDY_BACKUP_SUBTREE_FQN)) cache.getRoot().addChildDirect(BUDDY_BACKUP_SUBTREE_FQN);
+ if (!cache.exists(BUDDY_BACKUP_SUBTREE_FQN))
+ {
+ // need to get the root DIRECTLY. cache.getRoot() will pass a call up the interceptor chain and we will
+ // have a problem with the cache not being started.
+ dataContainer.getRoot().addChildDirect(BUDDY_BACKUP_SUBTREE_FQN);
+ }
// allow waiting threads to process.
initialisationLatch.countDown();
16 years, 6 months
JBoss Cache SVN: r6154 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-02 13:34:40 -0400 (Wed, 02 Jul 2008)
New Revision: 6154
Removed:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedWithParentLockTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewWithParentLockTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewWithParentLockTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewLockTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewLockTest.java
Log:
MVCC to lock parents always
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -71,7 +71,7 @@
{
// TODO: remove this ugly hack
NodeSPI node = lookupForEviction(ctx, fqn);
- if (node == null)
+ if (node == null || node.isDeleted())
{
return false;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeFactory;
@@ -33,6 +34,7 @@
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.mvcc.InternalNode;
+import org.jboss.cache.mvcc.NullMarkerNode;
import org.jboss.cache.mvcc.ReadCommittedNode;
import java.util.ArrayList;
@@ -58,7 +60,7 @@
// How will wrapper nodes unwrap?
- boolean allowWriteSkew, lockParentForChildInsertRemove;
+ boolean allowWriteSkew;
LockManager lockManager;
DataContainer dataContainer;
NodeFactory nodeFactory;
@@ -76,7 +78,6 @@
public void start()
{
allowWriteSkew = configuration.isAllowWriteSkew();
- lockParentForChildInsertRemove = configuration.isLockParentForChildInsertRemove();
defaultLockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
}
@@ -104,31 +105,83 @@
@Override
public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
+ addNodeAndParentForRemoval(ctx, command.getFqn(), true);
+ return invokeNextInterceptor(ctx, command);
+ }
+
+ private List<Fqn> addNodeAndParentForRemoval(InvocationContext ctx, Fqn nodeFqn, boolean recursive) throws InterruptedException
+ {
// when removing a node we want to get a lock on the Fqn anyway and return the wrapped node.
- Fqn nodeFqn = command.getFqn();
+ if (nodeFqn.isRoot()) throw new CacheException("Attempting to remove Fqn.ROOT!");
- if (!nodeFqn.isRoot())
+ Fqn parentFqn = nodeFqn.getParent();
+ // inspect parent
+ boolean needToCopyParent = lock(ctx, parentFqn);
+
+ // Ensure the node is in the context.
+ putNodeInContext(ctx, parentFqn, needToCopyParent);
+
+ boolean needToCopyNode = lock(ctx, nodeFqn);
+
+ // Ensure the node is in the context.
+ putNodeInContext(ctx, nodeFqn, needToCopyNode);
+
+ ReadCommittedNode node = (ReadCommittedNode) ctx.lookUpNode(nodeFqn);
+
+ // update child ref on parent to point to child as this is now a copy.
+ if (node != null && !(node instanceof NullMarkerNode))
{
- Fqn parentFqn = nodeFqn.getParent();
- // inspect parent
- InternalNode parent = dataContainer.peekInternalNode(parentFqn, false);
+ if (needToCopyNode || needToCopyParent)
{
- if (lockParentForChildInsertRemove || (parent != null && parent.isLockForChildInsertRemove()))
+
+ ReadCommittedNode parent = (ReadCommittedNode) ctx.lookUpNode(parentFqn);
+ parent.addChildDirect(nodeFactory.createNodeInvocationDelegate((InternalNode) node.getDelegationTarget()));
+ }
+
+ // now deal with children.
+ if (recursive)
+ {
+ Map childMap = node.getChildrenMapDirect();
+ List<Fqn> fqnsToBeRemoved = new LinkedList<Fqn>();
+ fqnsToBeRemoved.add(nodeFqn);
+ if (childMap == null || childMap.isEmpty()) return fqnsToBeRemoved;
+
+ for (Object n : childMap.values())
{
- boolean needToCopyNode = lock(ctx, parentFqn);
+ NodeSPI child = (NodeSPI) n;
+ lockForRemoval(child.getFqn(), recursive, ctx, fqnsToBeRemoved);
+ }
- // Ensure the node is in the context.
- putNodeInContext(ctx, parentFqn, needToCopyNode);
- }
+ return fqnsToBeRemoved;
}
}
- boolean needToCopyNode = lock(ctx, nodeFqn);
+ return null;
+ }
- // Ensure the node is in the context.
- putNodeInContext(ctx, nodeFqn, needToCopyNode);
+ private void lockForRemoval(Fqn fqn, boolean isRecursive, InvocationContext ctx, List<Fqn> fqnList) throws InterruptedException
+ {
+ lock(ctx, fqn); // lock node
+ if (fqnList != null) fqnList.add(fqn);
- return invokeNextInterceptor(ctx, command);
+ // now wrap and add to the context
+ ReadCommittedNode rcn = (ReadCommittedNode) getWrappedNode(ctx, fqn, true, false, true);
+ if (rcn != null)
+ {
+ rcn.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory);
+
+ if (isRecursive)
+ {
+ Map<Object, NodeSPI> children = rcn.getChildrenMapDirect();
+ if (children != null)
+ {
+ for (NodeSPI child : children.values())
+ {
+ lockForRemoval(child.getFqn(), isRecursive, ctx, fqnList);
+ }
+ }
+ }
+ }
}
private void putNodeInContext(InvocationContext ctx, Fqn fqn, boolean needToCopyNode)
@@ -143,7 +196,7 @@
if (needToCopyNode && node != null && !node.isChanged()) // node could be null if using read-committed
{
- node.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
+ node.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory);
}
}
@@ -159,33 +212,8 @@
{
// set lock acquisition timeout to 0 - we need to fail fast.
ctx.getOptionOverrides().setLockAcquisitionTimeout(0);
+ List<Fqn> fqnsToEvict = addNodeAndParentForRemoval(ctx, command.getFqn(), command.isRecursive());
- // similar to remove node, except that we need to take care of the recursive case.
- Fqn nodeFqn = command.getFqn();
-
- if (!nodeFqn.isRoot())
- {
- Fqn parentFqn = nodeFqn.getParent();
- // inspect parent
- InternalNode parent = dataContainer.peekInternalNode(parentFqn, true);
- {
- if (lockParentForChildInsertRemove || (parent != null && parent.isLockForChildInsertRemove()))
- {
- // lock parent
- lockManager.lockAndRecord(parentFqn, WRITE, ctx);
-
- // retrieve again from the dataContainer in case we have a race, and add to the context
- ReadCommittedNode rcn = (ReadCommittedNode) getWrappedNode(ctx, parentFqn, true, false, false);
- if (rcn != null)
- rcn.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
- }
- }
- }
-
- List<Fqn> fqnsToEvict = command.isRecursive() ? new LinkedList<Fqn>() : null;
-
- lockForEviction(nodeFqn, command.isRecursive(), ctx, fqnsToEvict);
-
if (fqnsToEvict != null) // add this set to the command
{
command.setNodesToEvict(fqnsToEvict);
@@ -194,31 +222,6 @@
return invokeNextInterceptor(ctx, command);
}
- private void lockForEviction(Fqn fqn, boolean isRecursive, InvocationContext ctx, List<Fqn> fqnsToEvict) throws InterruptedException
- {
- lockManager.lockAndRecord(fqn, WRITE, ctx); // lock node.
- if (fqnsToEvict != null) fqnsToEvict.add(fqn);
-
- // now wrap and add to the context
- ReadCommittedNode rcn = (ReadCommittedNode) getWrappedNode(ctx, fqn, true, false, true);
- if (rcn != null)
- {
- rcn.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
-
- if (isRecursive)
- {
- Map<Object, NodeSPI> children = rcn.getChildrenMapDirect();
- if (children != null)
- {
- for (NodeSPI child : children.values())
- {
- lockForEviction(child.getFqn(), isRecursive, ctx, fqnsToEvict);
- }
- }
- }
- }
- }
-
@Override
public Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
{
@@ -340,8 +343,7 @@
{
// for each of these, swap refs
ReadCommittedNode rcn = (ReadCommittedNode) ctx.lookUpNode(fqnsToUnlock[i]);
-// rcn.copyNodeForUpdate(dataContainer, allowWriteSkew);
- rcn.commitUpdate(dataContainer, nodeFactory);
+ if (rcn != null) rcn.commitUpdate(dataContainer, nodeFactory); // could be null with read-committed
// and then unlock
lockManager.unlock(fqnsToUnlock[i], owner);
}
@@ -462,7 +464,7 @@
if (lockForWriting && lock(context, fqn))
{
// create a copy of the underlying node
- n.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
+ n.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory);
}
if (trace) log.trace("Retrieving wrapped node " + fqn);
return n;
@@ -481,7 +483,7 @@
ReadCommittedNode wrapped = nodeFactory.createMvccNode(in);
context.putLookedUpNode(fqn, wrapped);
if (needToCopy)
- wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
+ wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory);
return wrapped;
}
@@ -491,14 +493,11 @@
Fqn parentFqn = fqn.getParent();
NodeSPI parent = getWrappedNode(context, parentFqn, false, createIfAbsent, false);
// do we need to lock the parent to create children?
- if (lockParentForChildInsertRemove || parent.isLockForChildInsertRemove())
+ // get a lock on the parent.
+ if (lock(context, parentFqn))
{
- // get a lock on the parent.
- if (lock(context, parentFqn))
- {
- ReadCommittedNode parentRCN = (ReadCommittedNode) context.lookUpNode(parentFqn);
- parentRCN.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
- }
+ ReadCommittedNode parentRCN = (ReadCommittedNode) context.lookUpNode(parentFqn);
+ parentRCN.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory);
}
// now to lock and create the node.
@@ -508,7 +507,10 @@
in = (InternalNode) ((NodeInvocationDelegate) temp).getDelegationTarget();
ReadCommittedNode wrapped = nodeFactory.createMvccNode(in);
context.putLookedUpNode(fqn, wrapped);
- wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
+ wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory);
+ // since we copied the child make sure we update the parent's ref
+ parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(wrapped.getNode()));
+
return wrapped;
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -281,4 +281,12 @@
{
delegate.printDetails(sb, indent);
}
+
+ @Override
+ public String toString()
+ {
+ return "NodeReference{" +
+ "delegate=" + delegate +
+ '}';
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -36,7 +36,7 @@
}
@Override
- public void copyNodeForUpdate(DataContainer d, boolean b, InvocationContext ctx, NodeFactory nodeFactory, boolean lockParent)
+ public void copyNodeForUpdate(DataContainer d, boolean b, InvocationContext ctx, NodeFactory nodeFactory)
{
// no op
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -30,7 +30,7 @@
return false;
}
- public void copyNodeForUpdate(DataContainer container, boolean allowWriteSkew, InvocationContext ctx, NodeFactory nodeFactory, boolean lockParent)
+ public void copyNodeForUpdate(DataContainer container, boolean allowWriteSkew, InvocationContext ctx, NodeFactory nodeFactory)
{
changed = true;
backup = node;
@@ -52,16 +52,25 @@
protected void updateNode(DataContainer container, NodeFactory nf)
{
- // TODO: Deal with creating - what if children is null?
-
if (isDeleted())
{
Fqn fqn = getFqn();
- NodeSPI parent = container.peek(fqn);
- if (parent != null)
+ if (!fqn.isRoot())
{
- parent.removeChildDirect(fqn.getLastElement());
+ NodeSPI parent = container.peek(fqn.getParent());
+ if (parent != null)
+ {
+ parent.removeChildDirect(fqn.getLastElement());
+ }
+ else
+ {
+ if (trace) log.trace("Parent is null in the underlying cache; cannot remove.");
+ }
}
+ else
+ {
+ log.warn("Attempting to remove the root node. Not doing anything!");
+ }
}
else
{
@@ -86,4 +95,14 @@
{
this.changed = changed;
}
+
+ public InternalNode getNode()
+ {
+ return node;
+ }
+
+ public InternalNode getBackupNode()
+ {
+ return backup;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -23,7 +23,7 @@
}
@Override
- public void copyNodeForUpdate(DataContainer container, boolean allowWriteSkew, InvocationContext ctx, NodeFactory nodeFactory, boolean lockParent)
+ public void copyNodeForUpdate(DataContainer container, boolean allowWriteSkew, InvocationContext ctx, NodeFactory nodeFactory)
{
Fqn fqn = getFqn();
@@ -48,14 +48,6 @@
// TODO: Make sure this works with custom versions as well!
DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
node.setVersion(newVersion);
-
- // if the parent is in the context make sure the parent has a ref to the copy now.
- Fqn parentFqn = getFqn().getParent();
- if (!getFqn().isRoot() && (lockParent || container.peek(parentFqn) == null))
- {
- NodeSPI parent = ctx.lookUpNode(parentFqn);
- if (parent != null) parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node));
- }
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -41,7 +41,6 @@
protected Fqn ABCD = Fqn.fromString("/a/b/c/d");
protected LockManager lockManager;
protected InvocationContextContainer icc;
- protected boolean lockParentForInsertRemove = false;
protected boolean repeatableRead = true;
protected boolean allowWriteSkew = false;
@@ -51,7 +50,6 @@
cache = new DefaultCacheFactory<String, String>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL), false);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache.getConfiguration().setLockParentForChildInsertRemove(lockParentForInsertRemove);
cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
cache.getConfiguration().setAllowWriteSkew(allowWriteSkew);
// reduce lock acquisition timeout so this doesn't take forever to run
@@ -92,10 +90,7 @@
{
tm.begin();
cache.put(AB, "k", "v");
- if (lockParentForInsertRemove)
- assertLocked(Fqn.ROOT);
- else
- assertNotLocked(Fqn.ROOT);
+ assertLocked(Fqn.ROOT);
assertLocked(A);
assertLocked(AB);
assertNotLocked(ABC);
@@ -117,10 +112,7 @@
cache.put(ABC, "k", "v");
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
- if (lockParentForInsertRemove)
- assertLocked(AB);
- else
- assertNotLocked(AB);
+ assertLocked(AB);
assertLocked(ABC);
tm.commit();
@@ -131,10 +123,7 @@
{
tm.begin();
cache.put(AB, Collections.singletonMap("k", "v"));
- if (lockParentForInsertRemove)
- assertLocked(Fqn.ROOT);
- else
- assertNotLocked(Fqn.ROOT);
+ assertLocked(Fqn.ROOT);
assertLocked(A);
assertLocked(AB);
assertNotLocked(ABC);
@@ -157,10 +146,7 @@
cache.put(ABC, Collections.singletonMap("k", "v"));
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
- if (lockParentForInsertRemove)
- assertLocked(AB);
- else
- assertNotLocked(AB);
+ assertLocked(AB);
assertLocked(ABC);
tm.commit();
@@ -177,10 +163,7 @@
tm.begin();
cache.removeNode(AB);
assertLocked(AB);
- if (lockParentForInsertRemove)
- assertLocked(A);
- else
- assertNotLocked(A);
+ assertLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -197,10 +180,7 @@
tm.begin();
cache.evict(AB);
assertLocked(AB);
- if (lockParentForInsertRemove)
- assertLocked(A);
- else
- assertNotLocked(A);
+ assertLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -223,10 +203,7 @@
assertLocked(AB);
assertLocked(ABC);
assertLocked(ABCD);
- if (lockParentForInsertRemove)
- assertLocked(A);
- else
- assertNotLocked(A);
+ assertLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -240,10 +217,7 @@
tm.begin();
cache.removeNode(AB);
assertLocked(AB);
- if (lockParentForInsertRemove)
- assertLocked(A);
- else
- assertNotLocked(A);
+ assertLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -257,10 +231,7 @@
tm.begin();
cache.evict(AB);
assertLocked(AB);
- if (lockParentForInsertRemove)
- assertLocked(A);
- else
- assertNotLocked(A);
+ assertLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockTest.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockTest.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -9,6 +9,5 @@
public ReadCommittedLockTest()
{
repeatableRead = false;
- lockParentForInsertRemove = false;
}
}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedWithParentLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedWithParentLockTest.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedWithParentLockTest.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -1,14 +0,0 @@
-package org.jboss.cache.api.mvcc.read_committed;
-
-import org.jboss.cache.api.mvcc.LockTestBase;
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "mvcc"})
-public class ReadCommittedWithParentLockTest extends LockTestBase
-{
- public ReadCommittedWithParentLockTest()
- {
- repeatableRead = false;
- lockParentForInsertRemove = true;
- }
-}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -25,6 +25,7 @@
protected void configure(Configuration c)
{
c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c.setLockParentForChildInsertRemove(true);
}
protected void assertNodeLockingScheme()
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewLockTest.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewLockTest.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -8,6 +8,5 @@
public RepeatableReadNoWriteSkewLockTest()
{
allowWriteSkew = false;
- lockParentForInsertRemove = false;
}
}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewWithParentLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewWithParentLockTest.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadNoWriteSkewWithParentLockTest.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -1,13 +0,0 @@
-package org.jboss.cache.api.mvcc.repeatable_read;
-
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "mvcc"})
-public class RepeatableReadNoWriteSkewWithParentLockTest extends RepeatableReadTestBase
-{
- public RepeatableReadNoWriteSkewWithParentLockTest()
- {
- allowWriteSkew = false;
- lockParentForInsertRemove = true;
- }
-}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewLockTest.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewLockTest.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -8,6 +8,5 @@
public RepeatableReadWriteSkewLockTest()
{
allowWriteSkew = true;
- lockParentForInsertRemove = false;
}
}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewWithParentLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewWithParentLockTest.java 2008-07-02 13:39:16 UTC (rev 6153)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadWriteSkewWithParentLockTest.java 2008-07-02 17:34:40 UTC (rev 6154)
@@ -1,13 +0,0 @@
-package org.jboss.cache.api.mvcc.repeatable_read;
-
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "mvcc"})
-public class RepeatableReadWriteSkewWithParentLockTest extends RepeatableReadTestBase
-{
- public RepeatableReadWriteSkewWithParentLockTest()
- {
- allowWriteSkew = true;
- lockParentForInsertRemove = true;
- }
-}
16 years, 6 months
JBoss Cache SVN: r6153 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 6 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-02 09:39:16 -0400 (Wed, 02 Jul 2008)
New Revision: 6153
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/commands/pessimistic/write/PessRemoveNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java
Log:
Created a new getParentDirect() SPI call
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -374,7 +374,8 @@
// mark the node to be removed (and all children) as invalid so anyone holding a direct reference to it will
// be aware that it is no longer valid.
n.setValid(false, true);
- return n.getParent().removeChildDirect(n.getFqn().getLastElement());
+ NodeSPI parent = peek(f.getParent(), true);
+ return parent.removeChildDirect(n.getFqn().getLastElement());
}
}
else
@@ -415,7 +416,7 @@
{
NodeSPI targetNode = peek(fqn, false, true);
if (targetNode == null) return;
- NodeSPI parentNode = targetNode.getParent();
+ NodeSPI parentNode = targetNode.getParentDirect();
targetNode.setValid(false, false);
if (parentNode != null)
{
Modified: core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -456,7 +456,7 @@
* @return parent node
* @see Node#getParent()
*/
- NodeSPI<K, V> getParent();
+ NodeSPI<K, V> getParentDirect();
/**
* @return true if the node has one or more child nodes; false otherwise.
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -609,7 +609,7 @@
// Remove the subtree from the main cache and any buddy backup trees
for (Fqn subtree : list)
{
- subtreeRoot = cache.peek(subtree, false, false);
+ subtreeRoot = cache.peek(subtree, false);
if (subtreeRoot != null)
{
// Acquire locks
@@ -618,7 +618,7 @@
subtreeLocked = lockManager.lockAll(subtreeRoot, WRITE, owner, stateFetchTimeout);
// Lock the parent, as we're about to write to it
- parent = subtreeRoot.getParent();
+ parent = subtreeRoot.getParentDirect();
if (parent != null) parentLocked = lockManager.lock(parent.getFqn(), WRITE, owner, stateFetchTimeout);
// Remove the subtree
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -514,7 +514,7 @@
else
{
NodeSPI child = getChildDirect(f);
- return child != null && child.getParent().removeChildDirect(f.getLastElement());
+ return child != null && child.getParentDirect().removeChildDirect(f.getLastElement());
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -13,6 +13,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.RPCManager;
import org.jboss.cache.Region;
import org.jboss.cache.RegionEmptyException;
@@ -48,7 +49,18 @@
import org.jgroups.util.Util;
import java.io.ByteArrayInputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Vector;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
@@ -1020,7 +1032,7 @@
}
- private void migrateDefunctData(Node backupRoot, Address dataOwner)
+ private void migrateDefunctData(NodeSPI backupRoot, Address dataOwner)
{
Fqn defunctBackupRootFqn = getDefunctBackupRootFqn(dataOwner);
@@ -1035,7 +1047,7 @@
}
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- backupRoot.getParent().removeChild(backupRoot.getFqn().getLastElement());
+ backupRoot.getParentDirect().removeChild(backupRoot.getFqn().getLastElement());
}
private Fqn getDefunctBackupRootFqn(Address dataOwner)
@@ -1169,7 +1181,7 @@
{
BuddyGroup bg = buddyGroupsIParticipateIn.remove(a);
Fqn backupRootFqn = buddyFqnTransformer.getBackupRoot(bg.getDataOwner());
- Node backupRoot = cache.getNode(backupRootFqn);
+ NodeSPI backupRoot = cache.getNode(backupRootFqn);
if (backupRoot != null)
{
// could be a race condition where the backup region has been removed because we have been removed
Modified: core/trunk/src/main/java/org/jboss/cache/commands/pessimistic/write/PessRemoveNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/pessimistic/write/PessRemoveNodeCommand.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/commands/pessimistic/write/PessRemoveNodeCommand.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -38,7 +38,7 @@
// now record rollback info.
if (globalTransaction != null && found)
{
- NodeSPI parentNode = targetNode.getParent();
+ NodeSPI parentNode = targetNode.getParentDirect();
prepareForRollback(parentNode);
}
return found;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -102,7 +102,7 @@
if (trace) log.trace("Moving " + fqn + " to sit under " + to);
- NodeSPI oldParent = node.getParent();
+ NodeSPI oldParent = (NodeSPI) node.getParent();
Object nodeName = toMoveFqn.getLastElement();
// now that we have the parent and target nodes:
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -169,7 +169,7 @@
if (!useTombstones)
{
// don't retain the tombstone
- NodeSPI parent = underlyingNode.getParent();
+ NodeSPI parent = underlyingNode.getParentDirect();
if (parent == null)
{
throw new CacheException("Underlying node " + underlyingNode + " has no parent");
@@ -267,7 +267,7 @@
private void validateNodeAndParents(NodeSPI node)
{
node.setValid(true, false);
- if (!node.getFqn().isRoot()) validateNodeAndParents(node.getParent());
+ if (!node.getFqn().isRoot()) validateNodeAndParents(node.getParentDirect());
}
private void performVersionUpdate(NodeSPI underlyingNode, WorkspaceNode workspaceNode)
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -237,6 +237,11 @@
return spi.getNode(f.getParent());
}
+ public NodeSPI<K, V> getParentDirect()
+ {
+ return node.getParent();
+ }
+
public Set<Node<K, V>> getChildren()
{
assertValid();
Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -7,8 +7,8 @@
import org.jboss.cache.NodeSPI;
import static org.jboss.cache.lock.LockType.READ;
import static org.jboss.cache.lock.LockType.WRITE;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
@@ -65,10 +65,10 @@
assertFalse(lockManager.isLocked(n, READ));
assertTrue(lockManager.isLocked(n, WRITE));
- assertTrue(lockManager.isLocked(n.getParent(), READ));
- assertFalse(lockManager.isLocked(n.getParent(), WRITE));
- assertTrue(lockManager.isLocked(n.getParent().getParent(), READ));
- assertFalse(lockManager.isLocked(n.getParent().getParent(), WRITE));
+ assertTrue(lockManager.isLocked(n.getParentDirect(), READ));
+ assertFalse(lockManager.isLocked(n.getParentDirect(), WRITE));
+ assertTrue(lockManager.isLocked(n.getParentDirect().getParentDirect(), READ));
+ assertFalse(lockManager.isLocked(n.getParentDirect().getParentDirect(), WRITE));
tm.commit();
@@ -87,10 +87,10 @@
assertTrue(lockManager.isLocked(n, READ));
assertFalse(lockManager.isLocked(n, WRITE));
- assertTrue(lockManager.isLocked(n.getParent(), READ));
- assertFalse(lockManager.isLocked(n.getParent(), WRITE));
- assertTrue(lockManager.isLocked(n.getParent().getParent(), READ));
- assertFalse(lockManager.isLocked(n.getParent().getParent(), WRITE));
+ assertTrue(lockManager.isLocked(n.getParentDirect(), READ));
+ assertFalse(lockManager.isLocked(n.getParentDirect(), WRITE));
+ assertTrue(lockManager.isLocked(n.getParentDirect().getParentDirect(), READ));
+ assertFalse(lockManager.isLocked(n.getParentDirect().getParentDirect(), WRITE));
tm.commit();
@@ -109,10 +109,10 @@
assertFalse(lockManager.isLocked(n, READ));
assertTrue(lockManager.isLocked(n, WRITE));
- assertTrue(lockManager.isLocked(n.getParent(), READ));
- assertFalse(lockManager.isLocked(n.getParent(), WRITE));
- assertTrue(lockManager.isLocked(n.getParent().getParent(), READ));
- assertFalse(lockManager.isLocked(n.getParent().getParent(), WRITE));
+ assertTrue(lockManager.isLocked(n.getParentDirect(), READ));
+ assertFalse(lockManager.isLocked(n.getParentDirect(), WRITE));
+ assertTrue(lockManager.isLocked(n.getParentDirect().getParentDirect(), READ));
+ assertFalse(lockManager.isLocked(n.getParentDirect().getParentDirect(), WRITE));
tm.commit();
Modified: core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java 2008-07-02 12:01:41 UTC (rev 6152)
+++ core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java 2008-07-02 13:39:16 UTC (rev 6153)
@@ -254,11 +254,16 @@
throw new UnsupportedOperationException();
}
- public NodeSPI getParent()
+ public NodeSPI getParentDirect()
{
return parent;
}
+ public Node getParent()
+ {
+ return parent;
+ }
+
public boolean hasChildrenDirect()
{
return !children.isEmpty();
16 years, 6 months
JBoss Cache SVN: r6152 - in core/tags/2.2.0.CR6: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-02 08:01:41 -0400 (Wed, 02 Jul 2008)
New Revision: 6152
Modified:
core/tags/2.2.0.CR6/pom.xml
core/tags/2.2.0.CR6/src/main/java/org/jboss/cache/Version.java
Log:
Release CR6
Modified: core/tags/2.2.0.CR6/pom.xml
===================================================================
--- core/tags/2.2.0.CR6/pom.xml 2008-07-02 11:55:04 UTC (rev 6151)
+++ core/tags/2.2.0.CR6/pom.xml 2008-07-02 12:01:41 UTC (rev 6152)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.2.0-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>2.2.0.CR6</jbosscache-core-version>
<!-- By default only run tests in the "unit" group -->
<defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
@@ -410,7 +410,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.2.0-SNAPSHOT-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>2.2.0.CR6-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
Modified: core/tags/2.2.0.CR6/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/tags/2.2.0.CR6/src/main/java/org/jboss/cache/Version.java 2008-07-02 11:55:04 UTC (rev 6151)
+++ core/tags/2.2.0.CR6/src/main/java/org/jboss/cache/Version.java 2008-07-02 12:01:41 UTC (rev 6152)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.2.0-SNAPSHOT";
+ public static final String version = "2.2.0.CR6";
public static final String codename = "Poblano";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '2', '0', 'S'};
+ static final byte[] version_id = {'0', '2', '2', '0', 'C', '6'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 6 months
JBoss Cache SVN: r6151 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-02 07:55:04 -0400 (Wed, 02 Jul 2008)
New Revision: 6151
Added:
core/tags/2.2.0.CR6/
Log:
Copied: core/tags/2.2.0.CR6 (from rev 6150, core/branches/2.2.X)
16 years, 6 months
JBoss Cache SVN: r6150 - searchable/trunk/src/main/java/org/jboss/cache/search.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-07-02 07:06:43 -0400 (Wed, 02 Jul 2008)
New Revision: 6150
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
Log:
Edit to CacheQueryImpl constructor and NPE
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-02 10:54:19 UTC (rev 6149)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-02 11:06:43 UTC (rev 6150)
@@ -258,7 +258,6 @@
for (int index = first; index <= max; index++)
{
String documentId = (String) extractor.extract(hits, index).id;
- if (documentId == null) throw new NullPointerException("The document id extracted is null");
CacheEntityId id = new CacheEntityId(documentId);
ids.add(id);
}
16 years, 6 months
JBoss Cache SVN: r6149 - in searchable/trunk: src/test/java/org/jboss/cache/search and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-02 06:54:19 -0400 (Wed, 02 Jul 2008)
New Revision: 6149
Modified:
searchable/trunk/pom.xml
searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/TransformerTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/ClusteredCacheTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
Log:
TestNG test grouping
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2008-07-02 10:52:43 UTC (rev 6148)
+++ searchable/trunk/pom.xml 2008-07-02 10:54:19 UTC (rev 6149)
@@ -5,8 +5,6 @@
<modelVersion>4.0.0</modelVersion>
<properties>
<jbosscache-searchable-version>0.1-SNAPSHOT</jbosscache-searchable-version>
- <!-- By default only run tests in the "unit" group -->
- <defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
<javadocPhase>install</javadocPhase>
</properties>
@@ -48,18 +46,18 @@
<version>1.0.4</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
- <groupId>org.hibernate.apache.lucene.solr</groupId>
- <artifactId>apache-solr-analyzer</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
+ <groupId>org.hibernate.apache.lucene.solr</groupId>
+ <artifactId>apache-solr-analyzer</artifactId>
+ <version>1.2.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java 2008-07-02 10:52:43 UTC (rev 6148)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java 2008-07-02 10:54:19 UTC (rev 6149)
@@ -16,7 +16,7 @@
* Test class for the QueryResultIteratorImpl
*/
-@Test
+@Test(groups = "functional")
public class QueryResultIteratorImplTest
{
List<CacheEntityId> ids;
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/TransformerTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/TransformerTest.java 2008-07-02 10:52:43 UTC (rev 6148)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/TransformerTest.java 2008-07-02 10:54:19 UTC (rev 6149)
@@ -4,18 +4,17 @@
import org.testng.annotations.Test;
/**
-@author Navin Surtani - navin(a)surtani.org
-
- Unit-test class for the Transformer class.
+ * @author Navin Surtani - navin(a)surtani.org
+ * <p/>
+ * Unit-test class for the Transformer class.
*/
-@Test
+@Test(groups = "functional")
public class TransformerTest
{
/**
* Tests the generateId method.
- *
*/
public void testGenerateId()
@@ -28,12 +27,11 @@
assert generatedId.contentEquals("Fqn=[/a/b/c]Key=[key]");
- assert ! generatedId.contentEquals("/ab/c/d");
+ assert !generatedId.contentEquals("/ab/c/d");
}
/**
* Tests the getFqn method.
- *
*/
public void testGetFqn()
{
@@ -58,53 +56,53 @@
assert key.contentEquals("thisIsMyKey");
- assert ! key.contentEquals("thisIsNotMyKey");
+ assert !key.contentEquals("thisIsNotMyKey");
}
- @Test (expectedExceptions = NullPointerException.class)
+ @Test(expectedExceptions = NullPointerException.class)
public void testGetKeyWithNull()
{
Transformer.getKey(null);
}
- @Test (expectedExceptions = InvalidFqnException.class)
+ @Test(expectedExceptions = InvalidFqnException.class)
public void testGenerateIdWithHackedString()
{
Transformer.generateId(Fqn.fromString("/Fqn=[/a/b/c"), "x");
}
- @Test (expectedExceptions = InvalidFqnException.class)
+ @Test(expectedExceptions = InvalidFqnException.class)
public void testGenerateIdWithHackedFqn()
{
Transformer.generateId(Fqn.fromString("/Fqn=[/a/b/c"), "x");
}
- @Test (expectedExceptions = InvalidFqnException.class)
+ @Test(expectedExceptions = InvalidFqnException.class)
public void testGenerateIdWithHackedFqn2()
{
Transformer.generateId(Fqn.fromString("/]Key=[/a/b/c"), "x");
}
- @Test (expectedExceptions = InvalidFqnException.class)
+ @Test(expectedExceptions = InvalidFqnException.class)
public void testGenerateIdWithHackedKey()
{
Transformer.generateId(Fqn.fromString("/a/b/c"), "]Key=[");
}
- @Test (expectedExceptions = InvalidFqnException.class)
+ @Test(expectedExceptions = InvalidFqnException.class)
public void testGenerateIdWithHackedKey2()
{
Transformer.generateId(Fqn.fromString("/a/b/c"), "Fqn=[");
}
- @Test (expectedExceptions = InvalidFqnException.class)
+ @Test(expectedExceptions = InvalidFqnException.class)
public void testGenerateIdWithNullKey()
{
Transformer.generateId(Fqn.fromString("/a/b/c"), null);
}
- @Test (expectedExceptions = InvalidFqnException.class)
+ @Test(expectedExceptions = InvalidFqnException.class)
public void testGenerateIdWithNullFqn()
{
Transformer.generateId(null, "x");
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/ClusteredCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/ClusteredCacheTest.java 2008-07-02 10:52:43 UTC (rev 6148)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/ClusteredCacheTest.java 2008-07-02 10:54:19 UTC (rev 6149)
@@ -1,27 +1,26 @@
package org.jboss.cache.search.blackbox;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.search.SearchableCache;
import org.jboss.cache.search.CacheQuery;
+import org.jboss.cache.search.SearchableCache;
import org.jboss.cache.search.SearchableCacheFactory;
import org.jboss.cache.search.test.Person;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-
import java.util.List;
/**
* @author Navin Surtani - navin(a)surtani.org
*/
-@Test
+@Test(groups = "functional")
public class ClusteredCacheTest
{
Cache cache1, cache2;
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-07-02 10:52:43 UTC (rev 6148)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-07-02 10:54:19 UTC (rev 6149)
@@ -1,29 +1,28 @@
package org.jboss.cache.search.blackbox;
-import org.jboss.cache.search.SearchableCache;
-import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.search.CacheQuery;
-import org.jboss.cache.search.QueryResultIterator;
-import org.jboss.cache.search.test.Person;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.testng.annotations.BeforeMethod;
+import org.jboss.cache.search.CacheQuery;
+import org.jboss.cache.search.QueryResultIterator;
+import org.jboss.cache.search.SearchableCache;
+import org.jboss.cache.search.SearchableCacheFactory;
+import org.jboss.cache.search.test.Person;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.search.Query;
import java.util.List;
-import java.util.Iterator;
/**
* @author Navin Surtani - navin(a)surtani.org
*/
-@Test
+@Test(groups = "functional")
public class LocalCacheTest
{
SearchableCache searchableCache;
@@ -92,7 +91,6 @@
}
-
public void testMultipleResults() throws ParseException
{
queryParser = new QueryParser("name", new StandardAnalyzer());
@@ -139,7 +137,7 @@
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
- assert found.size() == 2: "Size of list should be 2";
+ assert found.size() == 2 : "Size of list should be 2";
assert found.contains(person2);
assert found.contains(person3);
assert !found.contains(person4) : "This should not contain object person4";
@@ -153,7 +151,7 @@
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
- assert found.size() == 3: "Size of list should be 3";
+ assert found.size() == 3 : "Size of list should be 3";
assert found.contains(person2);
assert found.contains(person3);
assert found.contains(person4) : "This should now contain object person4";
@@ -169,7 +167,7 @@
assert found.size() == 2;
assert found.contains(person2);
- assert found.contains(person3): "This should still contain object person3";
+ assert found.contains(person3) : "This should still contain object person3";
searchableCache.remove(Fqn.fromString("/a/b/c/"), person3);
@@ -179,7 +177,7 @@
assert found.size() == 1;
assert found.contains(person2);
- assert !found.contains(person3): "The search should not return person3";
+ assert !found.contains(person3) : "The search should not return person3";
}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2008-07-02 10:52:43 UTC (rev 6148)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2008-07-02 10:54:19 UTC (rev 6149)
@@ -1,33 +1,34 @@
package org.jboss.cache.search.blackbox;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.AfterMethod;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheFactory;
+import org.jboss.cache.search.CacheQuery;
import org.jboss.cache.search.SearchableCache;
-import org.jboss.cache.search.CacheQuery;
import org.jboss.cache.search.SearchableCacheFactory;
import org.jboss.cache.search.test.Person;
-import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import java.util.List;
/**
* Same as LocalCacheTest except that you will use a POJO Cache instead and use pojoCache.attach() ad pojoCache.detach()
* instead of cache.put() and cache.remove().
- * <p />
+ * <p/>
+ *
* @author Navin Surtani - navin(a)surtani.org
*/
-@Test
+@Test(groups = "functional")
public class LocalPOJOCacheTest
{
SearchableCache searchableCache;
@@ -73,8 +74,8 @@
public void tearDown()
{
- if(pojo != null) pojo.stop();
- if(searchableCache != null) searchableCache.stop();
+ if (pojo != null) pojo.stop();
+ if (searchableCache != null) searchableCache.stop();
}
public void testSimple() throws ParseException
@@ -132,7 +133,7 @@
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
- assert found.size() == 2: "Size of list should be 2";
+ assert found.size() == 2 : "Size of list should be 2";
assert found.contains(person2);
assert found.contains(person3);
assert !found.contains(person4) : "This should not contain object person4";
@@ -146,7 +147,7 @@
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
- assert found.size() == 3: "Size of list should be 3";
+ assert found.size() == 3 : "Size of list should be 3";
assert found.contains(person2);
assert found.contains(person3);
assert found.contains(person4) : "This should now contain object person4";
@@ -160,7 +161,7 @@
assert found.size() == 2;
assert found.contains(person2);
- assert found.contains(person3): "This should still contain object person3";
+ assert found.contains(person3) : "This should still contain object person3";
pojo.detach(Fqn.fromString("/a/b/c/"));
@@ -170,7 +171,7 @@
assert found.size() == 1;
assert found.contains(person2);
- assert !found.contains(person3): "The search should not return person3";
+ assert !found.contains(person3) : "The search should not return person3";
}
16 years, 6 months