[infinispan-commits] Infinispan SVN: r1252 - in trunk/lucene-directory/src: main/java/org/infinispan/lucene/locking and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Fri Dec 4 13:37:12 EST 2009


Author: sannegrinovero
Date: 2009-12-04 13:37:11 -0500 (Fri, 04 Dec 2009)
New Revision: 1252

Modified:
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/LuceneLockFactory.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java
Log:
[ISPN-301] (Closing the Lucene Directory will close the cache too)

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java	2009-12-04 17:29:14 UTC (rev 1251)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java	2009-12-04 18:37:11 UTC (rev 1252)
@@ -236,9 +236,6 @@
     */
    public void close() throws IOException {
       isOpen = false;
-      if (cache != null) {
-         cache.stop();
-      }
    }
 
    private void checkIsOpen() throws AlreadyClosedException {

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/LuceneLockFactory.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/LuceneLockFactory.java	2009-12-04 17:29:14 UTC (rev 1251)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/LuceneLockFactory.java	2009-12-04 18:37:11 UTC (rev 1252)
@@ -25,6 +25,7 @@
 import org.apache.lucene.store.LockFactory;
 import org.infinispan.Cache;
 import org.infinispan.CacheException;
+import org.infinispan.lifecycle.ComponentStatus;
 import org.infinispan.lucene.CacheKey;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
@@ -56,9 +57,15 @@
       this.indexName = indexName;
       tm = cache.getAdvancedCache().getComponentRegistry().getComponent(TransactionManager.class);
       if (tm == null) {
-         throw new CacheException(
-                  "Failed looking up TransactionManager, check if any transaction manager is associated with Infinispan cache: "
-                           + cache.getName());
+         ComponentStatus status = cache.getAdvancedCache().getComponentRegistry().getStatus();
+         if (status.equals(ComponentStatus.RUNNING)) {
+            throw new CacheException(
+                     "Failed looking up TransactionManager. Check if any transaction manager is associated with Infinispan cache: \'"
+                              + cache.getName() + "\'");
+         }
+         else {
+            throw new CacheException("Failed looking up TransactionManager: the cache is not running");
+         }
       }
       defLock = new SharedLuceneLock(cache, indexName, DEF_LOCK_NAME, tm);
    }

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java	2009-12-04 17:29:14 UTC (rev 1251)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java	2009-12-04 18:37:11 UTC (rev 1252)
@@ -73,8 +73,19 @@
       assertTextIsFoundInIds(dirB, "node", 1, 0);
       removeByTerm(dirA, "from");
       assertTextIsFoundInIds(dirB, "node", 1);
+      dirA.close();
+      dirB.close();
    }
+   
+   @Test(description="Verifies the caches can be reused after a Directory close")
+   @SuppressWarnings("unchecked")
+   public void testCacheReuse() throws IOException {
+      testIndexWritingAndFinding();
+      cache(0, "lucene").clear();
+      testIndexWritingAndFinding();
+   }
 
+
    /**
     * Used in test to remove all documents containing some term
     * 



More information about the infinispan-commits mailing list