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;
}
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);
}
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());
}
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);
}
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;
}
Aggregations