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

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Mon Aug 9 13:20:43 EDT 2010


Author: sannegrinovero
Date: 2010-08-09 13:20:42 -0400 (Mon, 09 Aug 2010)
New Revision: 2176

Removed:
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/CacheKey.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.java
Modified:
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/ChunkCacheKey.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileCacheKey.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileListCacheKey.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileReadLockKey.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexOutput.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/SingleChunkIndexInput.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLockFactory.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLuceneLock.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalLockFactory.java
   trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalSharedLuceneLock.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/DirectoryIntegrityCheck.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryIOTest.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryStressTest.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/IndexReadingStressTest.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/PerformanceCompareStressTest.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/ClusteredCacheFactory.java
Log:
[ISPN-585] (cleanup the Lucene Directory implementation) trunk

Deleted: trunk/lucene-directory/src/main/java/org/infinispan/lucene/CacheKey.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/CacheKey.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/CacheKey.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.infinispan.lucene;
-
-/**
- * Interface for objects used as a key for Infinispan cache.
- * Anything we put in the index store has to be scoped to one index,
- * we tell two indexes apart by giving them unique names, so the keys are
- * scoped to these index names.
- * 
- * @author Sanne Grinovero
- * @since 4.0
- * @see org.infinispan.lucene.InfinispanDirectory#cache
- */
-public interface CacheKey {
-
-   /**
-    * Get the name of the index to which this key is scoped to.
-    * 
-    * @return the indexName
-    */
-   public String getIndexName();
-
-}

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/ChunkCacheKey.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/ChunkCacheKey.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/ChunkCacheKey.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -30,7 +30,7 @@
  * @author Lukasz Moren
  * @author Sanne Grinovero
  */
-final class ChunkCacheKey implements Serializable, CacheKey {
+final class ChunkCacheKey implements Serializable {
 
    /** The serialVersionUID */
    private static final long serialVersionUID = 4429712073623290126L;

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileCacheKey.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileCacheKey.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileCacheKey.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -30,35 +30,20 @@
  * @author Lukasz Moren
  * @author Sanne Grinovero
  */
-public final class FileCacheKey implements Serializable, CacheKey {
+public final class FileCacheKey implements Serializable {
 
    /** The serialVersionUID */
    private static final long serialVersionUID = -228474937509042691L;
    
-   private final boolean isLockKey;
    private final String indexName;
    private final String fileName;
    private final int hashCode;
 
    public FileCacheKey(String indexName, String fileName) {
-      this(indexName, fileName, false);
-   }
-
-   public FileCacheKey(String indexName, String fileName, boolean isLockKey) {
       this.indexName = indexName;
       this.fileName = fileName;
-      this.isLockKey = isLockKey;
       this.hashCode = generatedHashCode();
    }
-   
-   /**
-    * Get the isLockKey.
-    * 
-    * @return the isLockKey.
-    */
-   public boolean isLockKey() {
-      return isLockKey;
-   }
 
    /**
     * Get the indexName.
@@ -88,7 +73,6 @@
       int result = 1;
       result = prime * result + ((fileName == null) ? 0 : fileName.hashCode());
       result = prime * result + ((indexName == null) ? 0 : indexName.hashCode());
-      result = prime * result + (isLockKey ? 1231 : 1237);
       return result;
    }
 
@@ -111,14 +95,12 @@
             return false;
       } else if (!indexName.equals(other.indexName))
          return false;
-      if (isLockKey != other.isLockKey)
-         return false;
       return true;
    }
    
    @Override
    public String toString() {
-      return "FileCacheKey{fileName='" + fileName + "', indexName='" + indexName + "', isLockKey=" + isLockKey + '}';
+      return "FileCacheKey{fileName='" + fileName + "', indexName='" + indexName + '}';
    }
 
 }

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileListCacheKey.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileListCacheKey.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileListCacheKey.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -30,7 +30,7 @@
  * @author Lukasz Moren
  * @author Sanne Grinovero
  */
-final class FileListCacheKey implements Serializable, CacheKey {
+final class FileListCacheKey implements Serializable {
 
    /** The serialVersionUID */
    private static final long serialVersionUID = 8965108175527988255L;

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileReadLockKey.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileReadLockKey.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/FileReadLockKey.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -32,7 +32,7 @@
  * @author Sanne Grinovero
  * @since 4.0
  */
-final class FileReadLockKey implements Serializable, CacheKey {
+final class FileReadLockKey implements Serializable {
 
    /** The serialVersionUID */
    private static final long serialVersionUID = 7789410500198851940L;

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -48,7 +48,6 @@
  * @author Sanne Grinovero
  * @see org.infinispan.lucene.locking.TransactionalLockFactory
  */
-// TODO add support for ConcurrentMergeSheduler
 public class InfinispanDirectory extends Directory {
    
    // used as default chunk size if not provided in conf
@@ -61,7 +60,7 @@
    // access type will be changed in the next Lucene version
    volatile boolean isOpen = true;
 
-   private final AdvancedCache<CacheKey, Object> cache;
+   private final AdvancedCache cache;
    // indexName is required when one common cache is used
    private final String indexName;
    // chunk size used in this directory, static filed not used as we want to have different chunk
@@ -70,7 +69,7 @@
 
    private final FileListCacheKey fileListCacheKey;
 
-   public InfinispanDirectory(Cache<CacheKey, Object> cache, String indexName, LockFactory lf, int chunkSize) {
+   public InfinispanDirectory(Cache cache, String indexName, LockFactory lf, int chunkSize) {
       this.cache = cache.getAdvancedCache();
       this.indexName = indexName;
       this.setLockFactory(lf);
@@ -78,19 +77,19 @@
       this.fileListCacheKey = new FileListCacheKey(indexName);
    }
 
-   public InfinispanDirectory(Cache<CacheKey, Object> cache, String indexName, LockFactory lf) {
+   public InfinispanDirectory(Cache cache, String indexName, LockFactory lf) {
       this(cache, indexName, lf, DEFAULT_BUFFER_SIZE);
    }
 
-   public InfinispanDirectory(Cache<CacheKey, Object> cache, String indexName, int chunkSize) {
+   public InfinispanDirectory(Cache cache, String indexName, int chunkSize) {
       this(cache, indexName, new BaseLockFactory(cache, indexName), chunkSize);
    }
 
-   public InfinispanDirectory(Cache<CacheKey, Object> cache, String indexName) {
+   public InfinispanDirectory(Cache cache, String indexName) {
       this(cache, indexName, new BaseLockFactory(cache, indexName), DEFAULT_BUFFER_SIZE);
    }
 
-   public InfinispanDirectory(Cache<CacheKey, Object> cache) {
+   public InfinispanDirectory(Cache cache) {
       this(cache, "");
    }
 
@@ -129,7 +128,7 @@
     */
    public void touchFile(String fileName) throws IOException {
       checkIsOpen();
-      CacheKey key = new FileCacheKey(indexName, fileName);
+      FileCacheKey key = new FileCacheKey(indexName, fileName);
       FileMetadata file = (FileMetadata) cache.get(key);
       if (file == null) {
          throw new FileNotFoundException(fileName);
@@ -176,7 +175,7 @@
       
       // rename metadata first
       cache.startBatch();
-      CacheKey fromKey = new FileCacheKey(indexName, from);
+      FileCacheKey fromKey = new FileCacheKey(indexName, from);
       FileMetadata metadata = (FileMetadata) cache.remove(fromKey);
       cache.put(new FileCacheKey(indexName, to), metadata);
       Set<String> fileList = getFileList();
@@ -227,7 +226,7 @@
 
    private void createRefCountForNewFile(String fileName) {
       FileReadLockKey readLockKey = new FileReadLockKey(indexName, fileName);
-      cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).put(readLockKey, Integer.valueOf(1));
+      cache.withFlags(Flag.SKIP_REMOTE_LOOKUP, Flag.SKIP_CACHE_STORE).put(readLockKey, Integer.valueOf(1));
    }
 
    @SuppressWarnings("unchecked")
@@ -269,7 +268,7 @@
    }
 
    private FileMetadata getFileMetadata(String fileName) {
-      CacheKey key = new FileCacheKey(indexName, fileName);
+      FileCacheKey key = new FileCacheKey(indexName, fileName);
       return (FileMetadata) cache.withFlags(Flag.SKIP_LOCKING).get(key);
    }
 
@@ -278,7 +277,7 @@
       return "InfinispanDirectory{" + "indexName='" + indexName + '\'' + '}';
    }
 
-   public Cache<CacheKey, Object> getCache() {
+   public Cache getCache() {
       return cache;
    }
 

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -43,7 +43,7 @@
 
    private static final Log log = LogFactory.getLog(InfinispanIndexInput.class);
 
-   private final AdvancedCache<CacheKey, Object> cache;
+   private final AdvancedCache cache;
    private final FileMetadata file;
    private final FileCacheKey fileKey;
    private final int chunkSize;
@@ -56,7 +56,7 @@
 
    private boolean isClone;
 
-   public InfinispanIndexInput(AdvancedCache<CacheKey, Object> cache, FileCacheKey fileKey, int chunkSize, FileMetadata fileMetadata) throws FileNotFoundException {
+   public InfinispanIndexInput(AdvancedCache cache, FileCacheKey fileKey, int chunkSize, FileMetadata fileMetadata) throws FileNotFoundException {
       this.cache = cache;
       this.fileKey = fileKey;
       this.chunkSize = chunkSize;
@@ -84,7 +84,7 @@
     * @param readLockKey the key pointing to the reference counter value
     * @param cache The cache containing the reference counter value
     */
-   static void releaseReadLock(FileReadLockKey readLockKey, AdvancedCache<CacheKey, Object> cache) {
+   static void releaseReadLock(FileReadLockKey readLockKey, AdvancedCache cache) {
       int newValue = 0;
       // spinning as we currently don't mandate transactions, so no proper lock support available
       boolean done = false;
@@ -111,7 +111,7 @@
     * @param readLockKey the key representing the values to be deleted
     * @param cache the cache containing the elements to be deleted
     */
-   static void realFileDelete(FileReadLockKey readLockKey, AdvancedCache<CacheKey, Object> cache) {
+   static void realFileDelete(FileReadLockKey readLockKey, AdvancedCache cache) {
       final String indexName = readLockKey.getIndexName();
       final String filename = readLockKey.getFileName();
       int i = 0;
@@ -213,7 +213,7 @@
    }
 
    private void setBufferToCurrentChunk() throws IOException {
-      CacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), currentLoadedChunk);
+      ChunkCacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), currentLoadedChunk);
       buffer = (byte[]) cache.withFlags(Flag.SKIP_LOCKING).get(key);
       if (buffer == null) {
          throw new IOException("Chunk value could not be found for key " + key);
@@ -224,7 +224,7 @@
    // Lucene might try seek(pos) using an illegal pos value
    // RAMDirectory teaches to position the cursor to the end of previous chunk in this case
    private void setBufferToCurrentChunkIfPossible() throws IOException {
-      CacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), currentLoadedChunk);
+      ChunkCacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), currentLoadedChunk);
       buffer = (byte[]) cache.withFlags(Flag.SKIP_LOCKING).get(key);
       if (buffer == null) {
          currentLoadedChunk--;

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexOutput.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexOutput.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexOutput.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -44,7 +44,7 @@
 
    private final int bufferSize;
 
-   private final AdvancedCache<CacheKey, Object> cache;
+   private final AdvancedCache cache;
    private final FileMetadata file;
    private final FileCacheKey fileKey;
 
@@ -53,7 +53,7 @@
    private long filePosition = 0;
    private int currentChunkNumber = 0;
 
-   public InfinispanIndexOutput(AdvancedCache<CacheKey, Object> cache, FileCacheKey fileKey, int bufferSize, FileMetadata fileMetadata) throws IOException {
+   public InfinispanIndexOutput(AdvancedCache cache, FileCacheKey fileKey, int bufferSize, FileMetadata fileMetadata) throws IOException {
       this.cache = cache;
       this.fileKey = fileKey;
       this.bufferSize = bufferSize;
@@ -64,8 +64,8 @@
       }
    }
    
-   private static byte[] getChunkById(AdvancedCache<CacheKey, Object> cache, FileCacheKey fileKey, int chunkNumber, int bufferSize) {
-      CacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), chunkNumber);
+   private static byte[] getChunkById(AdvancedCache cache, FileCacheKey fileKey, int chunkNumber, int bufferSize) {
+      ChunkCacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), chunkNumber);
       byte[] readBuffer = (byte[]) cache.withFlags(Flag.SKIP_LOCKING).get(key);
       if (readBuffer==null) {
          return new byte[bufferSize];

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/SingleChunkIndexInput.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/SingleChunkIndexInput.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/SingleChunkIndexInput.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -43,8 +43,8 @@
    private final byte[] buffer;
    private int bufferPosition;
 
-   public SingleChunkIndexInput(AdvancedCache<CacheKey, Object> cache, FileCacheKey fileKey, FileMetadata fileMetadata) throws FileNotFoundException {
-      CacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), 0);
+   public SingleChunkIndexInput(AdvancedCache cache, FileCacheKey fileKey, FileMetadata fileMetadata) throws FileNotFoundException {
+      ChunkCacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), 0);
       buffer = (byte[]) cache.withFlags(Flag.SKIP_LOCKING).get(key);
       if (buffer == null) {
          throw new FileNotFoundException("Chunk value could not be found for key " + key);

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLockFactory.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLockFactory.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLockFactory.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -26,7 +26,6 @@
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.store.LockFactory;
 import org.infinispan.Cache;
-import org.infinispan.lucene.CacheKey;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -44,11 +43,11 @@
    private static final Log log = LogFactory.getLog(BaseLockFactory.class);
    static final String DEF_LOCK_NAME = IndexWriter.WRITE_LOCK_NAME;
 
-   private final Cache<CacheKey, Object> cache;
+   private final Cache cache;
    private final String indexName;
    private final BaseLuceneLock defLock;
 
-   public BaseLockFactory(Cache<CacheKey, Object> cache, String indexName) {
+   public BaseLockFactory(Cache cache, String indexName) {
       this.cache = cache;
       this.indexName = indexName;
       defLock = new BaseLuceneLock(cache, indexName, DEF_LOCK_NAME);

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLuceneLock.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLuceneLock.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/BaseLuceneLock.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -27,7 +27,6 @@
 import org.infinispan.AdvancedCache;
 import org.infinispan.Cache;
 import org.infinispan.context.Flag;
-import org.infinispan.lucene.CacheKey;
 import org.infinispan.lucene.FileCacheKey;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
@@ -46,16 +45,16 @@
    private static final Log log = LogFactory.getLog(BaseLuceneLock.class);
    private static final Flag[] lockFlags = new Flag[]{Flag.SKIP_CACHE_STORE};
 
-   private final AdvancedCache<CacheKey, Object> cache;
+   private final AdvancedCache cache;
    private final String lockName;
    private final String indexName;
    private final FileCacheKey keyOfLock;
 
-   BaseLuceneLock(Cache<CacheKey, Object> cache, String indexName, String lockName) {
+   BaseLuceneLock(Cache cache, String indexName, String lockName) {
       this.cache = cache.getAdvancedCache();
       this.lockName = lockName;
       this.indexName = indexName;
-      this.keyOfLock = new FileCacheKey(indexName, lockName, true);
+      this.keyOfLock = new FileCacheKey(indexName, lockName);
    }
 
    /**

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalLockFactory.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalLockFactory.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalLockFactory.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -26,7 +26,6 @@
 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;
 
@@ -58,12 +57,12 @@
    private static final Log log = LogFactory.getLog(TransactionalLockFactory.class);
    private static final String DEF_LOCK_NAME = IndexWriter.WRITE_LOCK_NAME;
 
-   private final Cache<CacheKey, Object> cache;
+   private final Cache cache;
    private final String indexName;
    private final TransactionManager tm;
    private final TransactionalSharedLuceneLock defLock;
 
-   public TransactionalLockFactory(Cache<CacheKey, Object> cache, String indexName) {
+   public TransactionalLockFactory(Cache cache, String indexName) {
       this.cache = cache;
       this.indexName = indexName;
       tm = cache.getAdvancedCache().getTransactionManager();

Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalSharedLuceneLock.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalSharedLuceneLock.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/locking/TransactionalSharedLuceneLock.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -31,7 +31,6 @@
 import org.infinispan.Cache;
 import org.infinispan.CacheException;
 import org.infinispan.context.Flag;
-import org.infinispan.lucene.CacheKey;
 import org.infinispan.lucene.FileCacheKey;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
@@ -51,18 +50,18 @@
    private static final Log log = LogFactory.getLog(TransactionalSharedLuceneLock.class);
    private static final Flag[] lockFlags = new Flag[]{Flag.SKIP_CACHE_STORE};
 
-   private final AdvancedCache<CacheKey, Object> cache;
+   private final AdvancedCache cache;
    private final String lockName;
    private final String indexName;
    private final TransactionManager tm;
    private final FileCacheKey keyOfLock;
 
-   TransactionalSharedLuceneLock(Cache<CacheKey, Object> cache, String indexName, String lockName, TransactionManager tm) {
+   TransactionalSharedLuceneLock(Cache cache, String indexName, String lockName, TransactionManager tm) {
       this.cache = cache.getAdvancedCache();
       this.lockName = lockName;
       this.indexName = indexName;
       this.tm = tm;
-      this.keyOfLock = new FileCacheKey(indexName, lockName, true);
+      this.keyOfLock = new FileCacheKey(indexName, lockName);
    }
 
    /**

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -28,7 +28,10 @@
 import org.apache.lucene.index.IndexWriter.MaxFieldLength;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.LockObtainFailedException;
 import org.infinispan.config.Configuration;
@@ -44,7 +47,10 @@
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Random;
+import java.util.Set;
 
 /**
  * Contains general utilities used by other tests
@@ -151,5 +157,62 @@
       IndexSearcher searcher = new IndexSearcher(directory, true);
       searcher.close();
    }
+   
+   /**
+    * Used in test to remove all documents containing some term
+    * 
+    * @param dir The Directory containing the Index to verify
+    * @param string
+    */
+   public static void removeByTerm(Directory dir, String term) throws IOException {
+      IndexWriter iw = new IndexWriter(dir, LuceneSettings.analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
+      iw.deleteDocuments(new Term("body", term));
+      iw.commit();
+      iw.close();
+   }
 
+   /**
+    * Used in test to verify an Index
+    * 
+    * @param dir The Directory containing the Index to verify
+    * @param term a single Term (after analysis) to be searched for
+    * @param validDocumentIds The list of document identifiers which should contain the searched-for term
+    * @throws IOException
+    */
+   public static void assertTextIsFoundInIds(Directory dir, String term, Integer... validDocumentIds) throws IOException {
+      int expectedResults = validDocumentIds.length;
+      Set<Integer> expectedDocumendIds = new HashSet<Integer>(Arrays.asList(validDocumentIds));
+      IndexSearcher searcher = new IndexSearcher(dir,true);
+      Query query = new TermQuery(new Term("body", term));
+      TopDocs docs = searcher.search(query, null, expectedResults + 1);
+      assert docs.totalHits == expectedResults;
+      for (ScoreDoc scoreDoc : docs.scoreDocs) {
+         int docId = scoreDoc.doc;
+         Document document = searcher.doc(docId);
+         String idString = document.get("id");
+         assert idString != null;
+         Integer idFoundElement = Integer.valueOf(idString);
+         assert expectedDocumendIds.contains(idFoundElement);
+      }
+      searcher.close();
+   }
+
+   /**
+    * Used in test to add a new Document to an Index; two fields are created: id and body 
+    * 
+    * @param dir The Directory containing the Index to modify
+    * @param id a sequential number to identify this document (id field)
+    * @param text Some text to add to the body field
+    * @throws IOException
+    */
+   public static void writeTextToIndex(Directory dir, int id, String text) throws IOException {
+      IndexWriter iw = new IndexWriter(dir, LuceneSettings.analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
+      Document doc = new Document();
+      doc.add(new Field("id", String.valueOf(id), Field.Store.YES, Field.Index.NOT_ANALYZED));
+      doc.add(new Field("body", text, Field.Store.NO, Field.Index.ANALYZED));
+      iw.addDocument(doc);
+      iw.commit();
+      iw.close();
+   }
+
 }

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/DirectoryIntegrityCheck.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/DirectoryIntegrityCheck.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/DirectoryIntegrityCheck.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -24,7 +24,6 @@
 import java.util.Set;
 
 import org.infinispan.Cache;
-import org.infinispan.lucene.CacheKey;
 import org.infinispan.lucene.ChunkCacheKey;
 import org.infinispan.lucene.FileCacheKey;
 import org.infinispan.lucene.FileListCacheKey;
@@ -51,7 +50,7 @@
     * @param indexName
     *           The name of the unique index stored in the cache
     */
-   public static void verifyDirectoryStructure(Cache<CacheKey, Object> cache, String indexName) {
+   public static void verifyDirectoryStructure(Cache cache, String indexName) {
       Set<String> fileList = (Set<String>) cache.get(new FileListCacheKey(indexName));
       Assert.assertNotNull(fileList);
       int fileListCacheKeyInstances = 0;
@@ -69,7 +68,6 @@
          } else if (key instanceof FileCacheKey) {
             FileCacheKey fileCacheKey = (FileCacheKey) key;
             Assert.assertEquals(fileCacheKey.getIndexName(), indexName);
-            Assert.assertFalse(fileCacheKey.isLockKey());
             Assert.assertTrue(fileList.contains(fileCacheKey.getFileName()), fileCacheKey + " should not have existed");
             Object value = cache.get(fileCacheKey);
             Assert.assertNotNull(value);
@@ -105,7 +103,7 @@
     *           the cache storing the chunks
     * @return the total size adding all found chunks up
     */
-   public static long deepCountFileSize(FileCacheKey fileCacheKey, Cache<CacheKey, Object> cache) {
+   public static long deepCountFileSize(FileCacheKey fileCacheKey, Cache cache) {
       String indexName = fileCacheKey.getIndexName();
       String fileName = fileCacheKey.getFileName();
       long accumulator = 0;

Deleted: trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -1,255 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.infinispan.lucene;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.SimpleAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Field.Index;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriter.MaxFieldLength;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.LockObtainFailedException;
-import org.infinispan.Cache;
-import org.infinispan.lucene.testutils.ClusteredCacheFactory;
-import org.infinispan.manager.EmbeddedCacheManager;
-import org.infinispan.test.TestingUtil;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.BlockingDeque;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.TimeUnit;
-
-/**
- * <p>
- * DynamicClusterIndexStressTest verifies the index state is healthy while the cluster topology changes.
- * While doing rehashing of the cluster in background it makes changes and searches, verifying the
- * search results.
- * </p>
- * Two pools of strings are maintained: one containing strings which are guaranteed to be found in the index,
- * and one containing the strings which are guaranteed to not be found in the index.
- * Threads take from these pools, check the index state towards them, then write/delete them from
- * index, commit and move them to the appropriate pool to check again or have another thread check them.
- * Different threads own different Directory instances - linked by Infinispan - while the pools are BlockingDeques
- * shared by reference.
- * </p>
- * 
- * Run with -Dbind.address=127.0.0.1 -Djava.net.preferIPv4Stack=true
- * 
- * @author Sanne Grinovero
- * @since 4.0
- */
- at Test(groups = "profiling", testName = "lucene.DynamicClusterIndexStressTest", enabled = false,
-      description = "This is a 'manual' test and should only be enabled and run when attached to a profiler.")
-public class DynamicClusterIndexStressTest {
-
-   private static final int TOTAL_NODES_TO_CREATE = 1000;
-   private static final int NODE_EXISTING_MILLISECONDS = 60000;
-   private static final int TIME_BETWEEN_NODE_CREATIONS = 1000;
-   private static final int CONCURRENCY_LIMIT = 10;
-   private static final int STRING_POOL_SIZE = 1000;
-   private static final Analyzer anyAnalyzer = new SimpleAnalyzer();
-
-   private final BlockingDeque<String> stringsInIndex = new LinkedBlockingDeque<String>();
-   private final BlockingDeque<String> stringsOutOfIndex = new LinkedBlockingDeque<String>();
-   private final ClusteredCacheFactory cacheFactory = new ClusteredCacheFactory(CacheTestSupport.createTestConfiguration());
-
-   private volatile boolean failed = false;
-   private volatile String failureMessage = "";
-
-//   @Test
-//   public void periodicallyAddingANode() throws InterruptedException, LockObtainFailedException, IOException {
-//      for (int i = 0; i < STRING_POOL_SIZE; i++) {
-//         stringsOutOfIndex.add(String.valueOf(i));
-//      }
-//      Cache<CacheKey, Object> cache = cacheFactory.createClusteredCache();
-//      try {
-//         createIndex(cache);
-//         runMoreNodes();
-//      } finally {
-//         cleanup(cache);
-//      }
-//   }
-
-   /**
-    * Initialize the empty index
-    * 
-    * @param cache to use to contain the index
-    * @throws CorruptIndexException
-    * @throws LockObtainFailedException
-    * @throws IOException
-    */
-   private void createIndex(Cache<CacheKey, Object> cache) throws CorruptIndexException, LockObtainFailedException, IOException {
-      InfinispanDirectory directory = new InfinispanDirectory(cache, "indexName");
-      IndexWriter iwriter = new IndexWriter(directory, anyAnalyzer, true, MaxFieldLength.UNLIMITED);
-      iwriter.commit();
-      iwriter.close();
-      IndexSearcher searcher = new IndexSearcher(directory, true);
-      searcher.close();
-      System.out.println("Index created by " + buildName(cache));
-      // verify it can be reopened:
-      InfinispanDirectory directory2 = new InfinispanDirectory(cache, "indexName");
-      IndexSearcher searcher2 = new IndexSearcher(directory2, true);
-      searcher2.close();
-   }
-
-   private void runMoreNodes() throws InterruptedException {
-      ExecutorService executor = Executors.newFixedThreadPool(CONCURRENCY_LIMIT);
-      for (int i = 0; !failed && (i < TOTAL_NODES_TO_CREATE); i++) {
-         executor.execute(new LuceneUserThread());
-         Thread.sleep(TIME_BETWEEN_NODE_CREATIONS);
-      }
-      executor.shutdown();
-      executor.awaitTermination(1, TimeUnit.HOURS);
-      Assert.assertTrue(!failed, failureMessage);
-   }
-   
-   public void testWithoutRehashing() throws InterruptedException{
-      ExecutorService executor = Executors.newFixedThreadPool(CONCURRENCY_LIMIT);
-      Cache[] caches = new Cache[CONCURRENCY_LIMIT];
-      for (int i=0; i<CONCURRENCY_LIMIT; i++){
-         caches[i] = cacheFactory.createClusteredCacheWaitingForNodesView(i+1);
-      }
-      //TODO run the tests
-      for (int i=0; i<CONCURRENCY_LIMIT; i++){
-         Thread.sleep(250); // there should be some sleep here
-         cleanup(caches[i]);
-      }
-   }
-   
-   private static String buildName(Cache cache) {
-      EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) cache.getCacheManager();
-      return Thread.currentThread().getName() +  "[" + cacheManager.getAddress().toString() + "]";
-   }
-
-   private class LuceneUserThread implements Runnable {
-
-      private Directory directory;
-
-      @Override
-      public void run() {
-         if (failed)
-            return;
-         String name = "";
-         try {
-            Cache<CacheKey, Object> cache = cacheFactory.createClusteredCache();
-            try {
-               name = buildName(cache);
-               directory = new InfinispanDirectory(cache, "indexName");
-               System.out.println("Created Directory in " + name);
-               try {
-                  runTest();
-               } catch (Exception e) {
-                  System.out.println("Error in " + name);
-                  e.printStackTrace();
-                  failed = true;
-                  failureMessage = e.getMessage();
-               }
-            } finally {
-               cleanup(cache);
-            }
-         } catch (InterruptedException e) {
-            failed = true;
-            failureMessage = e.getMessage();
-         } finally {
-            System.out.println("Leaving thread " + name);
-         }
-      }
-
-      private void runTest() throws CorruptIndexException, IOException {
-         long finishTime = System.currentTimeMillis() + NODE_EXISTING_MILLISECONDS;
-         while (!failed && System.currentTimeMillis() < finishTime) {
-            verifyStringsExistInIndex();
-            // verifyStringsNotExistInIndex(); //TODO
-            addSomeStrings();
-            // deleteSomeStrings(); //TODO
-         }
-      }
-
-      private void addSomeStrings() throws CorruptIndexException, LockObtainFailedException, IOException {
-         Set<String> strings = new HashSet<String>();
-         stringsOutOfIndex.drainTo(strings, 5);
-         IndexWriter iwriter = new IndexWriter(directory, anyAnalyzer, false, MaxFieldLength.UNLIMITED);
-         for (String term : strings) {
-            Document doc = new Document();
-            doc.add(new Field("main", term, Store.NO, Index.NOT_ANALYZED));
-            iwriter.addDocument(doc);
-         }
-         iwriter.commit();
-         stringsInIndex.addAll(strings);
-         iwriter.close();
-      }
-
-      private void verifyStringsExistInIndex() throws CorruptIndexException, IOException {
-         // take ownership of some strings, so that no other thread will change status for them:
-         Set<String> strings = new HashSet<String>();
-         stringsInIndex.drainTo(strings, 50);
-         IndexSearcher searcher = new IndexSearcher(directory, true);
-         for (String term : strings) {
-            Query query = new TermQuery(new Term("main", term));
-            TopDocs docs = searcher.search(query, null, 1);
-            if (docs.totalHits != 1) {
-               failed = true;
-               failureMessage = "couldn't find expected term in index";
-            }
-         }
-         // put the strings back at their place:
-         stringsInIndex.addAll(strings);
-      }
-
-   }
-
-   @BeforeClass
-   public void beforeTest() {
-      cacheFactory.start();
-   }
-
-   @AfterClass
-   public void afterTest() {
-      cacheFactory.stop();
-   }
-   
-   private static void cleanup(Cache<CacheKey, Object> cache) {
-      try {
-         TestingUtil.killCaches(cache);
-      } finally {
-         TestingUtil.killCacheManagers(cache.getCacheManager());
-      }
-   }
-
-}

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryIOTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryIOTest.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryIOTest.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -28,13 +28,12 @@
 import java.util.Random;
 import java.util.Set;
 
-import junit.framework.Assert;
-
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.IndexOutput;
 import org.infinispan.Cache;
 import org.infinispan.lucene.testutils.RepeatableLongByteSequence;
 import org.infinispan.manager.CacheContainer;
+import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
@@ -72,7 +71,7 @@
    public void testWriteUsingSeekMethod() throws IOException {
       final int BUFFER_SIZE = 64;
       
-      Cache<CacheKey, Object> cache = cacheManager.getCache();
+      Cache cache = cacheManager.getCache();
       InfinispanDirectory dir = new InfinispanDirectory(cache, INDEXNAME, BUFFER_SIZE);
       
       String fileName = "SomeText.txt";
@@ -136,7 +135,7 @@
    public void testReadWholeFile() throws IOException {
       final int BUFFER_SIZE = 64;
 
-      Cache<CacheKey, Object> cache = cacheManager.getCache();
+      Cache cache = cacheManager.getCache();
       InfinispanDirectory dir = new InfinispanDirectory(cache, INDEXNAME, BUFFER_SIZE);
 
       verifyOnBuffer("SingleChunk.txt", 61, BUFFER_SIZE, cache, dir, 15);
@@ -165,7 +164,7 @@
     * creates a file and then verifies it's readability in specific corner cases.
     * Then reuses the same parameters to verify the file rename capabilities. 
     */
-   private void verifyOnBuffer(final String fileName, final int fileSize, final int bufferSize, Cache<CacheKey, Object> cache, InfinispanDirectory dir, final int readBuffer) throws IOException {
+   private void verifyOnBuffer(final String fileName, final int fileSize, final int bufferSize, Cache cache, InfinispanDirectory dir, final int readBuffer) throws IOException {
       createFileWithRepeatableContent(dir, fileName, fileSize);
       assertReadByteWorkingCorrectly(dir, fileName, fileSize);
       assertReadBytesWorkingCorrectly(dir, fileName, fileSize, readBuffer);
@@ -183,7 +182,7 @@
    public void testReadRandomSampleFile() throws IOException {
       final int BUFFER_SIZE = 64;
 
-      Cache<CacheKey, Object> cache = cacheManager.getCache();
+      Cache cache = cacheManager.getCache();
       InfinispanDirectory dir = new InfinispanDirectory(cache, INDEXNAME, BUFFER_SIZE);
 
       final int FILE_SIZE = 1000;
@@ -285,10 +284,10 @@
    /**
     * Verifies a file is divided in N chunks
     */
-   private void assertHasNChunks(int expectedChunks, Cache<CacheKey, Object> cache, String index, String fileName) {
+   private void assertHasNChunks(int expectedChunks, Cache cache, String index, String fileName) {
       for (int i=0; i<expectedChunks; i++) {
          ChunkCacheKey key = new ChunkCacheKey(index, fileName, i);
-         Assert.assertTrue("should contain key " + key, cache.containsKey(key));
+         Assert.assertTrue(cache.containsKey(key), "should contain key " + key);
       }
    }
 
@@ -319,16 +318,16 @@
    public void testReadChunks() throws Exception {
       final int BUFFER_SIZE = 64;
 
-      Cache<CacheKey, Object> cache = cacheManager.getCache();
+      Cache cache = cacheManager.getCache();
       InfinispanDirectory dir = new InfinispanDirectory(cache, INDEXNAME, BUFFER_SIZE);
 
       // create file headers
       FileMetadata file1 = new FileMetadata();
-      CacheKey key1 = new FileCacheKey(INDEXNAME, "Hello.txt");
+      FileCacheKey key1 = new FileCacheKey(INDEXNAME, "Hello.txt");
       cache.put(key1, file1);
 
       FileMetadata file2 = new FileMetadata();
-      CacheKey key2 = new FileCacheKey(INDEXNAME, "World.txt");
+      FileCacheKey key2 = new FileCacheKey(INDEXNAME, "World.txt");
       cache.put(key2, file2);
 
       // byte array for Hello.txt
@@ -465,7 +464,7 @@
    public void testWriteChunks() throws Exception {
       final int BUFFER_SIZE = 64;
 
-      Cache<CacheKey, Object> cache = cacheManager.getCache();
+      Cache cache = cacheManager.getCache();
       InfinispanDirectory dir = new InfinispanDirectory(cache, INDEXNAME, BUFFER_SIZE);
 
       IndexOutput io = dir.createOutput("MyNewFile.txt");
@@ -504,7 +503,7 @@
 
    @Test
    public void testWriteChunksDefaultChunks() throws Exception {
-      Cache<CacheKey, Object> cache = cacheManager.getCache();
+      Cache cache = cacheManager.getCache();
       InfinispanDirectory dir = new InfinispanDirectory(cache, INDEXNAME);
 
       final String testText = "This is some rubbish";

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryStressTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryStressTest.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryStressTest.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -58,7 +58,7 @@
    public void testInfinispanDirectory() throws Exception {
       final int OPERATIONS = 100;
       CacheContainer cacheContainer = CacheTestSupport.createTestCacheManager();
-      Cache<CacheKey, Object> cache = cacheContainer.getCache();
+      Cache cache = cacheContainer.getCache();
       Directory directory = new InfinispanDirectory(cache, "indexName");
       CacheTestSupport.initializeDirectory(directory);
       File document = CacheTestSupport.createDummyDocToIndex("document.lucene", 10000);
@@ -82,12 +82,12 @@
    public void testDirectoryWithMultipleThreads() throws Exception {
       final CountDownLatch latch = new CountDownLatch(1);
       List<InfinispanDirectoryThread> threads = new ArrayList<InfinispanDirectoryThread>();
-      Cache<CacheKey, Object> cache = CacheTestSupport.createTestCacheManager().getCache();
+      Cache cache = CacheTestSupport.createTestCacheManager().getCache();
       Directory directory1 = new InfinispanDirectory(cache, "indexName");
       CacheTestSupport.initializeDirectory(directory1);
 
       // second cache joins after index creation: tests proper configuration
-      Cache<CacheKey, Object> cache2 = CacheTestSupport.createTestCacheManager().getCache(); // dummy cache, to force replication
+      Cache cache2 = CacheTestSupport.createTestCacheManager().getCache(); // dummy cache, to force replication
       Directory directory2 = new InfinispanDirectory(cache2, "indexName");
       Thread.sleep(3000);
 

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -21,23 +21,14 @@
  */
 package org.infinispan.lucene;
 
+import static org.infinispan.lucene.CacheTestSupport.assertTextIsFoundInIds;
+import static org.infinispan.lucene.CacheTestSupport.removeByTerm;
+import static org.infinispan.lucene.CacheTestSupport.writeTextToIndex;
+
 import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
 
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.infinispan.config.Configuration;
-import org.infinispan.lucene.testutils.LuceneSettings;
 import org.infinispan.test.MultipleCacheManagersTest;
 import org.testng.annotations.Test;
 
@@ -87,62 +78,4 @@
       testIndexWritingAndFinding();
    }
 
-
-   /**
-    * Used in test to remove all documents containing some term
-    * 
-    * @param dir The Directory containing the Index to verify
-    * @param string
-    */
-   private void removeByTerm(Directory dir, String term) throws IOException {
-      IndexWriter iw = new IndexWriter(dir, LuceneSettings.analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
-      iw.deleteDocuments(new Term("body", term));
-      iw.commit();
-      iw.close();
-   }
-
-   /**
-    * Used in test to verify an Index
-    * 
-    * @param dir The Directory containing the Index to verify
-    * @param term a single Term (after analysis) to be searched for
-    * @param validDocumentIds The list of document identifiers which should contain the searched-for term
-    * @throws IOException
-    */
-   private void assertTextIsFoundInIds(Directory dir, String term, Integer... validDocumentIds) throws IOException {
-      int expectedResults = validDocumentIds.length;
-      Set<Integer> expectedDocumendIds = new HashSet<Integer>(Arrays.asList(validDocumentIds));
-      IndexSearcher searcher = new IndexSearcher(dir,true);
-      Query query = new TermQuery(new Term("body", term));
-      TopDocs docs = searcher.search(query, null, expectedResults + 1);
-      assert docs.totalHits == expectedResults;
-      for (ScoreDoc scoreDoc : docs.scoreDocs) {
-         int docId = scoreDoc.doc;
-         Document document = searcher.doc(docId);
-         String idString = document.get("id");
-         assert idString != null;
-         Integer idFoundElement = Integer.valueOf(idString);
-         assert expectedDocumendIds.contains(idFoundElement);
-      }
-      searcher.close();
-   }
-
-   /**
-    * Used in test to add a new Document to an Index; two fields are created: id and body 
-    * 
-    * @param dir The Directory containing the Index to modify
-    * @param id a sequential number to identify this document (id field)
-    * @param text Some text to add to the body field
-    * @throws IOException
-    */
-   private void writeTextToIndex(Directory dir, int id, String text) throws IOException {
-      IndexWriter iw = new IndexWriter(dir, LuceneSettings.analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
-      Document doc = new Document();
-      doc.add(new Field("id", String.valueOf(id), Field.Store.YES, Field.Index.NOT_ANALYZED));
-      doc.add(new Field("body", text, Field.Store.NO, Field.Index.ANALYZED));
-      iw.addDocument(doc);
-      iw.commit();
-      iw.close();
-   }
-
 }

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/IndexReadingStressTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/IndexReadingStressTest.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/IndexReadingStressTest.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -44,12 +44,12 @@
 import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.RAMDirectory;
 import org.infinispan.Cache;
-import org.infinispan.lucene.CacheKey;
 import org.infinispan.lucene.CacheTestSupport;
 import org.infinispan.lucene.InfinispanDirectory;
 import org.infinispan.lucene.testutils.ClusteredCacheFactory;
 import org.infinispan.lucene.testutils.LuceneSettings;
 import org.infinispan.manager.CacheContainer;
+import org.infinispan.test.TestingUtil;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -75,6 +75,8 @@
 
    /** Number of Terms written in the index **/
    private static final int TERMS_NUMBER = 200000;
+   
+   private static final String indexName = "tempIndexName";
 
    private static final ClusteredCacheFactory cacheFactory = new ClusteredCacheFactory(CacheTestSupport.createTestConfiguration());
 
@@ -86,8 +88,9 @@
 
    @Test
    public void profileTestFSDirectory() throws InterruptedException, IOException {
-      File indexDir = new File(new File("."), "tempindex");
-      indexDir.mkdirs();
+      File indexDir = new File(new File("."), indexName);
+      boolean directoriesCreated = indexDir.mkdirs();
+      assert directoriesCreated : "couldn't create directory for FSDirectory test";
       FSDirectory dir = FSDirectory.open(indexDir);
       testDirectory(dir, "FSDirectory");
    }
@@ -95,7 +98,7 @@
    @Test
    public void profileTestInfinispanDirectory() throws InterruptedException, IOException {
       // these defaults are not for performance settings but meant for problem detection:
-      Cache<CacheKey, Object> cache = cacheFactory.createClusteredCache();
+      Cache cache = cacheFactory.createClusteredCache();
       InfinispanDirectory dir = new InfinispanDirectory(cache, "iname");
       testDirectory(dir, "InfinispanClustered");
    }
@@ -104,7 +107,7 @@
    public void profileInfinispanLocalDirectory() throws InterruptedException, IOException {
       CacheContainer cacheManager = CacheTestSupport.createLocalCacheManager();
       try {
-         Cache<CacheKey, Object> cache = cacheManager.getCache();
+         Cache cache = cacheManager.getCache();
          InfinispanDirectory dir = new InfinispanDirectory(cache, "iname");
          testDirectory(dir, "InfinispanLocal");
       } finally {
@@ -159,6 +162,7 @@
    @AfterClass
    public static void afterTest() {
       cacheFactory.stop();
+      TestingUtil.recursiveFileRemove(indexName);
    }
    
    private static class IndependentLuceneReaderThread extends LuceneUserThread {

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/PerformanceCompareStressTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/PerformanceCompareStressTest.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/profiling/PerformanceCompareStressTest.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -31,7 +31,6 @@
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.RAMDirectory;
 import org.infinispan.Cache;
-import org.infinispan.lucene.CacheKey;
 import org.infinispan.lucene.CacheTestSupport;
 import org.infinispan.lucene.DirectoryIntegrityCheck;
 import org.infinispan.lucene.InfinispanDirectory;
@@ -68,13 +67,13 @@
 
    /** Concurrent Threads in tests */
    private static final int READER_THREADS = 5;
-   private static final int WRITER_THREADS = 2;
+   private static final int WRITER_THREADS = 1;
 
    private static final String indexName = "tempIndexName";
 
    private static final long DURATION_MS = 60 * 60 * 1000;
 
-   private Cache<CacheKey, Object> cache;
+   private Cache cache;
 
    private EmbeddedCacheManager cacheFactory;
 
@@ -121,7 +120,7 @@
    public void profileInfinispanLocalDirectory() throws InterruptedException, IOException {
       CacheContainer cacheContainer = CacheTestSupport.createLocalCacheManager();
       try {
-         Cache<CacheKey, Object> cache = cacheContainer.getCache();
+         Cache cache = cacheContainer.getCache();
          InfinispanDirectory dir = new InfinispanDirectory(cache, indexName);
          stressTestDirectory(dir, "InfinispanLocal");
          DirectoryIntegrityCheck.verifyDirectoryStructure(cache, indexName);
@@ -133,7 +132,7 @@
    public static void stressTestDirectory(Directory dir, String testLabel) throws InterruptedException, IOException {
       SharedState state = new SharedState(DICTIONARY_SIZE);
       CacheTestSupport.initializeDirectory(dir);
-      ExecutorService e = Executors.newFixedThreadPool(READER_THREADS + 1);
+      ExecutorService e = Executors.newFixedThreadPool(READER_THREADS + WRITER_THREADS);
       for (int i = 0; i < READER_THREADS; i++) {
          e.execute(new LuceneReaderThread(dir, state));
       }

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/ClusteredCacheFactory.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/ClusteredCacheFactory.java	2010-08-06 14:45:07 UTC (rev 2175)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/ClusteredCacheFactory.java	2010-08-09 17:20:42 UTC (rev 2176)
@@ -31,7 +31,6 @@
 
 import org.infinispan.Cache;
 import org.infinispan.config.Configuration;
-import org.infinispan.lucene.CacheKey;
 import org.infinispan.manager.CacheContainer;
 import org.infinispan.test.TestingUtil;
 import org.infinispan.test.fwk.TestCacheManagerFactory;
@@ -48,7 +47,7 @@
 public class ClusteredCacheFactory {
 
    private final BlockingQueue<Configuration> requests = new SynchronousQueue<Configuration>();
-   private final BlockingQueue<Cache<CacheKey, Object>> results = new SynchronousQueue<Cache<CacheKey, Object>>();
+   private final BlockingQueue<Cache> results = new SynchronousQueue<Cache>();
    private final ExecutorService executor = Executors.newSingleThreadExecutor();
    private final Configuration cfg;
    
@@ -68,7 +67,7 @@
     * Create a cache using default configuration 
     * @throws InterruptedException if interrupted while waiting for the cache construction
     */
-   public synchronized Cache<CacheKey, Object> createClusteredCache() throws InterruptedException {
+   public synchronized Cache createClusteredCache() throws InterruptedException {
       if (!started)
          throw new IllegalStateException("was not started");
       if (stopped)
@@ -77,8 +76,8 @@
       return results.take();
    }
    
-   public Cache<CacheKey, Object> createClusteredCacheWaitingForNodesView(int expectedGroupSize) throws InterruptedException {
-      Cache<CacheKey, Object> cache = createClusteredCache();
+   public Cache createClusteredCacheWaitingForNodesView(int expectedGroupSize) throws InterruptedException {
+      Cache cache = createClusteredCache();
       TestingUtil.blockUntilViewReceived(cache, expectedGroupSize, 10000, false);
       return cache;
    }
@@ -109,7 +108,7 @@
             try {
                Configuration configuration = requests.take();
                CacheContainer cacheContainer = TestCacheManagerFactory.createClusteredCacheManager(configuration);
-               Cache<CacheKey, Object> cache = cacheContainer.getCache();
+               Cache cache = cacheContainer.getCache();
                results.put(cache);
             } catch (InterruptedException e) {
                return;



More information about the infinispan-commits mailing list