Search in sources :

Example 1 with NRTIndex

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();
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NRTIndex(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with NRTIndex

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;
}
Also used : LuceneIndexReader(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader) NRTIndex(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex)

Aggregations

NRTIndex (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex)2 IOException (java.io.IOException)1 LuceneIndexReader (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1 Test (org.junit.Test)1