Search in sources :

Example 1 with LocalIndexObserver

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

the class LuceneIndexProviderService method registerLocalIndexObserver.

private void registerLocalIndexObserver(BundleContext bundleContext, IndexTracker tracker, Map<String, ?> config) {
    if (!hybridIndex) {
        log.info("Hybrid indexing feature disabled");
        return;
    }
    int queueSize = PropertiesUtil.toInteger(config.get(PROP_HYBRID_QUEUE_SIZE), PROP_HYBRID_QUEUE_SIZE_DEFAULT);
    documentQueue = new DocumentQueue(queueSize, tracker, getExecutorService(), statisticsProvider);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(documentQueue, statisticsProvider);
    regs.add(bundleContext.registerService(Observer.class.getName(), localIndexObserver, null));
    int observerQueueSize = 1000;
    int builderMaxSize = 5000;
    regs.add(bundleContext.registerService(JournalPropertyService.class.getName(), new LuceneJournalPropertyService(builderMaxSize), null));
    ExternalObserverBuilder builder = new ExternalObserverBuilder(documentQueue, tracker, statisticsProvider, getExecutorService(), observerQueueSize);
    log.info("Configured JournalPropertyBuilder with max size {} and backed by BackgroundObserver " + "with queue size {}", builderMaxSize, observerQueueSize);
    Observer observer = builder.build();
    externalIndexObserver = builder.getBackgroundObserver();
    regs.add(bundleContext.registerService(Observer.class.getName(), observer, null));
    oakRegs.add(registerMBean(whiteboard, BackgroundObserverMBean.class, externalIndexObserver.getMBean(), BackgroundObserverMBean.TYPE, "LuceneExternalIndexObserver queue stats"));
    log.info("Hybrid indexing enabled for configured indexes with queue size of {}", queueSize);
}
Also used : ExternalObserverBuilder(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.ExternalObserverBuilder) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) BackgroundObserver(org.apache.jackrabbit.oak.spi.commit.BackgroundObserver) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) LuceneJournalPropertyService(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LuceneJournalPropertyService) BackgroundObserverMBean(org.apache.jackrabbit.oak.spi.commit.BackgroundObserverMBean)

Example 2 with LocalIndexObserver

use of org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver 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)

Aggregations

DocumentQueue (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue)2 LocalIndexObserver (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver)2 IOException (java.io.IOException)1 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)1 IndexTracker (org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker)1 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)1 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)1 ExternalObserverBuilder (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.ExternalObserverBuilder)1 LuceneJournalPropertyService (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LuceneJournalPropertyService)1 NRTIndexFactory (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory)1 DefaultIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory)1 LuceneIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory)1 BackgroundObserver (org.apache.jackrabbit.oak.spi.commit.BackgroundObserver)1 BackgroundObserverMBean (org.apache.jackrabbit.oak.spi.commit.BackgroundObserverMBean)1 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)1 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)1