Example usage for org.apache.lucene.store MockDirectoryWrapper setAssertNoUnrefencedFilesOnClose

List of usage examples for org.apache.lucene.store MockDirectoryWrapper setAssertNoUnrefencedFilesOnClose

Introduction

In this page you can find the example usage for org.apache.lucene.store MockDirectoryWrapper setAssertNoUnrefencedFilesOnClose.

Prototype

public void setAssertNoUnrefencedFilesOnClose(boolean v) 

Source Link

Usage

From source file:org.apache.solr.core.MockDirectoryFactory.java

License:Apache License

@Override
protected Directory create(String path, DirContext dirContext) throws IOException {
    Directory dir = LuceneTestCase.newDirectory();

    Directory cdir = reduce(dir);//from w  w w  .j  a v a  2 s  . c  om
    cdir = reduce(cdir);
    cdir = reduce(cdir);

    if (cdir instanceof MockDirectoryWrapper) {
        MockDirectoryWrapper mockDirWrapper = (MockDirectoryWrapper) cdir;

        // we can't currently do this check because of how
        // Solr has to reboot a new Directory sometimes when replicating
        // or rolling back - the old directory is closed and the following
        // test assumes it can open an IndexWriter when that happens - we
        // have a new Directory for the same dir and still an open IW at 
        // this point
        mockDirWrapper.setAssertNoUnrefencedFilesOnClose(false);

        // ram dirs in cores that are restarted end up empty
        // and check index fails
        mockDirWrapper.setCheckIndexOnClose(false);

        // if we enable this, TestReplicationHandler fails when it
        // tries to write to index.properties after the file has
        // already been created.
        mockDirWrapper.setPreventDoubleWrite(false);
    }

    return dir;
}