diff --git a/CHANGES.txt b/CHANGES.txt index c2d30324662..5be35cf41c1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -196,6 +196,11 @@ API Changes were deprecated. You should instantiate the Directory manually before and pass it to these classes (LUCENE-1451, LUCENE-1658). (Uwe Schindler) + +21. LUCENE-1407: Move RemoteSearchable, RemoteCachingWrapperFilter out + of Lucene's core into new contrib/remote package. Searchable no + longer extends java.rmi.Remote (Simon Willnauer via Mike + McCandless) Bug fixes diff --git a/build.xml b/build.xml index c410589c1f4..0a89413e089 100644 --- a/build.xml +++ b/build.xml @@ -77,15 +77,6 @@ - - - - - - - @@ -136,11 +127,7 @@ destdir="${build.dir}/${tag}/classes/java"> - - - - + diff --git a/common-build.xml b/common-build.xml index e0f5120cd69..3a5abe5f2d5 100644 --- a/common-build.xml +++ b/common-build.xml @@ -42,7 +42,7 @@ - + diff --git a/contrib/remote/build.xml b/contrib/remote/build.xml new file mode 100644 index 00000000000..3978b747a89 --- /dev/null +++ b/contrib/remote/build.xml @@ -0,0 +1,34 @@ + + + + + + + + Remote Searchable based on RMI + + + + + + + + + + + diff --git a/contrib/remote/pom.xml.template b/contrib/remote/pom.xml.template new file mode 100644 index 00000000000..3a06d6579b8 --- /dev/null +++ b/contrib/remote/pom.xml.template @@ -0,0 +1,36 @@ + + + + + 4.0.0 + + org.apache.lucene + lucene-contrib + @version@ + + org.apache.lucene + lucene-regex + Lucene Remote + @version@ + Remote Searchable based on RMI + jar + diff --git a/contrib/remote/src/java/org/apache/lucene/search/RMIRemoteSearchable.java b/contrib/remote/src/java/org/apache/lucene/search/RMIRemoteSearchable.java new file mode 100644 index 00000000000..46ebf6cada5 --- /dev/null +++ b/contrib/remote/src/java/org/apache/lucene/search/RMIRemoteSearchable.java @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.lucene.search; + +import java.rmi.Remote; + +/** + * Marker interface to enable subclasses of {@link Searchable} to be used via + * Java RMI. Classes implementing this interface can be used as a RMI - + * "remote object". + *

+ * {@link RMIRemoteSearchable} extends {@link Searchable} and can transparently + * be used as a such. + *

+ * Example usage: + * + *

+ *   RMIRemoteSearchable remoteObject = ...;
+ *   String remoteObjectName = ...;
+ *   Naming.rebind (remoteObjectName, remoteObject);
+ *   Searchable luceneSearchable = (Searchable) Naming.lookup (remoteObjectName);
+ * 
+ * + *

+ *

+ * + * @version $Id:$ + */ +public interface RMIRemoteSearchable extends Searchable, Remote { + +} diff --git a/src/java/org/apache/lucene/search/RemoteCachingWrapperFilter.java b/contrib/remote/src/java/org/apache/lucene/search/RemoteCachingWrapperFilter.java similarity index 99% rename from src/java/org/apache/lucene/search/RemoteCachingWrapperFilter.java rename to contrib/remote/src/java/org/apache/lucene/search/RemoteCachingWrapperFilter.java index 3862579fbec..47af20f36db 100644 --- a/src/java/org/apache/lucene/search/RemoteCachingWrapperFilter.java +++ b/contrib/remote/src/java/org/apache/lucene/search/RemoteCachingWrapperFilter.java @@ -36,6 +36,8 @@ import org.apache.lucene.index.IndexReader; * To cache a result you must do something like * RemoteCachingWrapperFilter f = new RemoteCachingWrapperFilter(new CachingWrapperFilter(myFilter)); *

