Search in sources :

Example 1 with DocumentQueue

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

use of org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue in project archiva by apache.

the class RepositoryFactory method createRepository.

public Repository createRepository() throws IOException, InvalidFileStoreVersionException {
    createExecutor();
    if (SEGMENT_FILE_TYPE == storeType) {
        fileStore = FileStoreBuilder.fileStoreBuilder(repositoryPath.toFile()).build();
        nodeStore = // 
        SegmentNodeStoreBuilders.builder(fileStore).withStatisticsProvider(// 
        StatisticsProvider.NOOP).build();
    } else if (IN_MEMORY_TYPE == storeType) {
        nodeStore = null;
    } else {
        throw new IllegalArgumentException("Store type " + storeType + " not recognized");
    }
    Oak oak = nodeStore == null ? new Oak() : new Oak(nodeStore);
    oak.with(new RepositoryInitializer() {

        @Override
        public void initialize(@Nonnull NodeBuilder root) {
            log.info("Creating index ");
            NodeBuilder lucene = IndexUtils.getOrCreateOakIndex(root).child("lucene");
            lucene.setProperty(JcrConstants.JCR_PRIMARYTYPE, "oak:QueryIndexDefinition", Type.NAME);
            lucene.setProperty("compatVersion", 2);
            lucene.setProperty("type", "lucene");
            // lucene.setProperty("async", "async");
            lucene.setProperty(INCLUDE_PROPERTY_TYPES, ImmutableSet.of("String"), Type.STRINGS);
            // lucene.setProperty("refresh",true);
            lucene.setProperty("async", ImmutableSet.of("async", "sync"), Type.STRINGS);
            NodeBuilder rules = lucene.child("indexRules").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            rules.setProperty(":childOrder", // 
            ImmutableSet.of(// 
            "archiva:projectVersion", // 
            "archiva:artifact", // 
            "archiva:facet", // 
            "archiva:namespace", // 
            "archiva:project"), Type.STRINGS);
            NodeBuilder allProps = // 
            rules.child("archiva:projectVersion").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            // allProps.setProperty("propertyIndex",true);
            allProps = // 
            rules.child("archiva:artifact").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            allProps = // 
            rules.child("archiva:facet").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            allProps = // 
            rules.child("archiva:namespace").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            allProps = // 
            rules.child("archiva:project").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            log.info("Index: {} myIndex {}", lucene, lucene.getChildNode("myIndex"));
            log.info("myIndex {}", lucene.getChildNode("myIndex").getProperties());
        // IndexUtils.createIndexDefinition(  )
        }
    });
    StatisticsProvider statsProvider = StatisticsProvider.NOOP;
    int queueSize = Integer.getInteger("queueSize", 10000);
    Path indexDir = Files.createTempDirectory("archiva_index");
    log.info("Queue Index {}", indexDir.toString());
    IndexCopier indexCopier = new IndexCopier(executorService, indexDir.toFile(), true);
    NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(indexCopier, statsProvider);
    MountInfoProvider mountInfoProvider = Mounts.defaultMountInfoProvider();
    IndexTracker tracker = new IndexTracker(new DefaultIndexReaderFactory(mountInfoProvider, indexCopier), nrtIndexFactory);
    DocumentQueue queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, statsProvider);
    LuceneIndexProvider provider = new LuceneIndexProvider(tracker);
    // ExternalObserverBuilder builder = new ExternalObserverBuilder(queue, tracker, statsProvider,
    // executorService, queueSize);
    // Observer observer = builder.build();
    // builder.getBackgroundObserver();
    // 
    LuceneIndexEditorProvider editorProvider = new // 
    LuceneIndexEditorProvider(// 
    null, // 
    tracker, // 
    new ExtractedTextCache(0, 0), null, mountInfoProvider);
    editorProvider.setIndexingQueue(queue);
    log.info("Oak: {} with nodeStore {}", oak, nodeStore);
    Jcr jcr = // 
    new Jcr(oak).with(editorProvider).with(// 
    (Observer) provider).with(localIndexObserver).with(// 
    (QueryIndexProvider) provider);
    // .withAsyncIndexing( "async", 5 );
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    Repository r = jcr.createRepository();
    stopWatch.stop();
    log.info("time to create jcr repository: {} ms", stopWatch.getTime());
    // }
    return r;
}
Also used : Path(java.nio.file.Path) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) StopWatch(org.apache.commons.lang.time.StopWatch) ExtractedTextCache(org.apache.jackrabbit.oak.plugins.index.lucene.ExtractedTextCache) Repository(javax.jcr.Repository) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) Oak(org.apache.jackrabbit.oak.Oak) NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)

Example 3 with DocumentQueue

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

Example 4 with DocumentQueue

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

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

the class HybridIndexTest method prepareLuceneIndexer.

private void prepareLuceneIndexer(File workDir, NodeStore nodeStore) {
    try {
        indexCopierDir = createTemporaryFolderIn(workDir);
        copier = new IndexCopier(executorService, indexCopierDir, true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    IndexPathService indexPathService = new IndexPathServiceImpl(nodeStore);
    AsyncIndexInfoService asyncIndexInfoService = new AsyncIndexInfoServiceImpl(nodeStore);
    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);
    if (syncIndexing) {
        PropertyIndexCleaner cleaner = new PropertyIndexCleaner(nodeStore, indexPathService, asyncIndexInfoService, statsProvider);
        regs.add(scheduleWithFixedDelay(whiteboard, cleaner, cleanerIntervalInSecs, true, true));
    }
    Thread.setDefaultUncaughtExceptionHandler((t, e) -> log.warn("Uncaught exception", e));
}
Also used : IndexPathService(org.apache.jackrabbit.oak.plugins.index.IndexPathService) AsyncIndexInfoService(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) IOException(java.io.IOException) IndexPathServiceImpl(org.apache.jackrabbit.oak.plugins.index.IndexPathServiceImpl) 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) 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) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) AsyncIndexInfoServiceImpl(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoServiceImpl) PropertyIndexCleaner(org.apache.jackrabbit.oak.plugins.index.lucene.property.PropertyIndexCleaner)

Aggregations

DocumentQueue (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue)5 IndexTracker (org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker)4 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)4 LocalIndexObserver (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver)4 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)3 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)3 NRTIndexFactory (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory)3 DefaultIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory)3 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)3 IOException (java.io.IOException)2 LuceneIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory)2 StatisticsProvider (org.apache.jackrabbit.oak.stats.StatisticsProvider)2 Path (java.nio.file.Path)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Repository (javax.jcr.Repository)1 StopWatch (org.apache.commons.lang.time.StopWatch)1 Oak (org.apache.jackrabbit.oak.Oak)1 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)1 AsyncIndexInfoService (org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService)1 AsyncIndexInfoServiceImpl (org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoServiceImpl)1