mirror of https://github.com/apache/lucene.git
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
This commit is contained in:
parent
6ebd260d01
commit
f6dd096703
|
@ -21,6 +21,13 @@
|
||||||
It is *not* a good example to work from.
|
It is *not* a good example to work from.
|
||||||
-->
|
-->
|
||||||
<config>
|
<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" />
|
<updateHandler class="solr.DirectUpdateHandler2" />
|
||||||
|
|
||||||
<requestDispatcher handleSelect="true" >
|
<requestDispatcher handleSelect="true" >
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
It is *not* a good example to work from.
|
It is *not* a good example to work from.
|
||||||
-->
|
-->
|
||||||
<config>
|
<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" />
|
<updateHandler class="solr.DirectUpdateHandler2" />
|
||||||
|
|
||||||
<requestDispatcher handleSelect="true" >
|
<requestDispatcher handleSelect="true" >
|
||||||
|
|
|
@ -28,11 +28,11 @@ import org.apache.lucene.store.Directory;
|
||||||
* Directory provider for using lucene RAMDirectory
|
* Directory provider for using lucene RAMDirectory
|
||||||
*/
|
*/
|
||||||
public class RAMDirectoryFactory extends StandardDirectoryFactory {
|
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
|
@Override
|
||||||
public Directory open(String path) throws IOException {
|
public Directory open(String path) throws IOException {
|
||||||
synchronized (this) {
|
synchronized (RAMDirectoryFactory.class) {
|
||||||
RefCntRamDirectory directory = directories.get(path);
|
RefCntRamDirectory directory = directories.get(path);
|
||||||
if (directory == null || !directory.isOpen()) {
|
if (directory == null || !directory.isOpen()) {
|
||||||
directory = (RefCntRamDirectory) openNew(path);
|
directory = (RefCntRamDirectory) openNew(path);
|
||||||
|
@ -46,7 +46,7 @@ public class RAMDirectoryFactory extends StandardDirectoryFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exists(String path) {
|
public boolean exists(String path) {
|
||||||
synchronized (this) {
|
synchronized (RAMDirectoryFactory.class) {
|
||||||
RefCntRamDirectory directory = directories.get(path);
|
RefCntRamDirectory directory = directories.get(path);
|
||||||
if (directory == null || !directory.isOpen()) {
|
if (directory == null || !directory.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -130,6 +130,9 @@ public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
|
||||||
long before = mcr.getStartTime( name ).getTime();
|
long before = mcr.getStartTime( name ).getTime();
|
||||||
CoreAdminRequest.reloadCore( name, coreadmin );
|
CoreAdminRequest.reloadCore( name, coreadmin );
|
||||||
|
|
||||||
|
// core should still have docs
|
||||||
|
assertEquals( 1, getSolrCore0().query( new SolrQuery( "id:AAA" ) ).getResults().size() );
|
||||||
|
|
||||||
mcr = CoreAdminRequest.getStatus( name, coreadmin );
|
mcr = CoreAdminRequest.getStatus( name, coreadmin );
|
||||||
long after = mcr.getStartTime( name ).getTime();
|
long after = mcr.getStartTime( name ).getTime();
|
||||||
assertTrue( "should have more recent time: "+after+","+before, after > before );
|
assertTrue( "should have more recent time: "+after+","+before, after > before );
|
||||||
|
|
Loading…
Reference in New Issue