use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.CopyOnReadDirectory in project jackrabbit-oak by apache.
the class IndexCopier method wrapForRead.
public Directory wrapForRead(String indexPath, IndexDefinition definition, Directory remote, String dirName) throws IOException {
Directory local = createLocalDirForIndexReader(indexPath, definition, dirName);
checkIntegrity(indexPath, local, remote);
return new CopyOnReadDirectory(this, remote, local, prefetchEnabled, indexPath, executor);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.CopyOnReadDirectory in project jackrabbit-oak by apache.
the class LucenePropertyIndexTest method createIndexCopier.
private IndexCopier createIndexCopier() {
try {
return new IndexCopier(executorService, temporaryFolder.getRoot()) {
@Override
public Directory wrapForRead(String indexPath, IndexDefinition definition, Directory remote, String dirName) throws IOException {
Directory ret = super.wrapForRead(indexPath, definition, remote, dirName);
corDir = getFSDirPath(ret);
return ret;
}
@Override
public Directory wrapForWrite(IndexDefinition definition, Directory remote, boolean reindexMode, String dirName) throws IOException {
Directory ret = super.wrapForWrite(definition, remote, reindexMode, dirName);
cowDir = getFSDirPath(ret);
return ret;
}
private String getFSDirPath(Directory dir) {
if (dir instanceof CopyOnReadDirectory) {
dir = ((CopyOnReadDirectory) dir).getLocal();
}
dir = unwrap(dir);
if (dir instanceof FSDirectory) {
return ((FSDirectory) dir).getDirectory().getAbsolutePath();
}
return null;
}
private Directory unwrap(Directory dir) {
if (dir instanceof FilterDirectory) {
return unwrap(((FilterDirectory) dir).getDelegate());
}
return dir;
}
};
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations