JBoss Cache SVN: r6177 - searchable/trunk/src/test/java/org/jboss/cache/search/blackbox.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-07-04 06:09:25 -0400 (Fri, 04 Jul 2008)
New Revision: 6177
Modified:
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
Log:
Disabled LocalPOJOTest
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-04 10:02:08 UTC (rev 6176)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2008-07-04 10:09:25 UTC (rev 6177)
@@ -1,202 +1,202 @@
-//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.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
-//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.SearchableCacheFactory;
-//import org.jboss.cache.search.helper.IndexCleanUp;
-//import org.jboss.cache.search.test.Person;
-//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/>
-// *
-// * @author Navin Surtani - navin(a)surtani.org
-// */
-//
-//@Test(groups = "functional")
-//public class LocalPOJOCacheTest
-//{
-// SearchableCache searchableCache;
-// PojoCache pojo;
-// Person person1;
-// Person person2;
-// Person person3;
-// Person person4;
-// QueryParser queryParser;
-// Query luceneQuery;
-// CacheQuery cacheQuery;
-// List found;
-// private static final Log log = LogFactory.getLog(LocalPOJOCacheTest.class);
-//
-//
-// @BeforeMethod
-// public void setUp()
-// {
-// boolean toStart = false;
-// pojo = PojoCacheFactory.createCache(new Configuration(), toStart);
-// pojo.start(); // if toStart above is true, it will starts the cache automatically.
-// searchableCache = new SearchableCacheFactory().createSearchableCache(pojo.getCache(), Person.class);
-//
-// person1 = new Person();
-// person1.setName("Navin Surtani");
-// person1.setBlurb("Likes playing WoW");
-//
-// person2 = new Person();
-// person2.setName("BigGoat");
-// person2.setBlurb("Eats grass");
-//
-// person3 = new Person();
-// person3.setName("MiniGoat");
-// person3.setBlurb("Eats cheese");
-//
-// pojo.attach(Fqn.fromString("/a/b/c"), person1);
-// pojo.attach(Fqn.fromString("/a/b/d"), person2);
-// pojo.attach(Fqn.fromString("/a/b/c"), person3);
-//
-//
-// }
-//
-// @AfterMethod
-// public void tearDown()
-// {
-// if (pojo != null) pojo.stop();
-// if (searchableCache != null) searchableCache.stop();
-// IndexCleanUp.cleanUpIndexes();
-// }
-//
-// public void testSimple() throws ParseException
-// {
-// queryParser = new QueryParser("blurb", new StandardAnalyzer());
-// luceneQuery = queryParser.parse("playing");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-//
-// found = cacheQuery.list();
-//
-// assert found.size() == 1;
-//
-// if (found.get(0) == null)
-// {
-// if (log.isTraceEnabled()) log.warn("found.get(0) is null");
-//
-// }
-//
-// if (person1 == null)
-// {
-// if (log.isTraceEnabled()) log.warn("person1 is null");
-// }
-//
-// // assert person1.equals(found.get(0));
-// }
-//
-// public void testMultipleResults() throws ParseException
-// {
-// queryParser = new QueryParser("blurb", new StandardAnalyzer());
-// luceneQuery = queryParser.parse("Eats");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-// found = cacheQuery.list();
-//
-// assert found.size() == 2;
-// assert !found.get(1).equals(person2);
-// assert !found.get(0).equals(person3);
-//
-// }
-//
-// public void testModified() throws ParseException
-// {
-// queryParser = new QueryParser("blurb", new StandardAnalyzer());
-// luceneQuery = queryParser.parse("playing");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-//
-// found = cacheQuery.list();
-//
-// assert found.size() == 1;
-//// assert found.get(0).equals(person1);
-//
-// person1.setBlurb("Likes pizza");
-//
-// pojo.attach(Fqn.fromString("/a/b/c/"), person1);
-//
-// queryParser = new QueryParser("blurb", new StandardAnalyzer());
-// luceneQuery = queryParser.parse("pizza");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-//
-// found = cacheQuery.list();
-//
-// assert found.size() == 1;
-//// assert found.get(0).equals(person1);
-// }
-//
-// public void testAdded() throws ParseException
-// {
-// queryParser = new QueryParser("blurb", new StandardAnalyzer());
-// luceneQuery = queryParser.parse("eats");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-// found = cacheQuery.list();
-//
-// 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";
-//
-// person4 = new Person();
-// person4.setName("MightyGoat");
-// person4.setBlurb("Also eats grass");
-//
-// pojo.attach(Fqn.fromString("/r/a/m/"), person4);
-//
-// luceneQuery = queryParser.parse("eats");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-// found = cacheQuery.list();
-//
-// 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";
-// }
-//
-// public void testRemoved() throws ParseException
-// {
-// queryParser = new QueryParser("blurb", new StandardAnalyzer());
-// luceneQuery = queryParser.parse("eats");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-// found = cacheQuery.list();
-//
-// assert found.size() == 2;
-// assert found.contains(person2);
-// assert found.contains(person3) : "This should still contain object person3";
-//
-// pojo.detach("/a/b/d");
-//
-// luceneQuery = queryParser.parse("eats");
-// cacheQuery = searchableCache.createQuery(luceneQuery);
-// found = cacheQuery.list();
-//
-// assert found.size() == 1;
-// assert found.contains(person2);
-// assert !found.contains(person3) : "The search should not return person3";
-//
-//
-// }
-//
-//}
-//
-//
-//
+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.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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.SearchableCacheFactory;
+import org.jboss.cache.search.helper.IndexCleanUp;
+import org.jboss.cache.search.test.Person;
+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/>
+ *
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+
+@Test(groups = "functional", enabled = false)
+public class LocalPOJOCacheTest
+{
+ SearchableCache searchableCache;
+ PojoCache pojo;
+ Person person1;
+ Person person2;
+ Person person3;
+ Person person4;
+ QueryParser queryParser;
+ Query luceneQuery;
+ CacheQuery cacheQuery;
+ List found;
+ private static final Log log = LogFactory.getLog(LocalPOJOCacheTest.class);
+
+
+ @BeforeMethod
+ public void setUp()
+ {
+ boolean toStart = false;
+ pojo = PojoCacheFactory.createCache(new Configuration(), toStart);
+ pojo.start(); // if toStart above is true, it will starts the cache automatically.
+ searchableCache = new SearchableCacheFactory().createSearchableCache(pojo.getCache(), Person.class);
+
+ person1 = new Person();
+ person1.setName("Navin Surtani");
+ person1.setBlurb("Likes playing WoW");
+
+ person2 = new Person();
+ person2.setName("BigGoat");
+ person2.setBlurb("Eats grass");
+
+ person3 = new Person();
+ person3.setName("MiniGoat");
+ person3.setBlurb("Eats cheese");
+
+ pojo.attach(Fqn.fromString("/a/b/c"), person1);
+ pojo.attach(Fqn.fromString("/a/b/d"), person2);
+ pojo.attach(Fqn.fromString("/a/b/c"), person3);
+
+
+ }
+
+ @AfterMethod
+ public void tearDown()
+ {
+ if (pojo != null) pojo.stop();
+ if (searchableCache != null) searchableCache.stop();
+ IndexCleanUp.cleanUpIndexes();
+ }
+
+ public void testSimple() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("playing");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+
+ if (found.get(0) == null)
+ {
+ if (log.isTraceEnabled()) log.warn("found.get(0) is null");
+
+ }
+
+ if (person1 == null)
+ {
+ if (log.isTraceEnabled()) log.warn("person1 is null");
+ }
+
+ // assert person1.equals(found.get(0));
+ }
+
+ public void testMultipleResults() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("Eats");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+ assert !found.get(1).equals(person2);
+ assert !found.get(0).equals(person3);
+
+ }
+
+ public void testModified() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("playing");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+// assert found.get(0).equals(person1);
+
+ person1.setBlurb("Likes pizza");
+
+ pojo.attach(Fqn.fromString("/a/b/c/"), person1);
+
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("pizza");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+// assert found.get(0).equals(person1);
+ }
+
+ public void testAdded() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("eats");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ 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";
+
+ person4 = new Person();
+ person4.setName("MightyGoat");
+ person4.setBlurb("Also eats grass");
+
+ pojo.attach(Fqn.fromString("/r/a/m/"), person4);
+
+ luceneQuery = queryParser.parse("eats");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ 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";
+ }
+
+ public void testRemoved() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("eats");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+ assert found.contains(person2);
+ assert found.contains(person3) : "This should still contain object person3";
+
+ pojo.detach("/a/b/d");
+
+ luceneQuery = queryParser.parse("eats");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+ assert found.contains(person2);
+ assert !found.contains(person3) : "The search should not return person3";
+
+
+ }
+
+}
+
+
+
16 years, 6 months
JBoss Cache SVN: r6176 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 06:02:08 -0400 (Fri, 04 Jul 2008)
New Revision: 6176
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
Log:
Prevent lock suppression
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-04 09:57:55 UTC (rev 6175)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-04 10:02:08 UTC (rev 6176)
@@ -73,6 +73,14 @@
}
@Override
+ protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
+ {
+ if (ctx.getOptionOverrides().isSuppressLocking())
+ throw new CacheException("Lock suppression not supported with MVCC!");
+ return true;
+ }
+
+ @Override
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
getWrappedNode(ctx, command.getFqn(), true, true, false); // get the node and stick it in the context.
16 years, 6 months
JBoss Cache SVN: r6175 - in core/trunk/src/main/java/org/jboss/cache/interceptors: base and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 05:57:55 -0400 (Fri, 04 Jul 2008)
New Revision: 6175
Added:
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
Removed:
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
Log:
Added support for preprocessing intercepted commands
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-04 09:39:44 UTC (rev 6174)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-04 09:57:55 UTC (rev 6175)
@@ -27,7 +27,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor;
+import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.lock.LockManager;
@@ -49,7 +49,7 @@
* @see <a href="http://wiki.jboss.org/wiki/JBossCacheMVCC">MVCC designs</a>
* @since 3.0
*/
-public class MVCCLockingInterceptor extends PostProcessingCommandInterceptor
+public class MVCCLockingInterceptor extends PrePostProcessingCommandInterceptor
{
boolean allowWriteSkew;
LockManager lockManager;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-07-04 09:39:44 UTC (rev 6174)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-07-04 09:57:55 UTC (rev 6175)
@@ -30,7 +30,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor;
+import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
@@ -64,7 +64,7 @@
* @author Bela Ban
* @version $Id$
*/
-public class PessimisticLockInterceptor extends PostProcessingCommandInterceptor
+public class PessimisticLockInterceptor extends PrePostProcessingCommandInterceptor
{
private DataContainer dataContainer;
private PessimisticNodeBasedLockManager lockManager;
Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java 2008-07-04 09:39:44 UTC (rev 6174)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java 2008-07-04 09:57:55 UTC (rev 6175)
@@ -1,421 +0,0 @@
-package org.jboss.cache.interceptors.base;
-
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.*;
-import org.jboss.cache.invocation.InvocationContext;
-
-/**
- * This interceptor will call {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} after invoking each visit method
- * (and the {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)} method) in
- * a <tt>finally</tt> block.
- * <p/>
- * It is useful if common cleanup code is required at the end of each call.
- * <p/>
- * Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
- * instead, as well as the {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public abstract class PostProcessingCommandInterceptor extends CommandInterceptor
-{
- @Override
- public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- try
- {
- return handlePutDataMapCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- try
- {
- return handlePutKeyValueCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- @Override
- public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- try
- {
- return handlePutForExternalReadCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
-
- protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
-
- @Override
- public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- try
- {
- return handleRemoveNodeCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- try
- {
- return handleCreateNodeCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
-
- @Override
- public final Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- try
- {
- return handleClearDataCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
- {
- try
- {
- return handleEvictFqnCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
- {
- try
- {
- return handleInvalidateCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- try
- {
- return handleRemoveKeyCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- try
- {
- return handleGetDataMapCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
- {
- try
- {
- return handleExistsNodeCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- try
- {
- return handleGetKeyValueCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- try
- {
- return handleGetNodeCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- try
- {
- return handleGetKeysCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- try
- {
- return handleGetChildrenNamesCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- try
- {
- return handleMoveCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
- {
- try
- {
- return handleGravitateDataCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
- {
- try
- {
- return handlePrepareCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- try
- {
- return handleRollbackCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- try
- {
- return handleCommitCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- @Override
- public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- try
- {
- return handleOptimisticPrepareCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
-
- protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- /**
- * Callback that is invoked after every handleXXX() method defined above.
- *
- * @param ctx invocation context
- * @param command command which was invoked
- */
- protected abstract void doAfterCall(InvocationContext ctx, VisitableCommand command);
-}
Copied: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java (from rev 6169, core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java 2008-07-04 09:57:55 UTC (rev 6175)
@@ -0,0 +1,437 @@
+package org.jboss.cache.interceptors.base;
+
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.ClearDataCommand;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.EvictCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.invocation.InvocationContext;
+
+/**
+ * This interceptor adds pre and post processing to each <tt>visitXXX()</tt> method.
+ * <p/>
+ * For each <tt>visitXXX()</tt> method invoked, it will first call {@link #doBeforeCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * and if this method returns true, it will proceed to invoking a <tt>handleXXX()</tt> method and lastly, {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * in a <tt>finally</tt> block. Note that the <tt>doAfterCall()</tt> method is still invoked even if <tt>doBeforeCall()</tt> returns <tt>false</tt>.
+ * <p/>
+ * Instead of overriding <tt>visitXXX()</tt> methods, implementations should override their <tt>handleXXX()</tt> counterparts defined in this class
+ * instead, as well as the {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method and
+ * optionally {@link #doBeforeCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
+ * <p/>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public abstract class PrePostProcessingCommandInterceptor extends CommandInterceptor
+{
+ @Override
+ public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handlePutDataMapCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handlePutKeyValueCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ @Override
+ public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handlePutForExternalReadCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+
+ protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+
+ @Override
+ public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleRemoveNodeCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleCreateNodeCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+
+ @Override
+ public final Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleClearDataCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleEvictFqnCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleInvalidateCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleRemoveKeyCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleGetDataMapCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleExistsNodeCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleGetKeyValueCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleGetNodeCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleGetKeysCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleGetChildrenNamesCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleMoveCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleGravitateDataCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handlePrepareCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleRollbackCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleCommitCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+ {
+ try
+ {
+ return doBeforeCall(ctx, command) ? handleOptimisticPrepareCommand(ctx, command) : null;
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ /**
+ * Callback that is invoked after every handleXXX() method defined above.
+ *
+ * @param ctx invocation context
+ * @param command command which was invoked
+ */
+ protected abstract void doAfterCall(InvocationContext ctx, VisitableCommand command);
+
+ protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
+ {
+ return true;
+ }
+}
16 years, 6 months
JBoss Cache SVN: r6174 - core/trunk/src/main/java/org/jboss/cache/util/concurrent.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 05:39:44 -0400 (Fri, 04 Jul 2008)
New Revision: 6174
Modified:
core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java
Log:
Better javadocs, added 1 more ctor
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java 2008-07-04 09:38:16 UTC (rev 6173)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java 2008-07-04 09:39:44 UTC (rev 6174)
@@ -25,13 +25,22 @@
}
/**
- * @param concurrencyLevel passed in to the underlying CHM.
+ * @param concurrencyLevel passed in to the underlying CHM. See {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
*/
public ConcurrentHashSet(int concurrencyLevel)
{
map = new ConcurrentHashMap<E, Object>(16, 0.75f, concurrencyLevel);
}
+ /**
+ * Params passed in to the underlying CHM. See {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
+ */
+ public ConcurrentHashSet(int initSize, float loadFactor, int concurrencyLevel)
+ {
+ map = new ConcurrentHashMap<E, Object>(initSize, loadFactor, concurrencyLevel);
+ }
+
+
@Override
public int size()
{
16 years, 6 months
JBoss Cache SVN: r6173 - in core/branches/2.2.X/src/main/java/org/jboss/cache: util/concurrent and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 05:38:16 -0400 (Fri, 04 Jul 2008)
New Revision: 6173
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/lock/LockMap.java
core/branches/2.2.X/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java
Log:
JBCACHE-1383: ConcurrentHashSet should allow for setting a "concurrency level"
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/lock/LockMap.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/lock/LockMap.java 2008-07-04 08:57:58 UTC (rev 6172)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/lock/LockMap.java 2008-07-04 09:38:16 UTC (rev 6173)
@@ -33,7 +33,7 @@
public LockMap()
{
- this(new ConcurrentHashSet<Object>());
+ this(new ConcurrentHashSet<Object>(4));
}
/**
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java 2008-07-04 08:57:58 UTC (rev 6172)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java 2008-07-04 09:38:16 UTC (rev 6173)
@@ -24,6 +24,22 @@
map = new ConcurrentHashMap<E, Object>();
}
+ /**
+ * @param concurrency concurrency level passed in to the CHM constructor. See {@link ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
+ */
+ public ConcurrentHashSet(int concurrency)
+ {
+ map = new ConcurrentHashMap<E, Object>(16, 0.75f, concurrency);
+ }
+
+ /**
+ * Params passed in to the CHM constructor. See {@link ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
+ */
+ public ConcurrentHashSet(int initSize, float loadFactor, int concurrency)
+ {
+ map = new ConcurrentHashMap<E, Object>(initSize, loadFactor, concurrency);
+ }
+
@Override
public int size()
{
16 years, 6 months
JBoss Cache SVN: r6172 - in core/trunk/src/main/java/org/jboss/cache: util/concurrent and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 04:57:58 -0400 (Fri, 04 Jul 2008)
New Revision: 6172
Modified:
core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java
Log:
Fewer CHM segments for LockMaps
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java 2008-07-04 08:53:09 UTC (rev 6171)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java 2008-07-04 08:57:58 UTC (rev 6172)
@@ -33,7 +33,7 @@
public LockMap()
{
- this(new ConcurrentHashSet<Object>());
+ this(new ConcurrentHashSet<Object>(4));
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java 2008-07-04 08:53:09 UTC (rev 6171)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java 2008-07-04 08:57:58 UTC (rev 6172)
@@ -24,6 +24,14 @@
map = new ConcurrentHashMap<E, Object>();
}
+ /**
+ * @param concurrencyLevel passed in to the underlying CHM.
+ */
+ public ConcurrentHashSet(int concurrencyLevel)
+ {
+ map = new ConcurrentHashMap<E, Object>(16, 0.75f, concurrencyLevel);
+ }
+
@Override
public int size()
{
16 years, 6 months
JBoss Cache SVN: r6171 - in core/trunk/src: test/java/org/jboss/cache/api/mvcc and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 04:53:09 -0400 (Fri, 04 Jul 2008)
New Revision: 6171
Added:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/ForceWriteLockTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
Log:
Preliminary move() + forceWriteLock logic
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-04 08:52:44 UTC (rev 6170)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-04 08:53:09 UTC (rev 6171)
@@ -37,7 +37,6 @@
import org.jboss.cache.mvcc.NullMarkerNode;
import org.jboss.cache.mvcc.ReadCommittedNode;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -52,14 +51,6 @@
*/
public class MVCCLockingInterceptor extends PostProcessingCommandInterceptor
{
- // TODO: Implement me.
-
- // Need to think about how this will behave with 1. LockParentForChildInsertRemove and 2. CacheLoading.
-
- // Need to think further about cached node lookups. Walking the tree sucks ass.
-
- // How will wrapper nodes unwrap?
-
boolean allowWriteSkew;
LockManager lockManager;
DataContainer dataContainer;
@@ -227,8 +218,11 @@
@Override
public Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
{
- // TODO : Handle this properly
- return handleWriteCommand(ctx, command, new ArrayList<Fqn>(1), Collections.singletonList(command.getFqn()));
+ // this should be handled the same as a recursive evict command.
+ ctx.getOptionOverrides().setLockAcquisitionTimeout(0);
+ addNodeAndParentForRemoval(ctx, command.getFqn(), true);
+
+ return invokeNextInterceptor(ctx, command);
}
@Override
@@ -277,11 +271,22 @@
@Override
public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
- // TODO : Handle this properly
- List<Fqn> list = new ArrayList<Fqn>();
- list.add(command.getFqn());
- list.add(command.getTo());
- return handleWriteCommand(ctx, command, new ArrayList<Fqn>(1), list);
+ // nodes we need to get WLs for:
+ // node we are moving FROM (and it's parent and children.) Same as removeNode.
+ List<Fqn> children = addNodeAndParentForRemoval(ctx, command.getFqn(), true);
+
+ // now lock the new parent.
+ getWrappedNode(ctx, command.getTo(), true, true, false);
+
+ // the children list contains all child nodes, including the node itself.
+ // now obtain locks on the new places these children will occupy.
+ for (Fqn f : children)
+ {
+ getWrappedNode(ctx, Fqn.fromRelativeFqn(command.getTo(), f), true, true, true);
+ }
+
+ // now pass up the chain.
+ return invokeNextInterceptor(ctx, command);
}
@Override
@@ -394,11 +399,17 @@
protected Object handleReadCommand(InvocationContext ctx, VisitableCommand command, List<Fqn> fqns) throws Throwable
{
+ boolean forceWriteLock = ctx.getOptionOverrides().isForceWriteLock();
+
// does the node exist in the context?
for (Fqn f : fqns)
{
- if (ctx.lookUpNode(f) == null)
+ if (forceWriteLock)
{
+ getWrappedNode(ctx, f, true, false, false);
+ }
+ else if (ctx.lookUpNode(f) == null)
+ {
// simple implementation. Peek the node, wrap it, put wrapped node in the context.
InternalNode node = dataContainer.peekInternalNode(f, false);
NodeSPI wrapped = nodeFactory.createMvccNode(node);
@@ -408,41 +419,6 @@
return invokeNextInterceptor(ctx, command);
}
- // TODO : this method is probably unnecessary
- protected Object handleWriteCommand(InvocationContext ctx, VisitableCommand command, List<Fqn> fqnsToRead, List<Fqn> fqnsToWrite) throws Throwable
- {
- for (Fqn f : fqnsToRead)
- {
- if (ctx.lookUpNode(f) == null)
- {
- // simple implementation. Peek the node, wrap it, put wrapped node in the context.
- InternalNode node = dataContainer.peekInternalNode(f, false);
- if (node != null)
- {
- NodeSPI wrapped = nodeFactory.createMvccNode(node);
- ctx.putLookedUpNode(f, wrapped);
- }
- }
- }
-
- for (Fqn f : fqnsToWrite)
- {
- if (ctx.lookUpNode(f) == null)
- {
- // simple implementation. Peek the node, wrap it, put wrapped node in the context.
- InternalNode node = dataContainer.peekInternalNode(f, false);
- if (node != null)
- {
- lock(ctx, f);
- NodeSPI wrapped = nodeFactory.createMvccNode(node);
- ctx.putLookedUpNode(f, wrapped);
- }
- }
- }
-
- return invokeNextInterceptor(ctx, command);
- }
-
/**
* First checks in contexts for the existence of the node. If it does exist, it will return it, acquiring a lock if
* necessary. Otherwise, it will peek in the dataContainer, wrap the node, lock if necessary, and add it to the context.
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/ForceWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/ForceWriteLockTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/ForceWriteLockTest.java 2008-07-04 08:53:09 UTC (rev 6171)
@@ -0,0 +1,38 @@
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.LockManager;
+import org.jboss.cache.lock.LockType;
+import org.jboss.cache.util.TestingUtil;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class ForceWriteLockTest extends org.jboss.cache.options.ForceWriteLockTest
+{
+ public ForceWriteLockTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void assertNotLocked(Fqn fqn)
+ {
+ assert !TestingUtil.extractLockManager(cache).isLocked(cache.peek(fqn, true)) : "Node " + fqn + " is locked!!";
+ }
+
+ @Override
+ protected void assertLocked(Object owner, Fqn fqn, boolean write_locked)
+ {
+ if (write_locked)
+ {
+ LockManager lm = TestingUtil.extractLockManager(cache);
+ NodeSPI<String, String> n = cache.peek(fqn, true);
+ if (owner == null) owner = Thread.currentThread();
+ assertTrue("node " + fqn + " is not locked", lm.isLocked(n));
+ assertTrue("node " + fqn + " is not write-locked by owner " + owner, lm.ownsLock(fqn, LockType.WRITE, owner));
+ }
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveMvccTest.java 2008-07-04 08:52:44 UTC (rev 6170)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveMvccTest.java 2008-07-04 08:53:09 UTC (rev 6171)
@@ -43,7 +43,7 @@
LockAssert.assertLocked(Fqn.ROOT, lm, icc);
LockAssert.assertLocked(C, lm, icc);
LockAssert.assertLocked(Fqn.fromRelativeFqn(A, B), lm, icc);
- LockAssert.assertLocked(Fqn.fromRelativeFqn(B, C), lm, icc);
+ LockAssert.assertLocked(Fqn.fromRelativeFqn(Fqn.fromRelativeFqn(A, B), C), lm, icc);
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java 2008-07-04 08:52:44 UTC (rev 6170)
+++ core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java 2008-07-04 08:53:09 UTC (rev 6171)
@@ -27,16 +27,17 @@
@Test(groups = {"functional", "pessimistic"})
public class ForceWriteLockTest
{
- private CacheSPI<String, String> cache;
+ protected CacheSPI<String, String> cache;
private Fqn fqn = Fqn.fromString("/a/b");
private TransactionManager tm;
+ protected NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
@BeforeMethod(alwaysRun = true)
public void setUp()
{
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- c.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ c.setNodeLockingScheme(nodeLockingScheme);
CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(c);
tm = cache.getTransactionManager();
@@ -45,15 +46,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- try
- {
- tm.rollback();
- }
- catch (Exception e)
- {
- // ignore
- }
- cache.stop();
+ TestingUtil.killCaches(cache);
}
public void testControl() throws Exception
@@ -116,12 +109,12 @@
testControl();
}
- private void assertNotLocked(Fqn fqn)
+ protected void assertNotLocked(Fqn fqn)
{
assert !TestingUtil.extractLockManager(cache).isLocked(cache.peek(fqn, true)) : "Node " + fqn + " is locked!!";
}
- private void assertLocked(Object owner, Fqn fqn, boolean write_locked)
+ protected void assertLocked(Object owner, Fqn fqn, boolean write_locked)
{
LockManager lm = TestingUtil.extractLockManager(cache);
NodeSPI<String, String> n = cache.peek(fqn, true);
@@ -136,5 +129,4 @@
assertTrue("node " + fqn + " is not read-locked by owner " + owner, lm.ownsLock(fqn, LockType.READ, owner));
}
}
-
}
16 years, 6 months
JBoss Cache SVN: r6170 - core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 04:52:44 -0400 (Fri, 04 Jul 2008)
New Revision: 6170
Modified:
core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java
Log:
Added more info in exception
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java 2008-07-03 20:25:29 UTC (rev 6169)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java 2008-07-04 08:52:44 UTC (rev 6170)
@@ -113,7 +113,7 @@
{
int c = getState() - releases;
if (!currentRequestor().equals(owner))
- throw new IllegalMonitorStateException();
+ throw new IllegalMonitorStateException(this.toString());
boolean free = false;
if (c == 0)
{
16 years, 6 months
JBoss Cache SVN: r6169 - in core/trunk/src/test/java/org/jboss/cache: api/mvcc/repeatable_read and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-03 16:25:29 -0400 (Thu, 03 Jul 2008)
New Revision: 6169
Added:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferTest.java
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
Log:
Added more MVCC tests
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,18 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.loader.DummyInMemoryCacheLoaderTest;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class CacheLoaderTest extends DummyInMemoryCacheLoaderTest
+{
+ @Override
+ protected void configureCache() throws Exception
+ {
+ super.configureCache();
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.passivation.PassivationTestsBase;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class PassivationTest extends PassivationTestsBase
+{
+ @Override
+ protected void configureCache() throws Exception
+ {
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "", false, true, false);
+ clc.setPassivation(true);
+ cache.getConfiguration().setCacheLoaderConfig(clc);
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferConcurrencyTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferConcurrencyTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,17 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class StateTransferConcurrencyTest extends org.jboss.cache.statetransfer.StateTransferConcurrencyTest
+{
+ @Override
+ protected void additionalConfiguration(Configuration c)
+ {
+ c.setNodeLockingScheme(NodeLockingScheme.MVCC);
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/StateTransferTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,18 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.statetransfer.StateTransfer200Test;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class StateTransferTest extends StateTransfer200Test
+{
+ @Override
+ protected void additionalConfiguration(Configuration c)
+ {
+ c.setNodeLockingScheme(NodeLockingScheme.MVCC);
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,18 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.loader.DummyInMemoryCacheLoaderTest;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class CacheLoaderTest extends DummyInMemoryCacheLoaderTest
+{
+ @Override
+ protected void configureCache() throws Exception
+ {
+ super.configureCache();
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.passivation.PassivationTestsBase;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class PassivationTest extends PassivationTestsBase
+{
+ @Override
+ protected void configureCache() throws Exception
+ {
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "", false, true, false);
+ clc.setPassivation(true);
+ cache.getConfiguration().setCacheLoaderConfig(clc);
+ }
+}
\ No newline at end of file
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferConcurrencyTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferConcurrencyTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,17 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class StateTransferConcurrencyTest extends org.jboss.cache.statetransfer.StateTransferConcurrencyTest
+{
+ @Override
+ protected void additionalConfiguration(Configuration c)
+ {
+ c.setNodeLockingScheme(NodeLockingScheme.MVCC);
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
\ No newline at end of file
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/StateTransferTest.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -0,0 +1,18 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.statetransfer.StateTransfer200Test;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class StateTransferTest extends StateTransfer200Test
+{
+ @Override
+ protected void additionalConfiguration(Configuration c)
+ {
+ c.setNodeLockingScheme(NodeLockingScheme.MVCC);
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-07-03 20:11:52 UTC (rev 6168)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -45,7 +45,7 @@
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
private static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
- CacheSPI<Object, Object> cache;
+ protected CacheSPI<Object, Object> cache;
CacheLoader loader = null;
static final Fqn<String> FQN = Fqn.fromString("/key");
private static final Fqn SUBTREE_FQN = Fqn.fromRelativeElements(FQN, "subtree");
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-07-03 20:11:52 UTC (rev 6168)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -9,23 +9,19 @@
import org.jboss.cache.Modification;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.DummyTransactionManager;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.util.TestingUtil;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
-import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -44,13 +40,13 @@
* @version $Id$
*/
@Test(groups = "functional")
-abstract public class PassivationTestsBase
+abstract public class PassivationTestsBase extends AbstractCacheLoaderTestBase
{
Log log = LogFactory.getLog(getClass());
//Cache Loader fields
- CacheSPI<Object, Object> cache;
+ protected CacheSPI<Object, Object> cache;
CacheLoader loader = null;
static final Fqn<String> FQN = Fqn.fromString("/key");
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-07-03 20:11:52 UTC (rev 6168)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-07-03 20:25:29 UTC (rev 6169)
@@ -127,6 +127,7 @@
CacheMode mode = sync ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC;
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(mode);
+
if (sync)
{
c.setSyncRollbackPhase(true);
@@ -145,12 +146,9 @@
{
configureCacheLoader(c, cacheLoaderClass, cacheID, cacheLoaderAsync, fetchPersistentState);
}
- // tree.setConfiguration(c);
- //c.setLockAcquisitionTimeout(60000);
- //c.setSyncReplTimeout(60000);
+
+ additionalConfiguration(c);
CacheSPI<Object, Object> tree = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(c, false);
- //c.setLockAcquisitionTimeout(60000); // a whole minute?!?? Lots of state to tfr?
- //c.setSyncReplTimeout(60000);
configureMultiplexer(tree);
// Put the cache in the map before starting, so if it fails in
@@ -166,6 +164,11 @@
return tree;
}
+ protected void additionalConfiguration(Configuration c)
+ {
+ // to be overridden
+ }
+
protected void createAndActivateRegion(CacheSPI<Object, Object> c, Fqn f)
{
Region r = c.getRegion(f, true);
16 years, 6 months
JBoss Cache SVN: r6168 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-03 16:11:52 -0400 (Thu, 03 Jul 2008)
New Revision: 6168
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
Log:
Typo
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-07-03 20:09:26 UTC (rev 6167)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-07-03 20:11:52 UTC (rev 6168)
@@ -46,7 +46,7 @@
" numBuddies = 3\n" +
" </properties>\n" +
" </locator>\n" +
- " </buddyReplication>";
+ " </buddy>";
BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
BuddyManager mgr = new BuddyManager(config);
@@ -80,7 +80,7 @@
" numBuddies = 3\n" +
" </properties>\n" +
" </locator>\n" +
- " </buddyReplication>";
+ " </buddy>";
BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
BuddyManager mgr = new BuddyManager(config);
16 years, 6 months