Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

allow RAMDir for multi-core tests - add test that docs stay after core reload - change RAMDirFactory to work over core reloads

Mark Robert Millerf6dd0967036d
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.
-->
<config>
+
+ <!-- The DirectoryFactory to use for indexes.
+ solr.StandardDirectoryFactory, the default, is filesystem based.
+ solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
+
+
<updateHandler class="solr.DirectUpdateHandler2" />
<requestDispatcher handleSelect="true" >
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.
-->
<config>
+ <!-- The DirectoryFactory to use for indexes.
+ solr.StandardDirectoryFactory, the default, is filesystem based.
+ solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
+
<updateHandler class="solr.DirectUpdateHandler2" />
<requestDispatcher handleSelect="true" >
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<String, RefCntRamDirectory> directories = new HashMap<String, RefCntRamDirectory>();
+ private static Map<String, RefCntRamDirectory> directories = new HashMap<String, RefCntRamDirectory>();
@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 );