[infinispan-commits] Infinispan SVN: r2295 - in branches/4.1.x: query/src/main/java/org/infinispan/query/backend and 1 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu Sep 2 05:03:39 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-09-02 05:03:37 -0400 (Thu, 02 Sep 2010)
New Revision: 2295
Added:
branches/4.1.x/query/src/test/java/org/infinispan/query/config/CacheModeTest.java
Modified:
branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
branches/4.1.x/query/src/main/java/org/infinispan/query/backend/QueryHelper.java
Log:
[ISPN-624] (QueryInterceptor injected after LockingInterceptor - hence doesn't work with distributed mode)
Modified: branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2010-09-01 16:59:43 UTC (rev 2294)
+++ branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2010-09-02 09:03:37 UTC (rev 2295)
@@ -156,6 +156,14 @@
return newDefaultCacheManager(configuration, new Configuration(), enforceJmxDomain);
}
+ public static EmbeddedCacheManager createCacheManager(Configuration.CacheMode mode, boolean indexing) {
+ GlobalConfiguration gc = mode.isClustered() ? GlobalConfiguration.getClusteredDefault() : GlobalConfiguration.getNonClusteredDefault();
+ Configuration c = new Configuration();
+ if (indexing) c.setIndexingEnabled(true);
+ c.setCacheMode(mode);
+ return createCacheManager(gc, c);
+ }
+
/**
* Creates a local cache manager and amends so that it won't conflict (e.g. jmx) with other managers whilst running
* tests in parallel. This is a non-transactional cache manager.
Modified: branches/4.1.x/query/src/main/java/org/infinispan/query/backend/QueryHelper.java
===================================================================
--- branches/4.1.x/query/src/main/java/org/infinispan/query/backend/QueryHelper.java 2010-09-01 16:59:43 UTC (rev 2294)
+++ branches/4.1.x/query/src/main/java/org/infinispan/query/backend/QueryHelper.java 2010-09-02 09:03:37 UTC (rev 2295)
@@ -30,6 +30,7 @@
import org.infinispan.config.Configuration;
import org.infinispan.factories.ComponentRegistry;
import org.infinispan.factories.InterceptorChainFactory;
+import org.infinispan.interceptors.DistLockingInterceptor;
import org.infinispan.interceptors.LockingInterceptor;
import org.infinispan.interceptors.base.CommandInterceptor;
import org.infinispan.util.logging.Log;
@@ -129,11 +130,11 @@
try {
if (cfg.isIndexLocalOnly()) {
// Add a LocalQueryInterceptor to the chain
- initComponents(LocalQueryInterceptor.class);
+ initComponents(cfg, LocalQueryInterceptor.class);
} else {
// We're indexing data even if it comes from other sources
// Add in a QueryInterceptor to the chain
- initComponents(QueryInterceptor.class);
+ initComponents(cfg, QueryInterceptor.class);
}
} catch (Exception e) {
throw new CacheException("Unable to add interceptor", e);
@@ -176,7 +177,7 @@
// Private method that adds the interceptor from the classname parameter.
- private void initComponents(Class<? extends QueryInterceptor> interceptorClass)
+ private void initComponents(Configuration cfg, Class<? extends QueryInterceptor> interceptorClass)
throws IllegalAccessException, InstantiationException {
// get the component registry and then register the searchFactory.
@@ -189,8 +190,10 @@
CommandInterceptor inter = icf.createInterceptor(interceptorClass);
cr.registerComponent(inter, QueryInterceptor.class);
- cache.getAdvancedCache().addInterceptorAfter(inter, LockingInterceptor.class);
-
+ cache.getAdvancedCache().addInterceptorAfter(inter,
+ cfg.getCacheMode().isDistributed() ?
+ DistLockingInterceptor.class :
+ LockingInterceptor.class);
}
//This is to check that both the @ProvidedId is present and the the @DocumentId is not present. This is because
Added: branches/4.1.x/query/src/test/java/org/infinispan/query/config/CacheModeTest.java
===================================================================
--- branches/4.1.x/query/src/test/java/org/infinispan/query/config/CacheModeTest.java (rev 0)
+++ branches/4.1.x/query/src/test/java/org/infinispan/query/config/CacheModeTest.java 2010-09-02 09:03:37 UTC (rev 2295)
@@ -0,0 +1,53 @@
+package org.infinispan.query.config;
+
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.interceptors.base.CommandInterceptor;
+import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.query.backend.QueryHelper;
+import org.infinispan.query.backend.QueryInterceptor;
+import org.infinispan.query.test.Person;
+import org.infinispan.test.AbstractInfinispanTest;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+ at Test(groups = "functional", testName = "query.config.CacheModeTest")
+public class CacheModeTest extends AbstractInfinispanTest {
+ public void testLocal() {
+ doTest(Configuration.CacheMode.LOCAL);
+ }
+
+ public void testReplicated() {
+ doTest(Configuration.CacheMode.REPL_SYNC);
+ }
+
+ public void testInvalidated() {
+ doTest(Configuration.CacheMode.INVALIDATION_SYNC);
+ }
+
+ public void testDistributed() {
+ doTest(Configuration.CacheMode.DIST_SYNC);
+ }
+
+ private void doTest(Configuration.CacheMode m) {
+ CacheContainer cc = null;
+
+ try {
+ cc = TestCacheManagerFactory.createCacheManager(m, true);
+ QueryHelper qh = new QueryHelper(cc.getCache(), new Properties(), Person.class);
+ boolean found = false;
+ for (CommandInterceptor i : cc.getCache().getAdvancedCache().getInterceptorChain()) {
+ System.out.println(" Testing " + i.getClass().getSimpleName());
+ if (i instanceof QueryInterceptor) found = true;
+ }
+ assert found : "Didn't find a query interceptor in the chain!!";
+ } finally {
+ TestingUtil.killCacheManagers(cc);
+ }
+ }
+}
More information about the infinispan-commits
mailing list