public static MockDirectoryWrapper newMockFSDirectory(Path f, LockFactory lf) { return (MockDirectoryWrapper) newFSDirectory(f, lf, false); }
/** Returns a new FSDirectory instance over the given file, which must be a folder. */ public static BaseDirectoryWrapper newFSDirectory(Path f) { return newFSDirectory(f, FSLockFactory.getDefault()); }
@Override public Directory newDirectory() throws IOException { return newFSDirectory(shardPath.resolveIndex()); } };
/** Returns a new FSDirectory instance over the given file, which must be a folder. */ public static BaseDirectoryWrapper newFSDirectory(Path f, LockFactory lf) { return newFSDirectory(f, lf, rarely()); }
public static MockDirectoryWrapper newMockFSDirectory(Path f) { return (MockDirectoryWrapper) newFSDirectory(f, FSLockFactory.getDefault(), false); }
/** Like {@link #newFSDirectory(Path)}, but randomly insert {@link VirusCheckingFS} */ public static BaseDirectoryWrapper newMaybeVirusCheckingFSDirectory(Path f) { if (random().nextInt(5) == 4) { f = addVirusChecker(f); } return newFSDirectory(f, FSLockFactory.getDefault()); }
@Override public Directory create(String path, LockFactory lockFactory, DirContext dirContext) throws IOException { // we pass NoLockFactory, because the real lock factory is set later by injectLockFactory: Directory dir = LuceneTestCase.newFSDirectory(new File(path).toPath(), lockFactory); // 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 Directory cdir = reduce(dir); cdir = reduce(cdir); cdir = reduce(cdir); if (cdir instanceof MockDirectoryWrapper) { ((MockDirectoryWrapper)cdir).setAssertNoUnrefencedFilesOnClose(false); } return dir; }
/** Like {@link #newDirectory} except randomly the {@link VirusCheckingFS} may be installed */ public static BaseDirectoryWrapper newMaybeVirusCheckingDirectory() { if (random().nextInt(5) == 4) { Path path = addVirusChecker(createTempDir()); return newFSDirectory(path); } else { return newDirectory(random()); } }