From f6dd0967036d4bd4a60251aa04079e2c4c835c04 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Wed, 24 Mar 2010 00:12:48 +0000 Subject: [PATCH] allow RAMDir for multi-core tests - add test that docs stay after core reload - change RAMDirFactory to work over core reloads git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@926875 13f79535-47bb-0310-9956-ffa450edef68 --- solr/example/multicore/core0/conf/solrconfig.xml | 7 +++++++ solr/example/multicore/core1/conf/solrconfig.xml | 5 +++++ .../src/java/org/apache/solr/core/RAMDirectoryFactory.java | 6 +++--- .../apache/solr/client/solrj/MultiCoreExampleTestBase.java | 3 +++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/solr/example/multicore/core0/conf/solrconfig.xml b/solr/example/multicore/core0/conf/solrconfig.xml index 338a37cc982..69b534e6324 100644 --- a/solr/example/multicore/core0/conf/solrconfig.xml +++ b/solr/example/multicore/core0/conf/solrconfig.xml @@ -21,6 +21,13 @@ It is *not* a good example to work from. --> + + + + + diff --git a/solr/example/multicore/core1/conf/solrconfig.xml b/solr/example/multicore/core1/conf/solrconfig.xml index 338a37cc982..11be4843e2d 100644 --- a/solr/example/multicore/core1/conf/solrconfig.xml +++ b/solr/example/multicore/core1/conf/solrconfig.xml @@ -21,6 +21,11 @@ It is *not* a good example to work from. --> + + + diff --git a/solr/src/java/org/apache/solr/core/RAMDirectoryFactory.java b/solr/src/java/org/apache/solr/core/RAMDirectoryFactory.java index b40aaae2257..3a27ce80801 100644 --- a/solr/src/java/org/apache/solr/core/RAMDirectoryFactory.java +++ b/solr/src/java/org/apache/solr/core/RAMDirectoryFactory.java @@ -28,11 +28,11 @@ import org.apache.lucene.store.Directory; * Directory provider for using lucene RAMDirectory */ public class RAMDirectoryFactory extends StandardDirectoryFactory { - private Map directories = new HashMap(); + private static Map directories = new HashMap(); @Override public Directory open(String path) throws IOException { - synchronized (this) { + synchronized (RAMDirectoryFactory.class) { RefCntRamDirectory directory = directories.get(path); if (directory == null || !directory.isOpen()) { directory = (RefCntRamDirectory) openNew(path); @@ -46,7 +46,7 @@ public class RAMDirectoryFactory extends StandardDirectoryFactory { } public boolean exists(String path) { - synchronized (this) { + synchronized (RAMDirectoryFactory.class) { RefCntRamDirectory directory = directories.get(path); if (directory == null || !directory.isOpen()) { return false; diff --git a/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java b/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java index ec38e5c4ad3..0f678f5e04a 100644 --- a/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java +++ b/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java @@ -130,6 +130,9 @@ public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase long before = mcr.getStartTime( name ).getTime(); CoreAdminRequest.reloadCore( name, coreadmin ); + // core should still have docs + assertEquals( 1, getSolrCore0().query( new SolrQuery( "id:AAA" ) ).getResults().size() ); + mcr = CoreAdminRequest.getStatus( name, coreadmin ); long after = mcr.getStartTime( name ).getTime(); assertTrue( "should have more recent time: "+after+","+before, after > before );