Search in sources :

Example 1 with IndexTracker

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker in project jackrabbit-oak by apache.

the class HybridIndexClusterIT method customize.

@Override
protected Jcr customize(Jcr jcr) {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    MountInfoProvider mip = defaultMountInfoProvider();
    NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    LuceneIndexProvider provider = new LuceneIndexProvider(tracker);
    DocumentQueue queue = new DocumentQueue(100, tracker, sameThreadExecutor());
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
    editorProvider.setIndexingQueue(queue);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
    ExternalIndexObserver externalIndexObserver = new ExternalIndexObserver(queue, tracker, StatisticsProvider.NOOP);
    QueryEngineSettings qs = new QueryEngineSettings();
    qs.setFailTraversal(true);
    jcr.with((QueryIndexProvider) provider).with((Observer) provider).with(localIndexObserver).with(externalIndexObserver).with(editorProvider).with(qs).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    return jcr;
}
Also used : IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)

Example 2 with IndexTracker

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker in project jackrabbit-oak by apache.

the class DocumentQueueTest method createTracker.

private IndexTracker createTracker() throws IOException {
    IndexCopier indexCopier = new IndexCopier(sameThreadExecutor(), temporaryFolder.getRoot());
    indexFactory = new NRTIndexFactory(indexCopier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    return new IndexTracker(new DefaultIndexReaderFactory(defaultMountInfoProvider(), indexCopier), indexFactory);
}
Also used : IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)

Example 3 with IndexTracker

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker in project jackrabbit-oak by apache.

the class DocumentQueueTest method updateDocument.

@Test
public void updateDocument() throws Exception {
    IndexTracker tracker = createTracker();
    NodeState indexed = createAndPopulateAsyncIndex(IndexingMode.NRT);
    tracker.update(indexed);
    DocumentQueue queue = new DocumentQueue(2, tracker, sameThreadExecutor());
    Document d1 = new Document();
    d1.add(newPathField("/a/b"));
    d1.add(new StringField("foo", "a", Field.Store.NO));
    queue.add(LuceneDoc.forUpdate("/oak:index/fooIndex", "/a/b", d1));
    List<NRTIndex> indexes = indexFactory.getIndexes("/oak:index/fooIndex");
    NRTIndex index = indexes.get(indexes.size() - 1);
    assertEquals(1, index.getPrimaryReader().getReader().numDocs());
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) StringField(org.apache.lucene.document.StringField) Document(org.apache.lucene.document.Document) Test(org.junit.Test)

Example 4 with IndexTracker

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker in project jackrabbit-oak by apache.

the class HybridIndexTest method prepareLuceneIndexer.

private void prepareLuceneIndexer(File workDir) {
    try {
        indexCopierDir = createTemporaryFolderIn(workDir);
        copier = new IndexCopier(executorService, indexCopierDir, true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    nrtIndexFactory = new NRTIndexFactory(copier, Clock.SIMPLE, TimeUnit.MILLISECONDS.toSeconds(refreshDeltaMillis), StatisticsProvider.NOOP);
    MountInfoProvider mip = Mounts.defaultMountInfoProvider();
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    luceneEditorProvider = new LuceneIndexEditorProvider(copier, tracker, //extractedTextCache
    null, //augmentorFactory
    null, mip);
    queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    localIndexObserver = new LocalIndexObserver(queue, statsProvider);
    luceneEditorProvider.setIndexingQueue(queue);
}
Also used : LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)

Example 5 with IndexTracker

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker in project jackrabbit-oak by apache.

the class JsonIndexCommand method createLuceneIndexEditorProvider.

private static LuceneIndexEditorProvider createLuceneIndexEditorProvider() {
    LuceneIndexEditorProvider ep = new LuceneIndexEditorProvider();
    ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService((ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5));
    StatisticsProvider statsProvider = StatisticsProvider.NOOP;
    int queueSize = Integer.getInteger("queueSize", 1000);
    IndexTracker tracker = new IndexTracker();
    DocumentQueue queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    ep.setIndexingQueue(queue);
    return ep;
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider)

Aggregations

IndexTracker (org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker)8 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)5 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)5 DefaultIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory)5 IOException (java.io.IOException)3 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)3 LuceneIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory)3 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)3 DocumentQueue (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue)2 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)2 Mounts.defaultMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider)2 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)2 Stopwatch (com.google.common.base.Stopwatch)1 MoreExecutors.sameThreadExecutor (com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor)1 Executor (java.util.concurrent.Executor)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 InitialContent (org.apache.jackrabbit.oak.InitialContent)1 Oak (org.apache.jackrabbit.oak.Oak)1 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)1 NodeCounterEditorProvider (org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)1