use of org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex in project jackrabbit-oak by apache.
the class IndexNodeTest method lockAndRefreshPolicy.
@Test
public void lockAndRefreshPolicy() throws Exception {
NodeState state = createNRTIndex();
IndexDefinition definition = new IndexDefinition(root, state, "/foo");
NRTIndex nrtIndex = nrtFactory.createIndex(definition);
NRTIndex mock = spy(nrtIndex);
doReturn(new FailingPolicy()).when(mock).getRefreshPolicy();
IndexNode node = new IndexNode("/foo", definition, Collections.<LuceneIndexReader>emptyList(), mock);
try {
node.acquire();
fail();
} catch (Exception ignore) {
}
node.close();
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex in project jackrabbit-oak by apache.
the class IndexNode method open.
static IndexNode open(String indexPath, NodeState root, NodeState defnNodeState, LuceneIndexReaderFactory readerFactory, @Nullable NRTIndexFactory nrtFactory) throws IOException {
IndexDefinition definition = new IndexDefinition(root, defnNodeState, indexPath);
List<LuceneIndexReader> readers = readerFactory.createReaders(definition, defnNodeState, indexPath);
NRTIndex nrtIndex = nrtFactory != null ? nrtFactory.createIndex(definition) : null;
if (!readers.isEmpty() || (nrtIndex != null && !hasAsyncIndexerRun(root))) {
return new IndexNode(PathUtils.getName(indexPath), definition, readers, nrtIndex);
}
return null;
}
Aggregations