[infinispan-commits] Infinispan SVN: r1199 - in trunk/lucene-directory: src/main/java/org/infinispan/lucene and 2 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Sun Nov 15 07:09:55 EST 2009
Author: sannegrinovero
Date: 2009-11-15 07:09:55 -0500 (Sun, 15 Nov 2009)
New Revision: 1199
Added:
trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/LuceneSettings.java
Modified:
trunk/lucene-directory/pom.xml
trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java
trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java
trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.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/testutils/ClusteredCacheFactory.java
Log:
[ISPN-275] Update Lucene Directory to work with newer Lucene versions v.3.0.x
Modified: trunk/lucene-directory/pom.xml
===================================================================
--- trunk/lucene-directory/pom.xml 2009-11-13 18:15:47 UTC (rev 1198)
+++ trunk/lucene-directory/pom.xml 2009-11-15 12:09:55 UTC (rev 1199)
@@ -15,7 +15,7 @@
<description>A Lucene directory implementation based on Infinispan</description>
<properties>
- <version.lucene>2.4.1</version.lucene>
+ <version.lucene>2.9.1</version.lucene>
</properties>
<dependencies>
Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java 2009-11-13 18:15:47 UTC (rev 1198)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanDirectory.java 2009-11-15 12:09:55 UTC (rev 1199)
@@ -260,4 +260,10 @@
public Cache<CacheKey, Object> getCache() {
return cache;
}
+
+ /** new name for list() in Lucene 3.0 **/
+ public String[] listAll() throws IOException {
+ return list();
+ }
+
}
Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java 2009-11-13 18:15:47 UTC (rev 1198)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java 2009-11-15 12:09:55 UTC (rev 1199)
@@ -26,7 +26,6 @@
import java.io.FileWriter;
import java.util.Random;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -41,12 +40,13 @@
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
import org.infinispan.config.Configuration;
+import org.infinispan.lucene.testutils.LuceneSettings;
import org.infinispan.manager.CacheManager;
public abstract class CacheTestSupport {
private static final Log log = LogFactory.getLog(CacheTestSupport.class);
-
+
protected static CacheManager createTestCacheManager() {
return TestCacheManagerFactory.createClusteredCacheManager( createTestConfiguration() );
}
@@ -87,7 +87,7 @@
// this is a write
IndexWriter writer = null;
try {
- writer = new IndexWriter(d, new StandardAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ writer = new IndexWriter(d, LuceneSettings.analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
writer.setMergeScheduler(new SerialMergeScheduler());
log.info("IndexWriter was constructed");
@@ -113,9 +113,9 @@
IndexSearcher search = null;
try {
// this is a read
- search = new IndexSearcher(d);
+ search = new IndexSearcher(d, true);
// dummy query that probably won't return anything
- QueryParser qp = new QueryParser("path", new StandardAnalyzer());
+ QueryParser qp = new QueryParser(LuceneSettings.luceneCompatibility, "path", LuceneSettings.analyzer);
search.search(qp.parse("good"), null, 1);
} finally {
if (search != null) {
Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.java 2009-11-13 18:15:47 UTC (rev 1198)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/DynamicClusterIndexStressTest.java 2009-11-15 12:09:55 UTC (rev 1199)
@@ -117,12 +117,12 @@
IndexWriter iwriter = new IndexWriter(directory, anyAnalyzer, true, MaxFieldLength.UNLIMITED);
iwriter.commit();
iwriter.close();
- IndexSearcher searcher = new IndexSearcher(directory);
+ 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);
+ IndexSearcher searcher2 = new IndexSearcher(directory2, true);
searcher2.close();
}
@@ -218,7 +218,7 @@
// 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);
+ 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);
Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryStressTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryStressTest.java 2009-11-13 18:15:47 UTC (rev 1198)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/InfinispanDirectoryStressTest.java 2009-11-15 12:09:55 UTC (rev 1199)
@@ -30,12 +30,12 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
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.infinispan.Cache;
+import org.infinispan.lucene.testutils.LuceneSettings;
import org.infinispan.manager.CacheManager;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -68,7 +68,7 @@
CacheTestSupport.doReadOperation(directory);
}
- IndexSearcher search = new IndexSearcher(directory);
+ IndexSearcher search = new IndexSearcher(directory, true);
Term t = new Term("info", "good");
Query query = new TermQuery(t);
TopDocs hits = search.search(query, 1);
@@ -86,7 +86,7 @@
Directory directory1 = new InfinispanDirectory(cache, "indexName");
IndexWriter.MaxFieldLength fieldLength = new IndexWriter.MaxFieldLength(IndexWriter.DEFAULT_MAX_FIELD_LENGTH);
- IndexWriter iw = new IndexWriter(directory1, new StandardAnalyzer(), true, fieldLength);
+ IndexWriter iw = new IndexWriter(directory1, LuceneSettings.analyzer, true, fieldLength);
iw.close();
// second cache joins after index creation: tests proper configuration
@@ -123,7 +123,7 @@
}
}
- IndexSearcher search = new IndexSearcher(directory1);
+ IndexSearcher search = new IndexSearcher(directory1,true);
Term t = new Term("info", "good");
Query query = new TermQuery(t);
int expectedDocs = writeCount.get();
Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java 2009-11-13 18:15:47 UTC (rev 1198)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/SimpleLuceneTest.java 2009-11-15 12:09:55 UTC (rev 1199)
@@ -26,7 +26,6 @@
import java.util.HashSet;
import java.util.Set;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
@@ -38,6 +37,7 @@
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;
@@ -52,8 +52,6 @@
@Test(groups = "functional", testName = "lucene.SimpleLuceneTest")
public class SimpleLuceneTest extends MultipleCacheManagersTest {
- private static final StandardAnalyzer analyzer = new StandardAnalyzer(new String[0]);
-
@Override
protected void createCacheManagers() throws Throwable {
Configuration configuration = CacheTestSupport.createTestConfiguration();
@@ -84,7 +82,7 @@
* @param string
*/
private void removeByTerm(Directory dir, String term) throws IOException {
- IndexWriter iw = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter iw = new IndexWriter(dir, LuceneSettings.analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
iw.deleteDocuments(new Term("body", term));
iw.commit();
iw.close();
@@ -101,7 +99,7 @@
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);
+ 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;
@@ -125,7 +123,7 @@
* @throws IOException
*/
private void writeTextToIndex(Directory dir, int id, String text) throws IOException {
- IndexWriter iw = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
+ 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));
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 2009-11-13 18:15:47 UTC (rev 1198)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/ClusteredCacheFactory.java 2009-11-15 12:09:55 UTC (rev 1199)
@@ -26,6 +26,9 @@
import java.util.concurrent.Executors;
import java.util.concurrent.SynchronousQueue;
+import net.jcip.annotations.GuardedBy;
+import net.jcip.annotations.ThreadSafe;
+
import org.infinispan.Cache;
import org.infinispan.config.Configuration;
import org.infinispan.lucene.CacheKey;
@@ -39,14 +42,16 @@
* @author Sanne Grinovero
* @since 4.0
*/
+ at ThreadSafe
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 ExecutorService executor = Executors.newFixedThreadPool(1);
private final Configuration cfg;
- private boolean started = false;
- private boolean stopped = false;
+
+ @GuardedBy("this") private boolean started = false;
+ @GuardedBy("this") private boolean stopped = false;
/**
* Create a new ClusteredCacheFactory.
Added: trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/LuceneSettings.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/LuceneSettings.java (rev 0)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/LuceneSettings.java 2009-11-15 12:09:55 UTC (rev 1199)
@@ -0,0 +1,39 @@
+/*
+ * 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.testutils;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.util.Version;
+
+/**
+ * Collects common LuceneSettings for all tests; especially define the backwards compatibility.
+ *
+ * @author Sanne Grinovero
+ * @since 4.0
+ */
+public class LuceneSettings {
+
+ public static final Version luceneCompatibility = Version.LUCENE_24;
+ public static final Analyzer analyzer = new StandardAnalyzer(luceneCompatibility);
+
+}
Property changes on: trunk/lucene-directory/src/test/java/org/infinispan/lucene/testutils/LuceneSettings.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the infinispan-commits
mailing list