+ * + * @version $Id:$ */ public class RemoteCachingWrapperFilter extends Filter { protected Filter filter; diff --git a/src/java/org/apache/lucene/search/RemoteSearchable.java b/contrib/remote/src/java/org/apache/lucene/search/RemoteSearchable.java similarity index 99% rename from src/java/org/apache/lucene/search/RemoteSearchable.java rename to contrib/remote/src/java/org/apache/lucene/search/RemoteSearchable.java index ba0b1ab513a..6251e69332c 100644 --- a/src/java/org/apache/lucene/search/RemoteSearchable.java +++ b/contrib/remote/src/java/org/apache/lucene/search/RemoteSearchable.java @@ -35,7 +35,7 @@ import java.rmi.server.UnicastRemoteObject; */ public class RemoteSearchable extends UnicastRemoteObject - implements Searchable { + implements RMIRemoteSearchable { private Searchable local; diff --git a/src/test/org/apache/lucene/search/RemoteCachingWrapperFilterHelper.java b/contrib/remote/src/test/org/apache/lucene/search/RemoteCachingWrapperFilterHelper.java similarity index 100% rename from src/test/org/apache/lucene/search/RemoteCachingWrapperFilterHelper.java rename to contrib/remote/src/test/org/apache/lucene/search/RemoteCachingWrapperFilterHelper.java diff --git a/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java b/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java similarity index 99% rename from src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java rename to contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java index 3ad8b78e6ab..1edf24c8a5e 100644 --- a/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java +++ b/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java @@ -33,6 +33,8 @@ import org.apache.lucene.store.RAMDirectory; /** * Tests that the index is cached on the searcher side of things. * NOTE: This is copied from TestRemoteSearchable since it already had a remote index set up. + * + * @version $Id:$ */ public class TestRemoteCachingWrapperFilter extends LuceneTestCase { public TestRemoteCachingWrapperFilter(String name) { diff --git a/src/test/org/apache/lucene/search/TestRemoteSearchable.java b/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java similarity index 99% rename from src/test/org/apache/lucene/search/TestRemoteSearchable.java rename to contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java index cf930e6e360..ff1d4ccf1cb 100644 --- a/src/test/org/apache/lucene/search/TestRemoteSearchable.java +++ b/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java @@ -32,7 +32,7 @@ import java.util.Set; import java.util.HashSet; /** - * @version $Id$ + * @version $Id$ */ public class TestRemoteSearchable extends LuceneTestCase { public TestRemoteSearchable(String name) { diff --git a/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java b/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java new file mode 100644 index 00000000000..47fc8343430 --- /dev/null +++ b/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java @@ -0,0 +1,455 @@ +package org.apache.lucene.search; + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.Serializable; +import java.rmi.Naming; +import java.rmi.registry.LocateRegistry; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Locale; +import java.util.Random; + +import junit.framework.Test; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.apache.lucene.analysis.SimpleAnalyzer; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.Field; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.Term; +import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.util._TestUtil; + +/** + * Unit tests for remote sorting code. + * Note: This is a modified copy of {@link TestSort} without duplicated test + * methods and therefore unused members and methodes. + * + * @version $Id:$ + */ + +public class TestRemoteSort extends LuceneTestCase implements Serializable { + + private Searcher full; + private Query queryX; + private Query queryY; + private Query queryA; + private Query queryF; + private Sort sort; + + + public TestRemoteSort (String name) { + super (name); + } + + public static void main (String[] argv) { + if (argv == null || argv.length < 1) + TestRunner.run (suite()); + else if ("server".equals (argv[0])) { + TestRemoteSort test = new TestRemoteSort (null); + try { + test.startServer(); + Thread.sleep (500000); + } catch (Exception e) { + System.out.println (e); + e.printStackTrace(); + } + } + } + + public static Test suite() { + return new TestSuite (TestRemoteSort.class); + } + + + // document data: + // the tracer field is used to determine which document was hit + // the contents field is used to search and sort by relevance + // the int field to sort by int + // the float field to sort by float + // the string field to sort by string + // the i18n field includes accented characters for testing locale-specific sorting + private String[][] data = new String[][] { + // tracer contents int float string custom i18n long double, 'short', byte, 'custom parser encoding' + { "A", "x a", "5", "4f", "c", "A-3", "p\u00EAche", "10", "-4.0", "3", "126", "J"},//A, x + { "B", "y a", "5", "3.4028235E38", "i", "B-10", "HAT", "1000000000", "40.0", "24", "1", "I"},//B, y + { "C", "x a b c", "2147483647", "1.0", "j", "A-2", "p\u00E9ch\u00E9", "99999999", "40.00002343", "125", "15", "H"},//C, x + { "D", "y a b c", "-1", "0.0f", "a", "C-0", "HUT", String.valueOf(Long.MAX_VALUE), String.valueOf(Double.MIN_VALUE), String.valueOf(Short.MIN_VALUE), String.valueOf(Byte.MIN_VALUE), "G"},//D, y + { "E", "x a b c d", "5", "2f", "h", "B-8", "peach", String.valueOf(Long.MIN_VALUE), String.valueOf(Double.MAX_VALUE), String.valueOf(Short.MAX_VALUE), String.valueOf(Byte.MAX_VALUE), "F"},//E,x + { "F", "y a b c d", "2", "3.14159f", "g", "B-1", "H\u00C5T", "-44", "343.034435444", "-3", "0", "E"},//F,y + { "G", "x a b c d", "3", "-1.0", "f", "C-100", "sin", "323254543543", "4.043544", "5", "100", "D"},//G,x + { "H", "y a b c d", "0", "1.4E-45", "e", "C-88", "H\u00D8T", "1023423423005","4.043545", "10", "-50", "C"},//H,y + { "I", "x a b c d e f", "-2147483648", "1.0e+0", "d", "A-10", "s\u00EDn", "332422459999", "4.043546", "-340", "51", "B"},//I,x + { "J", "y a b c d e f", "4", ".5", "b", "C-7", "HOT", "34334543543", "4.0000220343", "300", "2", "A"},//J,y + { "W", "g", "1", null, null, null, null, null, null, null, null, null}, + { "X", "g", "1", "0.1", null, null, null, null, null, null, null, null}, + { "Y", "g", "1", "0.2", null, null, null, null, null, null, null, null}, + { "Z", "f g", null, null, null, null, null, null, null, null, null, null} + }; + + // create an index of all the documents, or just the x, or just the y documents + private Searcher getIndex (boolean even, boolean odd) + throws IOException { + RAMDirectory indexStore = new RAMDirectory (); + IndexWriter writer = new IndexWriter (indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); + writer.setMaxBufferedDocs(2); + writer.setMergeFactor(1000); + for (int i=0; i{@link HitCollector#collect(int,float)} is called for every non-zero diff --git a/src/test/org/apache/lucene/search/TestSort.java b/src/test/org/apache/lucene/search/TestSort.java index e985f5c6121..cadda167d38 100644 --- a/src/test/org/apache/lucene/search/TestSort.java +++ b/src/test/org/apache/lucene/search/TestSort.java @@ -19,8 +19,6 @@ package org.apache.lucene.search; import java.io.IOException; import java.io.Serializable; -import java.rmi.Naming; -import java.rmi.registry.LocateRegistry; import java.util.BitSet; import java.util.HashMap; import java.util.Iterator; @@ -29,7 +27,6 @@ import java.util.Random; import junit.framework.Test; import junit.framework.TestSuite; -import junit.textui.TestRunner; import org.apache.lucene.analysis.SimpleAnalyzer; import org.apache.lucene.document.Document; @@ -44,7 +41,6 @@ import org.apache.lucene.store.LockObtainFailedException; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.DocIdBitSet; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util._TestUtil; /** * Unit tests for sorting code. @@ -74,21 +70,6 @@ public class TestSort extends LuceneTestCase implements Serializable { super (name); } - public static void main (String[] argv) { - if (argv == null || argv.length < 1) - TestRunner.run (suite()); - else if ("server".equals (argv[0])) { - TestSort test = new TestSort (null); - try { - test.startServer(); - Thread.sleep (500000); - } catch (Exception e) { - System.out.println (e); - e.printStackTrace(); - } - } - } - public static Test suite() { return new TestSuite (TestSort.class); } @@ -653,28 +634,6 @@ public class TestSort extends LuceneTestCase implements Serializable { runMultiSorts(searcher, false); } - // test a variety of sorts using a remote searcher - public void testRemoteSort() throws Exception { - Searchable searcher = getRemote(); - MultiSearcher multi = new MultiSearcher (new Searchable[] { searcher }); - runMultiSorts(multi, true); // this runs on the full index - } - - // test custom search when remote - public void testRemoteCustomSort() throws Exception { - Searchable searcher = getRemote(); - MultiSearcher multi = new MultiSearcher (new Searchable[] { searcher }); - sort.setSort (new SortField ("custom", SampleComparable.getComparatorSource())); - assertMatches (multi, queryX, sort, "CAIEG"); - sort.setSort (new SortField ("custom", SampleComparable.getComparatorSource(), true)); - assertMatches (multi, queryY, sort, "HJDBF"); - SortComparator custom = SampleComparable.getComparator(); - sort.setSort (new SortField ("custom", custom)); - assertMatches (multi, queryX, sort, "CAIEG"); - sort.setSort (new SortField ("custom", custom, true)); - assertMatches (multi, queryY, sort, "HJDBF"); - } - // test that the relevancy scores are the same even if // hits are sorted public void testNormalizedScores() throws Exception { @@ -685,97 +644,73 @@ public class TestSort extends LuceneTestCase implements Serializable { HashMap scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full); // we'll test searching locally, remote and multi - MultiSearcher remote = new MultiSearcher (new Searchable[] { getRemote() }); + MultiSearcher multi = new MultiSearcher (new Searchable[] { searchX, searchY }); // change sorting and make sure relevancy stays the same sort = new Sort(); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); sort.setSort(SortField.FIELD_DOC); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); sort.setSort ("int"); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); sort.setSort ("float"); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); sort.setSort ("string"); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); sort.setSort (new String[] {"int","float"}); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); sort.setSort (new SortField[] { new SortField ("int", true), new SortField (null, SortField.DOC, true) }); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); sort.setSort (new String[] {"float","string"}); assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi)); assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full)); - assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote)); assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi)); } @@ -1077,31 +1012,4 @@ public class TestSort extends LuceneTestCase implements Serializable { } } - private Searchable getRemote () throws Exception { - try { - return lookupRemote (); - } catch (Throwable e) { - startServer (); - return lookupRemote (); - } - } - - private Searchable lookupRemote () throws Exception { - return (Searchable) Naming.lookup ("//localhost:" + port + "/SortedSearchable"); - } - - private static int port = -1; - - private void startServer () throws Exception { - // construct an index - port = _TestUtil.getRandomSocketPort(); - Searcher local = getFullIndex(); - // local.search (queryA, new Sort()); - - // publish it - LocateRegistry.createRegistry (port); - RemoteSearchable impl = new RemoteSearchable (local); - Naming.rebind ("//localhost:" + port + "/SortedSearchable", impl); - } - }